This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
In current spec, if an app wants to clear a SourceBuffer's non-empty trackDefaults, it must set the attribute to a TrackDefaultList that was constructed with an empty sequence<TrackDefault>. For example: ... sb = mediaSource.activeSourceBuffers[0]; sb.trackDefaults = new TrackDefaultList( [] ); ... This bug is to request change to spec to make this operation more natural, by specifying: 0. the SourceBuffer.trackDefaults attribute is nullable 1. the SourceBuffer.trackDefaults attribute setter allows null 2. the initial value of SourceBuffer.trackDefaults is null 3. the default {language, kind, label} algorithms behave correctly if trackDefaults is null These changes would be app-visible and #2 would possibly break existing apps. Alternatively, maybe #2 should be: 2. prior to any explicit set operation by app, the SourceBuffer.trackDefaults attribute getter should return an empty TrackDefaultList object that is the same object (===) each time for this SourceBuffer.
I think letting it default to null seems the most sane, a dummy object that doesn't hold any real info is a bit odd.
About potential breakage, has SourceBuffer.trackDefaults been shipped in any browser?
I'm not sure I agree with this position. It seems annoying to me that application code would always have to check for null AND then check for length > 0 before it could actually use the defaults. Having it always be non-null seems like a good way to avoid at least one of these checks. I agree that requiring the [] is ugly. What if I made the constructor parameter optional and provided a default of []? That at least makes it a little less ugly.
(In reply to Aaron Colwell from comment #3) > I agree that requiring the [] is ugly. What if I made the constructor > parameter optional and provided a default of []? That at least makes it a > little less ugly. This seems a good approach to me.
That seems OK to me too.
Change committed... https://github.com/w3c/media-source/commit/acd9345d853100eea4d5d19eca12347142c857b2