bitmovin / bitmovin-player-ui

The Bitmovin Adaptive Streaming Player UI
MIT License
126 stars 87 forks source link

Add API to switch UI variants #101

Closed protyposis closed 6 years ago

protyposis commented 6 years ago

Currently it is possible to define different UI variants that are switched according to criteria provided by the UIConditionContext object when certain player events happen. This means it is only possible to set the criteria for certain UI variants at setup, but switching is done autonomously and internally in the UIManager without any means to interfere from outside. Desired is an API that also allows to trigger switching from outside at any desired time.

The UIConditionContext upon which the target UI variant is evaluated: https://github.com/bitmovin/bitmovin-player-ui/blob/d8a6978f593ad229e96f051257b7d518d9687619/src/ts/uimanager.ts#L80-L118

Example UI variants and criteria setup: https://github.com/bitmovin/bitmovin-player-ui/blob/d8a6978f593ad229e96f051257b7d518d9687619/src/ts/uimanager.ts#L654-L672

The events that trigger the evaluation of the context and potentially switch the UI variant: https://github.com/bitmovin/bitmovin-player-ui/blob/d8a6978f593ad229e96f051257b7d518d9687619/src/ts/uimanager.ts#L339-L349

protyposis commented 6 years ago

Since the UI variants do not have distinct IDs, it is not possible to directly switch to a specific variant, e.g. uimanager.switchToVariant(UIVariant.Ads). The API will thus somehow have to work with the UIConditionContext and allow setting the conditions so the switching code evaluates to the desired UI variant.

protyposis commented 6 years ago

Since the UI variants do not have distinct IDs, it is not possible to directly switch to a specific variant

Solved by using variant references.

protyposis commented 6 years ago

Released in 2.15.0