[whatwg] Assigning media resources represented as DOM objects to a media element
robert at ocallahan.org
Tue Jan 22 19:19:44 PST 2013
Currently there are three kinds of (proposed) DOM objects which can be used
as the source of a media element: Blobs, MediaStreams and MediaSources.
Currently the only way to use one of these objects as the source of a media
element is via "element.src = URL.createObjectURL(object)". This is
problematic because the URLs minted by createObjectURL require manual
revocation. (Forms of auto-revocation have been proposed but a) they seem
difficult to spec in a rational way and b) we will not be able to make
auto-revocation the default.) Forcing authors to deal with manual
revocation makes their lives difficult and increases the chance that users
will encounter resource leaks in Web apps.
The createObjectURL approach also has the downside that there is no
standard way to recover the media element's source as a DOM object.
In Gecko we have implemented a prototype extension to media elements: the
srcObject attribute (currently prefixed). Thus an author can simply write
"element.srcObject = object". (Currently this only works for MediaStream
objects, but the other types are not difficult to support.) This is simpler
for authors, allows recovery of the source object, and most importantly
allows the resource to be managed automatically by standard garbage
Setting srcObject mostly behaves "just like" setting 'src' to
createObjectURL(object). However, 'src' and its corresponding content
attribute are not affected. The rules for choosing a media resource are
modified to check 'srcObject' before 'src'.
I think this would be a worthwhile addition to the Web platform.
Jesus called them together and said, “You know that the rulers of the
Gentiles lord it over them, and their high officials exercise authority
over them. Not so with you. Instead, whoever wants to become great among
you must be your servant, and whoever wants to be first must be your
slave — just
as the Son of Man did not come to be served, but to serve, and to give his
life as a ransom for many.” [Matthew 20:25-28]
More information about the whatwg