Settings can be stored in 4 places: localStorage, user, addonCollection, server
The Context
model should only handle the ones that are in localStorage
by default; settings that are specific to the environment (e.g. MPV settings) should be handled externally (in this example, by the player implementation) and hooked up on application level
ContextSettings
: struct, stored in localStorage
Managed by the Context
model, and indirectly by Settings
model
It will contain:
language
: preferred language
autoplay_next_vid
: binge watching
server_url
: default URL for the streaming server
use_external_player
: use external player by default; perhaps this should be a device ID/type, so that it can work for Chromecast
player_esc_exits_fullscreen
: this is not in the player settings cause it affects UI behavior in general
pause_on_lost_focus
: whether to pause on minimize/lost focus; alternatively could be renamed to play_in_background
show_vid_overview
: whether the video overview/synopsis will be readable by the user
ServerSettings
: a struct filled with dynamic data, loaded/saved from/to the server
Managed by the Settings
model
NOTE: because of the dynamic nature, we might not need a struct but rather a model that will load the settings types/values from the server
The server settings will be accessed from the server at URL ctx.settings.server_url
In practice, those settings are:
server_cache_location
server_cache_size
server_torrent_profile
However, those will be loaded dynamically from the server, along with the possible options, as they are in 4.x
WARNING: the ServerSettings
may be replaced by streaming server as a protocol addon and addonSettings
PlayerSettings
: struct, stored in localStorage
Managed by the Player
model, which also manages PlayerPreferences
and sends the settings/preferences to the implementation
The settings are:
subtitles_language
: default subtitles language
subtitles_size
subtitles_fgcolor
subtitles_outline_color
subtitles_background
Those will be sent to the implementation through the Load
player command. Not every implementation will support all of those
MPV settings
Managed (saved/loaded) by the mpv implementation:
player_mpv_hwdec
player_mpv_cache_size
player_mpv_separate_window
Addon settings
Managed by the Settings
model
Auto play: this will be an autoplay
flag for each addon in the collection; that, combined with the order of the addons in the collection, will determine autoplay behavior; the flag may contain details, such as { onlyGroups: ["hd"] }
(more about groups: https://github.com/Stremio/stremio/issues/524)
Settings
model
this model makes managing all settings convenient, including the server settings and add-on settings (preferred add-on and etc.)
This includes:
- saving/loading
ServerSettings
to/from the server
- managing add-on flags in order to set preferences
It might need to issue messages that will be handled in the Context
model (e.g. UpdateSettings
or ActionAddon::Install
/ActionAddon::Update
)
SettingsUI
trait
A helper trait to describe a settings struct in the UI
The server settings are described dynamically by it. We may define this behavior as a trait so that player implementations can use this to enable the Settings
model to easily control their settings too
To implement this, we can:
- add a
Settings
struct to the Ctx
under the settings
property
- Environment-specific settings: player implementations will manage their own settings OR this dynamic map would support nesting other maps into it, and we can use that for player-specific settings (e.g.
player_mpv
key) that will only be sent to the relative player implementation
- the settings structs (
ContextSettings
, PlayerSettings
) will have static properties (like autoplay settings) and if needed (see above), a field that holds everything else as a serde_json::Value
or HashMap<String, Any>
; serialize/deserialize will be done that way (see "capture additional fields")