shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.21k stars 1.34k forks source link

Period Change Event #3159

Closed patrickkunka closed 1 year ago

patrickkunka commented 3 years ago

Have you read the Tutorials?

Yes

Have you read the FAQ and checked for duplicate open issues?

Yes

What version of Shaka Player are you using?

2.5.x

Please ask your question

For testing purposes, it would be very helpful to know when shaka player transitions from one period to another in a multi-period manifest. Ideally, this would be at the point that the new period is first displayed on screen, but potentially could also be at the point at which the player starts buffering a new period. Again - ideally - the event would expose metadata about the new period, such as its ID.

I've checked the documentation and cannot find any event that is dispatched on period change. Is there a way to obtain this information via non-public APIs or perhaps via another event like adaptation?

Thank you

joeyparrish commented 3 years ago

In v2.5.x, you could get this with the 'trackschanged' event, since we change the track list on each period transition. I would have to search the source to confirm, but my memory is that it would fire when we start buffering the new period, not when we start playing in it, but it could be the other way around.

In v3.0.x+, we "flatten" the structure of multi-period content upfront, so that there is no longer any modeling of periods in the internal manifest structure. This means that in v3.0.x+, the player doesn't know it's changing periods. It is now modeled more closely on HLS discontinuities than DASH periods.

Does this help?

patrickkunka commented 3 years ago

Thank you that's really helpful, and very interesting regarding the decision to flatten the manifest model and follow HLS in 3.x.

To give a bit more context about our use case at DAZN, specifically related to multi-period DASH:

For playback testing, we have visualisation tools that show things like the active bitrate, estimated bandwidth, playback state - all lined up relative to each other against time. It would be really useful to show when the active period changes, to give context to other things that happen at that time like adaptations (e.g. when switching from a content period to an ad period with different bitrate ladders).

Similarly, for analytics purposes, its useful to know what period a player is in when things like re-buffering and errors occur.

In the context of DAI, we can get of course this sort of information from the ad manager (e.g. google DAI SDK), but it would be really useful to be able to access the raw period ID or model without the added abstraction of having to derive that information from an ad manager (which operates on <Event> data rather than <Periods> anyway, and may contain errors or reporting issues of its own).

So if that makes sense with you, I'd like to turn this into a feature request to expose a couple of new events like onscreenperiodchange and bufferingperiodchange that we could use for this purpose. If it can be done in a manifest agnostic way that could work for DASH periods and HLS discontinuity tags, and work across 2.5.x and 3.x, then even better!

Thanks again

TheModMaker commented 3 years ago

Since there have been other request for this, I think it is fine to have an enhancement request for some events. We could use the different properties of segments to detect when this changes and fire an event. For the "buffering" Period, this should be fairly trivial in StreamingEngine. For what is being played, that is a bit trickier since we'd need to use timeupdate events or some other poll events to detect the differences. But we may be able to use shaka.media.RegionObserver for this.

beka-discovery commented 3 years ago

Hi. Beka from Discovery Inc is here. We use Shaka Player on majority of Platforms. If there is a suggested way we could follow to introduce Period Change event, so we could use internally patched Shaka Player version until you folks deliver the proper fix. Or we could collaborate if we would have some directions to follow.

caridley commented 2 years ago

A period id could be added to the recently implemented media quality change events https://github.com/google/shaka-player/pull/3700

avelad commented 1 year ago

Is anyone interested in this? The issue will be automatically closed in 7 days if no one answers. Thanks!

shaka-bot commented 1 year ago

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.