Core Concepts
State Management
In this section, we'll look at the API available for reading and updating media state.
Reading
You can retrieve a snapshot of the current media state like so:
Subscribing
The <vds-media>
element has a media store that keeps track of the running state of the player. The store enables you to subscribe directly to specific media state changes, rather than listening to potentially multiple DOM events and binding it yourself.
Tracking media state via events:
Tracking media state via store subscription:
Updating
The MediaRemoteControl
class provides a simple facade for dispatching media request events. This can be used to request media playback to play/pause, change the current volume level, seek to a different time position, and other actions that change media state.
Media Element
The MediaRemoteControl
can attempt to find the nearest parent media element once a target has been attached like so: