From cecaa1e39d90a0de9ec54bf0b30f3c3c0234b874 Mon Sep 17 00:00:00 2001
From: Jean-Yves Avenard MediaSource Object
a media element=] algorithm. The extended [=resource fetch algorithm=] uses this internal slot to conditionally
fail attachment of a {{MediaSource}} using a {{MediaSourceHandle}} set on a {{HTMLMediaElement}}'s
{{HTMLMediaElement/srcObject}} attribute.
Each {{MediaSource}} object has a [[\is actively managed flag]] internal slot that stores a boolean indicating if the MediaSource object is actively managing its content or not. + It is initialized to false when the MediaSource object is created.
enum ReadyState { "closed", @@ -412,8 +414,17 @@Attributes
The ManagedMediaSource object is a MediaSource object that actively manages its memory content. + Unlike a MediaSource object it can evict from its ManagedSourceBuffer objects when the User Agent is under memory pressure.
+ +Each {{ManagedMediaSource}} object has a [[\is actively managed flag]] internal + slot that stores a {{boolean}}. It is initialized to true when the {{ManagedMediaSource}} object is created.
+ +[Exposed=(Window,DedicatedWorker)] +interface ManagedMediaSource : MediaSource { + constructor(); + + readonly attribute boolean streaming; + attribute EventHandler onstartstreaming; + attribute EventHandler onendstreaming; + + static boolean isTypeSupported (DOMString type); + };+
streaming
of type boolean, readonlyOn getting, run the following steps:
+onstartstreaming
of type {{EventHandler}}The event handler for the {{startstreaming}} event.
+onendstreaming
of type {{EventHandler}}The event handler for the {{endstreaming}} event.
+isTypeSupported
, staticCheck to see whether the ManagedMediaSource is capable of creating ManagedSourceBuffer objects for the specified MIME type.
+ ++ If true is returned from this method, it only indicates that the ManagedMediaSource implementation is capable of creating ManagedSourceBuffer objects for the specified MIME type. An {{MediaSource/addSourceBuffer()}} call SHOULD still fail if sufficient resources are not available to support the addition of a new ManagedSourceBuffer. +
++ This method returning true implies that HTMLMediaElement.canPlayType() will return "maybe" or "probably" since it does not make sense for a ManagedMediaSource to support a type the HTMLMediaElement knows it cannot play. +
+Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
|type| | {{DOMString}} | ✘ | ✘ |
Event name | +Interface | +Dispatched when... | +
---|---|---|
startstreaming |
+ Event |
+ {{ManagedMediaSource/streaming}} transitions from {{""false""}} to {{""true""}}. | +
endstreaming |
+ Event |
+ {{ManagedMediaSource/streaming}} transitions from {{""true""}} to {{""false""}}. | +
The following steps are run periodically, whenever the {{MediaSource}} SourceBuffer Monitoring algorithm was scheduled to be running.
+Having enough managed data to ensure uninterrupted playback is an implementation specific condition where the user agent + determines that it currently has enough data to play the presentation without stalling for a meaningful period of time and that it can achieve a balance between optimal memory and energy usage. + This condition is constantly evaluated to determine when to transition the media element into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. + These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.
+[Exposed=Window,DedicatedWorker] +interface BufferedChangeEvent : Event { + constructor(DOMString type, optional BufferedChangeEventInit eventInitDict); + + [SameObject] readonly attribute TimeRanges? addedRanges; + [SameObject] readonly attribute TimeRanges? removedRanges; +}; + +dictionary BufferedChangeEventInit : EventInit { + TimeRanges? addedRanges = null; + TimeRanges? removedRanges = null; +}; +
Value | Description |
---|---|
addedRanges |
+ The TimeRanges added during the last appendBuffer() operation. + |
removedRanges |
+ The TimeRanges removed during the last remove() operation or if the User-Agent evicted content in response to a memory pressure. + |
[Exposed=(Window,DedicatedWorker)] +interface ManagedSourceBuffer : SourceBuffer { + attribute EventHandler onbufferedchange; +};+
onbufferedchange
of type {{EventHandler}}The event handler for the {{bufferedchange}} event.
+Event name | +Interface | +Dispatched when... | +
---|---|---|
bufferedchange |
+ Event |
+ The ManagedSourceBuffer's buffered range changed following an appendBuffer, remove or [=memory pressure algorithm=]. | +
The following steps are run whenever a change to the {{ManagedSourceBuffer}} is performed that would cause {{SourceBuffer.buffered}} to change. +
Implementations MAY use different methods for selecting |removal ranges| so web applications SHOULD NOT depend on a + specific behavior. The web application should listen to the {{ManagedSourceBuffer/bufferedchange}} event to observe whether portions of the buffered data have been evicted. +
+This section specifies what existing {{HTMLMediaElement}}.{{HTMLMediaElement/seekable}} and
From 8b8b51fbc872d62854a2aad5d66746e0e89d7fa2 Mon Sep 17 00:00:00 2001
From: Jean-Yves Avenard Example use of the Media Source ExtensionsByte Stream Formats
Examples
- Use of the Media Source Extensions
<script>
@@ -3392,6 +3393,70 @@
Examples
Example use of the Managed Media Source Extensions
+ <script>
+async function setUpVideoStream(){
+ // Specific video format and codec
+ const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"';
+
+ // Check if the type of video format / codect is supported.
+ if (!window.ManagedMediaSource || !ManagedMediaSource.isTypeSupported(mediaType)) {
+ return; // Not supported, do something else.
+ }
+
+ // Set up video and its managed source.
+ const video = document.createElement("video");
+ const source = new ManagedMediaSource();
+
+ video.disableRemotePlayback = true;
+ video.controls = true;
+
+ await new Promise((resolve) => {
+ video.src = URL.createObjectURL(source);
+ source.addEventListener("sourceopen", resolve, { once: true });
+ document.body.appendChild(video);
+ });
+
+ const sourceBuffer = source.addSourceBuffer(mediaType);
+
+ // Set up the event handlers
+ sourceBuffer.onbufferedchange = (e) => {
+ console.log("onbufferedchange event fired.");
+ console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`);
+ console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`);
+ };
+
+ source.onstartstreaming = async () => {
+ const response = await fetch("./videos/bipbop.mp4");
+ const buffer = await response.arrayBuffer();
+ await new Promise((resolve) => {
+ sourceBuffer.addEventListener("updateend", resolve, { once: true });
+ sourceBuffer.appendBuffer(buffer);
+ });
+ };
+
+ source.onendstreaming = async () => {
+ // Stop fetching new segments here
+ };
+}
+
+// Helper function...
+function timeRangesToString(timeRanges) {
+ const ranges = [];
+ for (let i = 0; i < timeRanges?.length; i++) {
+ const range = [timeRanges.start(i), timeRanges.end(i)];
+ ranges.push(range);
+ }
+ return ranges.toString();
+}
+
+
+
+ Use of the Media Source Extensions
<script> From 89e6791f3c873a9da8811bdc0d3916e5805722c2 Mon Sep 17 00:00:00 2001 From: Jean-Yves AvenardDate: Mon, 16 Oct 2023 18:24:13 +1100 Subject: [PATCH 04/46] escape html so that body of example shows --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index f35d693..45ea16d 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3452,7 +3452,7 @@ Use of the Managed Media Source Extensions
return ranges.toString(); } - +<body onload="setUpVideoStream()"></body>
Each {{MediaSource}} object has a [[\is actively managed flag]] internal slot that stores a boolean indicating if the MediaSource object is actively managing its content or not. - It is initialized to false when the MediaSource object is created. - +
+ Each {{MediaSource}} object has a + [[\is actively managed flag]] internal + slot that stores a boolean indicating if the {{MediaSource}} object is + actively managing its content or not. It is initialized to false when the + {{MediaSource}} object is created. +
enum ReadyState { "closed", "open", @@ -415,36 +419,29 @@Attributes
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
|type| | {{DOMString}} | ✘ | ✘ |
removeSourceBuffer
Removes a {{SourceBuffer}} from {{MediaSource/sourceBuffers}}.
@@ -2703,12 +2700,12 @@addsourcebuffer
Event
removesourcebuffer
Event
The ManagedMediaSource object is a MediaSource object that actively manages its memory content. - Unlike a MediaSource object it can evict from its ManagedSourceBuffer objects when the User Agent is under memory pressure.
- -Each {{ManagedMediaSource}} object has a [[\is actively managed flag]] internal - slot that stores a {{boolean}}. It is initialized to true when the {{ManagedMediaSource}} object is created.
- -[Exposed=(Window,DedicatedWorker)] -interface ManagedMediaSource : MediaSource { - constructor(); - - readonly attribute boolean streaming; - attribute EventHandler onstartstreaming; - attribute EventHandler onendstreaming; - - static boolean isTypeSupported (DOMString type); - };-
+ A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its + memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it + from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory pressure=]. +
-streaming
of type boolean, readonlyOn getting, run the following steps:
-onstartstreaming
of type {{EventHandler}}The event handler for the {{startstreaming}} event.
-onendstreaming
of type {{EventHandler}}The event handler for the {{endstreaming}} event.
-isTypeSupported
, staticCheck to see whether the ManagedMediaSource is capable of creating ManagedSourceBuffer objects for the specified MIME type.
++ [Exposed=(Window,DedicatedWorker)] + interface ManagedMediaSource : MediaSource { + constructor(); + readonly attribute boolean streaming; + attribute EventHandler onstartstreaming; + attribute EventHandler onendstreaming; + + static boolean isTypeSupported(DOMString type); + }; ++
streaming
+ On getting:
++ Checks to see whether the user agent would be capable of instantiating + a {{ManagedSourceBuffer}} instance for the given [=MIME type=] + |type:DOMString|. +
- If true is returned from this method, it only indicates that the ManagedMediaSource implementation is capable of creating ManagedSourceBuffer objects for the specified MIME type. An {{MediaSource/addSourceBuffer()}} call SHOULD still fail if sufficient resources are not available to support the addition of a new ManagedSourceBuffer. + If true is returned from this method, it only indicates that the + {{ManagedMediaSource}} implementation is capable of creating + {{ManagedSourceBuffer}} objects for the specified MIME type. An + {{MediaSource/addSourceBuffer()}} call SHOULD still fail if there are + insufficient resources available to support the addition of a new + {{ManagedSourceBuffer}}.
- This method returning true implies that HTMLMediaElement.canPlayType() will return "maybe" or "probably" since it does not make sense for a ManagedMediaSource to support a type the HTMLMediaElement knows it cannot play. + This method returning true implies that {{HTMLMediaElement}}'s {{HTMLMediaElement/canPlayType()}} + will return {{CanPlayTypeResult["maybe"]}} or {{CanPlayTypeResult/["probably"]}} + since it does not make sense for a {{ManagedMediaSource}} to support a type + the {{HTMLMediaElement}} knows it cannot play.
-Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
|type| | {{DOMString}} | ✘ | ✘ |
startstreaming |
- Event |
- {{ManagedMediaSource/streaming}} transitions from {{""false""}} to {{""true""}}. | ++ startstreaming + | +{{Event}} | ++ {{ManagedMediaSource/streaming}} transitions from `false` to + `true`. + |
endstreaming |
- Event |
- {{ManagedMediaSource/streaming}} transitions from {{""true""}} to {{""false""}}. | ++ endstreaming + | +{{Event}} | ++ {{ManagedMediaSource/streaming}} transitions from `true` to + `false`. + |
The following steps are run periodically, whenever the {{MediaSource}} SourceBuffer Monitoring algorithm was scheduled to be running.
-Having enough managed data to ensure uninterrupted playback is an implementation specific condition where the user agent - determines that it currently has enough data to play the presentation without stalling for a meaningful period of time and that it can achieve a balance between optimal memory and energy usage. - This condition is constantly evaluated to determine when to transition the media element into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. - These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.
-+ The following steps are run periodically, whenever the {{MediaSource}} + {{SourceBuffer}} Monitoring algorithm is scheduled to run. +
++ Having enough managed data to ensure uninterrupted playback + is an implementation specific condition where the user agent determines + that it currently has enough data to play the presentation without + stalling for a meaningful period of time and that it can achieve a + balance between optimal memory and energy usage. This condition is + constantly evaluated to determine when to transition the media element + into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. + These transitions indicate when the user agent believes it has enough + data buffered or it needs more data respectively. +
+[Exposed=Window,DedicatedWorker] -interface BufferedChangeEvent : Event { - constructor(DOMString type, optional BufferedChangeEventInit eventInitDict); - - [SameObject] readonly attribute TimeRanges? addedRanges; - [SameObject] readonly attribute TimeRanges? removedRanges; -}; - -dictionary BufferedChangeEventInit : EventInit { - TimeRanges? addedRanges = null; - TimeRanges? removedRanges = null; -}; -
Value | Description |
---|---|
addedRanges |
- The TimeRanges added during the last appendBuffer() operation. - |
removedRanges |
- The TimeRanges removed during the last remove() operation or if the User-Agent evicted content in response to a memory pressure. - |
[Exposed=(Window,DedicatedWorker)] -interface ManagedSourceBuffer : SourceBuffer { - attribute EventHandler onbufferedchange; -};-
onbufferedchange
of type {{EventHandler}}The event handler for the {{bufferedchange}} event.
-Event name | -Interface | -Dispatched when... | -
---|---|---|
bufferedchange |
- Event |
- The ManagedSourceBuffer's buffered range changed following an appendBuffer, remove or [=memory pressure algorithm=]. | -
The following steps are run whenever a change to the {{ManagedSourceBuffer}} is performed that would cause {{SourceBuffer.buffered}} to change. -
+ [Exposed=(Window,DedicatedWorker)] + interface BufferedChangeEvent : Event { + constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {}); + + [SameObject] readonly attribute TimeRanges? addedRanges; + [SameObject] readonly attribute TimeRanges? removedRanges; + }; + + dictionary BufferedChangeEventInit : EventInit { + TimeRanges? addedRanges = null; + TimeRanges? removedRanges = null; + }; ++
Value | +Description | +
---|---|
+ addedRanges
+ |
+
+ The TimeRanges added during the last appendBuffer() operation. + |
+
+ removedRanges
+ |
+
+ + The TimeRanges removed during the last remove() operation or if the + User-Agent evicted content in response to a memory pressure. + + |
+
+ [Exposed=(Window,DedicatedWorker)] + interface ManagedSourceBuffer : SourceBuffer { + attribute EventHandler onbufferedchange; + }; ++
onbufferedchange
of type {{EventHandler}}
+ The event handler for the {{bufferedchange}} event.
Implementations MAY use different methods for selecting |removal ranges| so web applications SHOULD NOT depend on a
- specific behavior. The web application should listen to the {{ManagedSourceBuffer/bufferedchange}} event to observe whether portions of the buffered data have been evicted.
+
+ Event Summary
+
+
+
+
+
+
+
+ Event name
+ Interface
+ Dispatched when...
+
+
+
+
+ bufferedchange
+
+ {{Event}}
+
+ The {{ManagedSourceBuffer}}'s buffered range changed following an
+ appendBuffer, remove or [=ManagedSourceBuffer/memory pressure=]
+ algorithm.
+
+
+ The following steps are run whenever a change to the + {{ManagedSourceBuffer}} is performed that would cause a + {{SourceBuffer}}'s {{SourceBuffer/buffered}} to change.
- -+ Implementations MAY use different methods for selecting |removal + ranges| so web applications SHOULD NOT depend on a specific + behavior. The web application should listen to the + {{ManagedSourceBuffer/bufferedchange}} event to observe whether + portions of the buffered data have been evicted. +
+This section specifies what existing {{HTMLMediaElement}}.{{HTMLMediaElement/seekable}} and @@ -3394,68 +3545,65 @@
<script> -async function setUpVideoStream(){ - // Specific video format and codec - const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"'; - - // Check if the type of video format / codect is supported. - if (!window.ManagedMediaSource || !ManagedMediaSource.isTypeSupported(mediaType)) { - return; // Not supported, do something else. - } - - // Set up video and its managed source. - const video = document.createElement("video"); - const source = new ManagedMediaSource(); - - video.disableRemotePlayback = true; - video.controls = true; - - await new Promise((resolve) => { - video.src = URL.createObjectURL(source); - source.addEventListener("sourceopen", resolve, { once: true }); - document.body.appendChild(video); - }); - - const sourceBuffer = source.addSourceBuffer(mediaType); - - // Set up the event handlers - sourceBuffer.onbufferedchange = (e) => { - console.log("onbufferedchange event fired."); - console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`); - console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`); - }; - - source.onstartstreaming = async () => { - const response = await fetch("./videos/bipbop.mp4"); - const buffer = await response.arrayBuffer(); - await new Promise((resolve) => { - sourceBuffer.addEventListener("updateend", resolve, { once: true }); - sourceBuffer.appendBuffer(buffer); - }); - }; - - source.onendstreaming = async () => { - // Stop fetching new segments here - }; -} - -// Helper function... -function timeRangesToString(timeRanges) { - const ranges = []; - for (let i = 0; i < timeRanges?.length; i++) { - const range = [timeRanges.start(i), timeRanges.end(i)]; - ranges.push(range); - } - return ranges.toString(); -} -</script> -<body onload="setUpVideoStream()"></body> --
+ <script> + async function setUpVideoStream() { + // Specific video format and codec + const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"'; + + // Check if the type of video format / codec is supported. + if (ManagedMediaSource?.isTypeSupported(mediaType)) { + return; // Not supported, do something else. + } + + // Set up video and its managed source. + const video = document.createElement("video"); + const source = new ManagedMediaSource(); + + video.disableRemotePlayback = true; + video.controls = true; + + await new Promise((resolve) => { + video.src = URL.createObjectURL(source); + source.addEventListener("sourceopen", resolve, { once: true }); + document.body.appendChild(video); + }); + + const sourceBuffer = source.addSourceBuffer(mediaType); + + // Set up the event handlers + sourceBuffer.onbufferedchange = (e) => { + console.log("onbufferedchange event fired."); + console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`); + console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`); + }; + + source.onstartstreaming = async () => { + const response = await fetch("./videos/bipbop.mp4"); + const buffer = await response.arrayBuffer(); + await new Promise((resolve) => { + sourceBuffer.addEventListener("updateend", resolve, { once: true }); + sourceBuffer.appendBuffer(buffer); + }); + }; + + source.onendstreaming = async () => { + // Stop fetching new segments here + }; + } + + // Helper function... + function timeRangesToString(timeRanges) { + const ranges = []; + for (let i = 0; i < timeRanges?.length; i++) { + const range = [timeRanges.start(i), timeRanges.end(i)]; + ranges.push(range); + } + return ranges.toString(); + } + </script> + <body onload="setUpVideoStream()"></body> +
A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it - from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory pressure=]. + from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory + pressure=].
@@ -2737,16 +2738,16 @@ManagedMediaSource interface
Attributes
streaming
+ streaming
On getting:
- Checks to see whether the user agent would be capable of instantiating - a {{ManagedSourceBuffer}} instance for the given [=MIME type=] + Checks to see whether the user agent would be capable of instantiating a + {{ManagedSourceBuffer}} object for the given [=MIME type=] |type:DOMString|.
If true is returned from this method, it only indicates that the {{ManagedMediaSource}} implementation is capable of creating {{ManagedSourceBuffer}} objects for the specified MIME type. An - {{MediaSource/addSourceBuffer()}} call SHOULD still fail if there are + {{MediaSource/addSourceBuffer()}} call can still fail if there are insufficient resources available to support the addition of a new {{ManagedSourceBuffer}}.
- This method returning true implies that {{HTMLMediaElement}}'s {{HTMLMediaElement/canPlayType()}} - will return {{CanPlayTypeResult["maybe"]}} or {{CanPlayTypeResult/["probably"]}} - since it does not make sense for a {{ManagedMediaSource}} to support a type + This method returning true implies that {{HTMLMediaElement}}'s + {{HTMLMediaElement/canPlayType()}} will return + {{CanPlayTypeResult/"maybe"}} or {{CanPlayTypeResult/"probably"}} since + it does not make sense for a {{ManagedMediaSource}} to support a type the {{HTMLMediaElement}} knows it cannot play.
Event name | -Interface | -Dispatched when... | -
---|---|---|
- startstreaming - | -{{Event}} | -- {{ManagedMediaSource/streaming}} transitions from `false` to - `true`. - | -
- endstreaming - | -{{Event}} | -- {{ManagedMediaSource/streaming}} transitions from `true` to - `false`. - | -
- The following steps are run periodically, whenever the {{MediaSource}} - {{SourceBuffer}} Monitoring algorithm is scheduled to run. -
-- Having enough managed data to ensure uninterrupted playback - is an implementation specific condition where the user agent determines - that it currently has enough data to play the presentation without - stalling for a meaningful period of time and that it can achieve a - balance between optimal memory and energy usage. This condition is - constantly evaluated to determine when to transition the media element - into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. - These transitions indicate when the user agent believes it has enough - data buffered or it needs more data respectively. -
-Event name | +Interface | +Dispatched when... | +
---|---|---|
+ startstreaming + | +{{Event}} | ++ {{ManagedMediaSource/streaming}} attribute changes from `false` to `true`. + | +
+ endstreaming + | +{{Event}} | ++ {{ManagedMediaSource/streaming}} attribute changes from `true` to `false`. + | +
+ The following steps are run periodically, whenever the {{MediaSource}} + {{SourceBuffer}} Monitoring algorithm is scheduled to run. +
++ Having enough managed data to ensure uninterrupted playback + is an implementation specific condition where the user agent determines that + it currently has enough data to play the presentation without stalling for a + meaningful period of time and that it can achieve a balance between optimal + memory and energy usage. This condition is constantly evaluated to determine + when to transition the media element into and out of the + {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. These transitions + indicate when the user agent believes it has enough data buffered or it + needs more data respectively. +
+[Exposed=(Window,DedicatedWorker)] interface BufferedChangeEvent : Event { constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {}); - + [SameObject] readonly attribute TimeRanges? addedRanges; [SameObject] readonly attribute TimeRanges? removedRanges; }; - + dictionary BufferedChangeEventInit : EventInit { TimeRanges? addedRanges = null; TimeRanges? removedRanges = null; };-
Value | -Description | -
---|
- addedRanges
- |
-
- The TimeRanges added during the last appendBuffer() operation. - |
+ Event name | +Interface | +Dispatched when... |
---|---|---|---|---|
- removedRanges
+ bufferedchange
|
+ {{Event}} |
- - The TimeRanges removed during the last remove() operation or if the - User-Agent evicted content in response to a memory pressure. - + The {{ManagedSourceBuffer}}'s buffered range changed following a + call to {{SourceBuffer/appendBuffer()}}, {{ManagedSourceBuffer/remove()}}, + or as a consequence of the user agent running the + [=ManagedSourceBuffer/memory pressure=] algorithm. |
- [Exposed=(Window,DedicatedWorker)] - interface ManagedSourceBuffer : SourceBuffer { - attribute EventHandler onbufferedchange; - }; --
onbufferedchange
of type {{EventHandler}}
- The event handler for the {{bufferedchange}} event.
-Event name | -Interface | -Dispatched when... | -
---|---|---|
- bufferedchange - | -{{Event}} | -- The {{ManagedSourceBuffer}}'s buffered range changed following an - appendBuffer, remove or [=ManagedSourceBuffer/memory pressure=] - algorithm. - | -
- The following steps are run whenever a change to the - {{ManagedSourceBuffer}} is performed that would cause a - {{SourceBuffer}}'s {{SourceBuffer/buffered}} to change. + +
+ The following steps are run whenever a change to the {{ManagedSourceBuffer}} + is performed that would cause a {{SourceBuffer}}'s {{SourceBuffer/buffered}} + to change. +
++ Implementations can use different methods for selecting |removal ranges| + so web applications shouldn't depend on a specific behavior. The web + application would listen to the {{bufferedchange}} event to observe + whether portions of the buffered data have been evicted.
-- Implementations MAY use different methods for selecting |removal - ranges| so web applications SHOULD NOT depend on a specific - behavior. The web application should listen to the - {{ManagedSourceBuffer/bufferedchange}} event to observe whether - portions of the buffered data have been evicted. -
-[Exposed=(Window,DedicatedWorker)] interface BufferedChangeEvent : Event { - constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {}); + constructor(DOMString type, BufferedChangeEventInit eventInitDict); - [SameObject] readonly attribute TimeRanges? addedRanges; - [SameObject] readonly attribute TimeRanges? removedRanges; + [SameObject] readonly attribute TimeRanges addedRanges; + [SameObject] readonly attribute TimeRanges removedRanges; }; dictionary BufferedChangeEventInit : EventInit { - TimeRanges? addedRanges = null; - TimeRanges? removedRanges = null; + TimeRanges addedRanges; + TimeRanges removedRanges; };
The following steps are run whenever a change to the {{ManagedSourceBuffer}} - is performed that would cause a {{SourceBuffer}}'s {{SourceBuffer/buffered}} - to change. + |buffer:ManagedSourceBuffer| is performed that would cause a + a |buffer|'s {{SourceBuffer/buffered}} to change.
- The following steps are run whenever a change to the {{ManagedSourceBuffer}} - |buffer:ManagedSourceBuffer| is performed that would cause a - a |buffer|'s {{SourceBuffer/buffered}} to change. + The following steps are run at the completion of all operations to the {{ManagedSourceBuffer}} + |buffer:ManagedSourceBuffer| that would cause a |buffer|'s {{SourceBuffer/buffered}} to change. + That is once {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}} or + [=ManagedSourceBuffer/memory pressure=] algorithm have completed.
A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it - from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory + from a {{ManagedSourceBuffer}} may evict content from its {{MediaSource/sourceBuffers}} for any reasons, including when under [=ManagedMediaSource/memory pressure=].
From 1522ecc04f62af9550ea615f1d5eb3f8e2b3d019 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard- Checks to see whether the user agent would be capable of instantiating a - {{ManagedSourceBuffer}} object for the given [=MIME type=] - |type:DOMString|. -
-- If true is returned from this method, it only indicates that the - {{ManagedMediaSource}} implementation is capable of creating - {{ManagedSourceBuffer}} objects for the specified MIME type. An - {{MediaSource/addSourceBuffer()}} call can still fail if there are - insufficient resources available to support the addition of a new - {{ManagedSourceBuffer}}. -
-- This method returning true implies that {{HTMLMediaElement}}'s - {{HTMLMediaElement/canPlayType()}} will return - {{CanPlayTypeResult/"maybe"}} or {{CanPlayTypeResult/"probably"}} since - it does not make sense for a {{ManagedMediaSource}} to support a type - the {{HTMLMediaElement}} knows it cannot play. -
-{{Event}} | - {{ManagedMediaSource/streaming}} attribute changes from `false` to `true`. + {{ManagedMediaSource/streaming}} attribute changed from `false` to `true`. |
{{Event}} | - {{ManagedMediaSource/streaming}} attribute changes from `true` to `false`. + {{ManagedMediaSource/streaming}} attribute changed from `true` to `false`. | {{Event}} | - {{ManagedMediaSource/streaming}} attribute changed from `false` to `true`. + A {{ManagedMediaSource}}'s {{ManagedMediaSource/streaming}} attribute changed from `false` to `true`. |
{{Event}} | - {{ManagedMediaSource/streaming}} attribute changed from `true` to `false`. + A {{ManagedMediaSource}}'s {{ManagedMediaSource/streaming}} attribute changed from `true` to `false`. | The {{ManagedSourceBuffer}}'s buffered range changed following a call to {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}}, + {{MediaSource/endOfStream()}}, or as a consequence of the user agent running the [=ManagedSourceBuffer/memory cleanup=] algorithm. | From 4fc0c11974efdf0335f374e1f343f0aab07c5a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=