SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
159 stars 33 forks source link

tvOS info panel "smarter reload" #85

Closed defagos closed 3 years ago

defagos commented 4 years ago

At the moment, there is no official AVPlayerViewController API to update navigation markers and metadata displayed in the info panel. Updating them on the player item after the view controller has been loaded once does not work. Not only titles or images displayed will not change, but changes in the navigation marker timestamps will not be reflected.

I use a workaround to force a panel refresh, but with the issue that the scrolling position is then reset. The current implementation checks if navigation markers did change (metadata and timestamps), event slightly, and if this is the case forces a reload.

This is probably too much with the current control we have over the info panel, as sometimes times might slightly change (when calculating them based on stream dates). If we assume that markers timestamps are quite constant, we might probably loosen up a bit the comparison so that this better work, e.g. by only comparing the relevant metadata and number of items. Only in such cases should we trigger a reload.

defagos commented 4 years ago

Here is what I found. This may contain errors but should provide the necessary steps to investigate the problem further:

The strategy:

If we want to reduce the number of forced reloads, we still can test metadata only (not ranges) with the following condition:

if (! [[navigationMarkers valueForKeyPath:@"items"] isEqualToArray:[previousNavigationMarkers valueForKeyPath:@"items"]]) {
...
}
defagos commented 4 years ago

Intuition confirmed with a demo project: When playing a DVR livestream, the info panel scroll position is periodically reset. We should probably file a bug.

defagos commented 4 years ago

I don't recommend we reduce the number of reloads. Hopefully tvOS 14 will improve the available APIs and fix the above issue.

defagos commented 4 years ago

Still an issue with tvOS 14.2.

defagos commented 3 years ago

The tvOS player UX has been entirely redesigned in tvOS 15 and most periodic updates now work fine. The reload trick has been removed.