Shaka-player: Fire an event when a manifest is updated

Created on 18 Dec 2018  路  11Comments  路  Source: google/shaka-player

With the STREAMING event I can listen for being notified when the manifest has been downloaded and parsed and the PresentationTimeline is available.

For live streams the manifest is refreshed periodically and I want to be notified about that. Is there a listener I can register for that?

enhancement

Most helpful comment

If you just need to know when we fetch a manifest, you could add a response filter and check the type is shaka.net.NetworkingEngine.RequestType.MANIFEST. You'll need to introduce a slight delay to allow the manifest to be parsed, but that should work now. That also won't work when casting, but you could do something similar on the receiver.

```js
player.getNetworkingEngine().addResponseFilter((type, response) => {
if (type == shaka.net.NetworkingEngine.RequestType.MANIFEST)
setTimeout(() => checkForUpdates(), 500);
});

All 11 comments

@marcbaechinger Thanks for asking! Right now, we don't have an immediate way for the app to listen for a manifest update. In 2.6 we are planning to look at changing how manifest updates work, which would be a great time for us to add this for you.

To help us better understand your use case, do you need to know:

  1. when we got a new copy of the manifest (regardless of whether any content actually changed) or
  2. when we got a new copy of the manifest and the contents of the manifest changed

The former will be far easier for us to handle and most of the time the content would have changed. The later will be much harder because the parser will have the content needed to merge the manifests, but requiring them to fire events adds an extra cost to implementing custom parsers.

Thanks @vaage !

I'm fine with either of these options. I need to know whether periods and other properties of the PresentationTimeline changes.

To have a UI (potentially running on another device like in a Cast sender app) which allows for example seeking in a live window, we need to calculate a couple of things. We need things like segmentAvailabilityStart/End, delay and the like. To have this working properly we need to recalculate when it changes so we can simply recalculate when a new manifest arrives.

If we can have latter of your options it obviously would be more efficient, but if we can have former option earlier I would ask for that. :)

If you just need to know when we fetch a manifest, you could add a response filter and check the type is shaka.net.NetworkingEngine.RequestType.MANIFEST. You'll need to introduce a slight delay to allow the manifest to be parsed, but that should work now. That also won't work when casting, but you could do something similar on the receiver.

```js
player.getNetworkingEngine().addResponseFilter((type, response) => {
if (type == shaka.net.NetworkingEngine.RequestType.MANIFEST)
setTimeout(() => checkForUpdates(), 500);
});

To have a UI (potentially running on another device like in a Cast sender app) which allows for example seeking in a live window, we need to calculate a couple of things.

Are you aware of the .seekRange() method on Player? Or are you intending to compute this differently?

Thanks Joey! Yes, I am aware of getSeekRangeStart/End. That's what we need according to the timeline diagram: https://github.com/google/shaka-player/blob/master/docs/design/timeline.svg

When I understand correctly the seek range is dependent on segmentAvailabilityStart/End which for live can change with each update of the manifest. So in case I want to know when the values returned from getSeekRangeStart/End change, I need to know when the manifest has been refreshed.

Is my understanding correct?

The timeline changes as time passes, not as the manifest is updated. Every second the seek range moves forward by one second (approximately). So you'll need to just poll every second or so to update the UI.

@marcbaechinger Does this answer all your questions? Can we close the issue?

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

Yes, polling every second is an option. I think it actually would be nice being notified when the manifest has change as suggested in comment #2.

Is this something you are going to provide in a future release? I have a kind of a hacky solution for now, so it would be great to know whether such a manifest changed event is planned and when we can expect it.

@shaka-bot reopen

I see no reason we couldn't fire an event for that. It should depend on #1408, though, after which updates will be centralized to Player instead of each manifest parser. After that, it will be trivial to add an event as you requested.

1408 isn't scheduled just yet, but you may want to subscribe to that issue, as well.

Was this page helpful?
0 / 5 - 0 ratings