SRGSSR / pillarbox-android

The modern SRG SSR Pillarbox player targeting Android platforms
https://android.pillarbox.ch/api
MIT License
13 stars 1 forks source link

Introduce `PillarboxPreloadManager` #726

Closed MGaetan89 closed 2 weeks ago

MGaetan89 commented 1 month ago

Pull request

Description

This PR introduces a PillarboxPreloadManager and related classes. It also updates the OptimizedStory to use this new helper.

The PillarboxPreloadManager takes the same arguments as DefaultPreloadManager/PillarboxExoPlayer, with the addition of a PlayerPool. This allows PillarboxPreloadManager to create player on-demand, and reuse them if needed.

Changes made

[!NOTE] AndroidX Media3 1.5.0 introduces some changes regarding preload manager. In particular, DefaultPreloadManager.Status.STAGE_LOADED_TO_POSITION_MS will become DefaultPreloadManager.Status.STAGE_LOADED_FOR_DURATION_MS, and will take milliseconds instead of microseconds. This can be addressed once AndroidX Media3 1.5.0 is stable.

Checklist

github-actions[bot] commented 1 month ago

Code Coverage

Overall Project 48.48% -0.42% 🟒
Files changed 62.9% 🟒


Module Coverage
:pillarbox-player 58.06% -0.19% 🟒
:pillarbox-ui 0.2% -1.49% 🟒
Files |Module|File|Coverage|| |:-|:-|:-|:-:| |:pillarbox-player|[PillarboxTrackSelector.kt](https://github.com/SRGSSR/pillarbox-android/blob/e9d5c9a1a6a08ae400c00a975718077ec87dd112/pillarbox-player%2Fsrc%2Fmain%2Fjava%2Fch%2Fsrgssr%2Fpillarbox%2Fplayer%2FPillarboxTrackSelector.kt)|100%|🟒| ||[PillarboxBandwidthMeter.kt](https://github.com/SRGSSR/pillarbox-android/blob/e9d5c9a1a6a08ae400c00a975718077ec87dd112/pillarbox-player%2Fsrc%2Fmain%2Fjava%2Fch%2Fsrgssr%2Fpillarbox%2Fplayer%2FPillarboxBandwidthMeter.kt)|100%|🟒| ||[PillarboxRenderersFactory.kt](https://github.com/SRGSSR/pillarbox-android/blob/e9d5c9a1a6a08ae400c00a975718077ec87dd112/pillarbox-player%2Fsrc%2Fmain%2Fjava%2Fch%2Fsrgssr%2Fpillarbox%2Fplayer%2FPillarboxRenderersFactory.kt)|100%|🟒| ||[PillarboxPreloadManager.kt](https://github.com/SRGSSR/pillarbox-android/blob/e9d5c9a1a6a08ae400c00a975718077ec87dd112/pillarbox-player%2Fsrc%2Fmain%2Fjava%2Fch%2Fsrgssr%2Fpillarbox%2Fplayer%2FPillarboxPreloadManager.kt)|86.29% **`-13.71%`**|🟒| ||[PillarboxExoPlayer.kt](https://github.com/SRGSSR/pillarbox-android/blob/e9d5c9a1a6a08ae400c00a975718077ec87dd112/pillarbox-player%2Fsrc%2Fmain%2Fjava%2Fch%2Fsrgssr%2Fpillarbox%2Fplayer%2FPillarboxExoPlayer.kt)|79.3% **`-0.63%`**|🟒| |:pillarbox-ui|[AndroidPlayerSurfaceView.kt](https://github.com/SRGSSR/pillarbox-android/blob/e9d5c9a1a6a08ae400c00a975718077ec87dd112/pillarbox-ui%2Fsrc%2Fmain%2Fjava%2Fch%2Fsrgssr%2Fpillarbox%2Fui%2Fwidget%2Fplayer%2FAndroidPlayerSurfaceView.kt)|0% **`-28.74%`**|🟒|
MGaetan89 commented 2 weeks ago

Looks good to me πŸ‘πŸ»

@StaehliJ I can't approve it, since I opened the PR. Feel free to approve it, then we can merge it. I just pushed a couple small changes https://github.com/SRGSSR/pillarbox-android/pull/726/commits/1a1a9fe0c198498dbcb27b9f2d3b4c6a87b77f8b

MGaetan89 commented 2 weeks ago

I've switched the runner for the Android Tests step to ubuntu-22.04. See https://github.com/SRGSSR/pillarbox-android/pull/736#issuecomment-2407408319 for more details.

MGaetan89 commented 2 weeks ago

Looks like Google will make it easier to share parameters between the DefaultPreloadManager and ExoPlayer in the next version: https://github.com/androidx/media/commit/98dc7f2def8b7404383a118d02f309870a5bede4

MGaetan89 commented 2 weeks ago

I've reverted my change to the runner. See https://github.com/SRGSSR/pillarbox-android/issues/747#issuecomment-2410190157