w3c / media-source

Media Source Extensions
https://w3c.github.io/media-source/
Other
267 stars 57 forks source link

duration assignment to the MediaSource is unclear #230

Closed estobbart closed 5 years ago

estobbart commented 5 years ago

@wolenetz It appears in Chrome when assigning duration to MediaSource that the buffer's updating is set to true without actually dispatching updatestart or the corresponding updateend. It makes sense that it would be updating, because the buffer may need to change it's range due to the newly assigned duration. But it's not well documented here, and the lack of events make it hard to track.

jyavenard commented 5 years ago

Changing the mediasource's duration never remove data from the source buffer, as such, it can't change the buffered range. Also, the spec is rather clear on the matter and there's no mention on having to set the updating attribute to true. https://w3c.github.io/media-source/#duration-change-algorithm

As such, this is an issue that needs to be lodged against chrome issue tracking. not the spec.

estobbart commented 5 years ago

Apologies.. it may not be specific to Chrome. So is it possible that the bounds of the buffer is beyond the duration and that a client adjusting the duration makes no changes to the underlying buffer? Or is it that any assignments my ultimately be ignored for whatever value is greater?

jyavenard commented 5 years ago

if you set duration such that buffered data would be outside the duration of the element, then duration value will actually be set to the "highest end time". The buffered range reflects the actual data found in the sourcebuffer.

it's all described in the link I provided earlier.

There's no rationale for setting the updating attribute to true simply because you set the duration. And TBH, I'd be extremely surprise if chrome did do that. Setting the duration and updating attribute read are synchronous, so even if updating did get change to true internally and back to false when the duration change algorithm has completed it wouldn't be observable from the JS.

estobbart commented 5 years ago

Thanks @jyavenard for clearing this up.