W3C home > Mailing lists > Public > public-html-media@w3.org > June 2012

[MSE] Moving Media Source methods into a separate object.

From: Aaron Colwell <acolwell@google.com>
Date: Thu, 14 Jun 2012 13:17:48 -0700
Message-ID: <CAA0c1bAtOOwtjmxQxU-fqNXXDBu2tJ3nCs5rH5g0W6E=uc_Q9Q@mail.gmail.com>
To: public-html-media@w3.org
Bug 17082 <https://www.w3.org/Bugs/Public/show_bug.cgi?id=17082> was
created because several people suggested that the Media Source Extensions
should be more object oriented instead of just adding methods to
HTMLMediaElement. There was some initial discussion about this in the bug
comments, but I haven't gotten any more feedback after I proposed an
initial design. I'm hoping some discussion on this list will help move this
along since solutions to other bugs may depend on what we decide here.

Here is what I've proposed in the bug.

interface SourceBuffer : EventTarget {
 // Returns the time ranges buffered.
 readonly attribute TimeRanges buffered;

 // Append segment data.
 void append(DOMString url,
             optional unsigned long long start,
             optional unsigned long long length);

 // Abort the current segment append sequence.
 void abort();

 enum EndOfStreamError { "network", "decode" };
 void endOfStream(optional EndOfStreamError error);

 [TreatNonCallableAsNull] attribute Function? onappenddone;
 [TreatNonCallableAsNull] attribute Function? onappenderror;
};

interface SourceBufferList : EventTarget {
 readonly attribute unsigned long length;
 getter SourceBuffer (unsigned long index);
 void remove(SourceBuffer buffer);

 [TreatNonCallableAsNull] attribute Function? onaddsourcebuffer;
 [TreatNonCallableAsNull] attribute Function? onremovesourcebuffer;
};

[Constructor (DOMString type)]
interface MediaSource : EventTarget {
 readonly attribute SourceBufferList buffers;

 // Adds another source buffer.
 SourceBuffer addSourceBuffer(DOMString type);

 enum State { "closed", "open", "ended" };
 readonly attribute State readyState;

 [TreatNonCallableAsNull] attribute Function? onsourceclosed;
 [TreatNonCallableAsNull] attribute Function? onsourceopen;
 [TreatNonCallableAsNull] attribute Function? onsourceended;
};

I've included the url based append signature from Bug
16998<https://www.w3.org/Bugs/Public/show_bug.cgi?id=16998>and string
enums suggested in Bug
16938 <https://www.w3.org/Bugs/Public/show_bug.cgi?id=16938>. If people
want, I can change this back to the current append signature & enum values
so the initial spec edits will be a simple transfomation of the current
text.

The type passed to the MediaSource constructor is the type for the initial
SourceBuffer. I did this because a MediaSource object with no SourceBuffers
isn't really useful.

Associating the MediaSource with a <video> would be similar to
LocalMediaStream.
1. Create a MediaSource object.
2. Use createObjectURL() to get a blob URL for the MediaSource object.
3. Assign the blob URL to HTMLMediaElement.src.

Please let me know what you think.

Thanks,
Aaron
Received on Thursday, 14 June 2012 20:19:08 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:32:55 UTC