THEOplayer / android-ui

UI component library for the THEOplayer Android SDK
https://www.theoplayer.com/docs/open-video-ui/android/
MIT License
8 stars 2 forks source link

Rework player API #12

Closed MattiasBuelens closed 1 year ago

MattiasBuelens commented 1 year ago

Unfortunately, our initial API is not powerful enough. Users want to be able to interact with a PlayerState outside of the scope of a DefaultUI or UIController, and they want to be able to wrap it to provide a custom API.

This PR extracts the construction of the THEOplayerView and its associated PlayerState into a public rememberPlayer(config) function, returning a Player. This Player can be passed directly to DefaultUI or UIController, which will then "host" the associated THEOplayerView.

A Player can now also be moved into a different UI without losing the player's state. This is shown in the demo app, where switching between the default theme and the Nitflex theme now retains the playback state.