A MediaSource object is typically attached to a media element.
When this MediaSource is detached from the media element (such as when the src or srcObject attribute is cleared or set to another object), the “3.15.2 Detaching from a media element” algorithm is to be run which will clear all its source buffers and their content and change the readyState of the MediaSource object to “close”
Discussion with users has show interests on having the ability to detach a MediaSource from a media element temporarily to re-attach it again later so that a new MediaSource doesn’t need to be created and having to reload all the original content again which is slow, impact playback quality and result in an interruption.
Proposal:
Provide an optional dictionary to the MediaSource constructor.
it could take an optional dictionary with { detachable: true }
such as const ms = new MediaSource({ detachable: true })
dictionary MediaSourceInit {
boolean detachable = false;
};
The in the MediaSource IDL, the constructor would be amended as follow:
to
constructor(optional MediaSourceInit init = { });
and same for the ManagedMediaSource's constructor.
A new detachable attribute would be added, allowing to detect the functionality and test test if a MediaSource is detachable or not.
readonly attribute boolean detachable;
When a detachable MediaSource is detached from the mediaElement, the Detaching from a media element algorithm https://w3c.github.io/media-source/#mediasource-detach
step 5, 8 and 9 would be skipped.
in the Attaching to a media element algorithm (https://w3c.github.io/media-source/#mediasource-attach)
steps would be modified to allow re-using a MediaSourceHandle (if in worker) or a MediaSource. Such as ignoring the "has ever been attached" internal slot
A MediaSource object is typically attached to a media element.
When this MediaSource is detached from the media element (such as when the src or srcObject attribute is cleared or set to another object), the “3.15.2 Detaching from a media element” algorithm is to be run which will clear all its source buffers and their content and change the readyState of the MediaSource object to “close”
Discussion with users has show interests on having the ability to detach a MediaSource from a media element temporarily to re-attach it again later so that a new MediaSource doesn’t need to be created and having to reload all the original content again which is slow, impact playback quality and result in an interruption.
Proposal:
Provide an optional dictionary to the MediaSource constructor.
it could take an optional dictionary with
{ detachable: true }such as
const ms = new MediaSource({ detachable: true })The in the MediaSource IDL, the constructor would be amended as follow:
to
and same for the
ManagedMediaSource's constructor.A new
detachableattribute would be added, allowing to detect the functionality and test test if aMediaSourceis detachable or not.When a detachable MediaSource is detached from the mediaElement, the
Detaching from a media elementalgorithm https://w3c.github.io/media-source/#mediasource-detachstep 5, 8 and 9 would be skipped.
in the
Attaching to a media elementalgorithm (https://w3c.github.io/media-source/#mediasource-attach)steps would be modified to allow re-using a MediaSourceHandle (if in worker) or a MediaSource. Such as ignoring the "has ever been attached" internal slot