When the user configures the player according to his or her preference (e.g., starting up the player in mute), these user preferences (i.e., actions that are triggered by the user) create a configurable value, which is saved in the browser’s local storage. The player then uses those saved values to enable the user to retain the last choices they made when playing media.
For example, if the last played media was muted, the next media will begin muted also, even if the user refreshed the page.
The following values are saved under user preferences:
When a player instantiates, a partial configuration is created internally by the StorageManager
and supplied to the player using the saved values found in the local storage.
The structure of this initial configuration is as follows:
{
muted: string,
volume: number,
audioLanguage: string,
textLanguage: string,
captionsDisplay: boolean,
textStyle: TextStyle
}
The following flow-chart diagram shows a high-level workflow of this scenario:
After the player starts to to play, the StorageManager
will track any user interaction with the UI and update the storage value accordingly, as you can see in the following sequence diagram:
Let’s look at an example based on a Chrome browser (this can be done on any supported browser; see next section).
You’ll be able to see your saved player values in the local storage:
The user preference configuration is enabled by default. To disable it, you’ll need to configure the disableUserCache
value as True when creating the player instance.
{
...
disableUserCache: true // Disable user preferences
...
}
The user preference feature works on all browsers that support the localStorage option.
For a complete list of browsers that support localStorage, see here.