/
/
/
1"""Constants for the player queues controller."""
2
3from __future__ import annotations
4
5from music_assistant_models.enums import MediaType
6
7CONF_DEFAULT_ENQUEUE_SELECT_ARTIST = "default_enqueue_select_artist"
8CONF_DEFAULT_ENQUEUE_SELECT_ALBUM = "default_enqueue_select_album"
9
10ENQUEUE_SELECT_ARTIST_DEFAULT_VALUE = "all_tracks"
11ENQUEUE_SELECT_ALBUM_DEFAULT_VALUE = "all_tracks"
12
13CONF_DEFAULT_ENQUEUE_OPTION_ARTIST = "default_enqueue_option_artist"
14CONF_DEFAULT_ENQUEUE_OPTION_ALBUM = "default_enqueue_option_album"
15CONF_DEFAULT_ENQUEUE_OPTION_TRACK = "default_enqueue_option_track"
16CONF_DEFAULT_ENQUEUE_OPTION_GENRE = "default_enqueue_option_genre"
17CONF_DEFAULT_ENQUEUE_OPTION_LIVE_SOURCES = "default_enqueue_option_live_sources"
18CONF_DEFAULT_ENQUEUE_OPTION_PLAYLIST = "default_enqueue_option_playlist"
19CONF_DEFAULT_ENQUEUE_OPTION_AUDIOBOOK = "default_enqueue_option_audiobook"
20CONF_DEFAULT_ENQUEUE_OPTION_PODCAST = "default_enqueue_option_podcast"
21CONF_DEFAULT_ENQUEUE_OPTION_SOUND_EFFECT = "default_enqueue_option_sound_effect"
22CONF_DEFAULT_ENQUEUE_OPTION_PODCAST_EPISODE = "default_enqueue_option_podcast_episode"
23CONF_DEFAULT_ENQUEUE_OPTION_FOLDER = "default_enqueue_option_folder"
24CONF_DEFAULT_ENQUEUE_OPTION_COLLECTION = "default_enqueue_option_collection"
25CONF_DEFAULT_ENQUEUE_OPTION_UNKNOWN = "default_enqueue_option_unknown"
26
27CONF_DEFAULT_CLICK_ACTION_ARTIST = "default_click_action_artist"
28CONF_DEFAULT_CLICK_ACTION_ALBUM = "default_click_action_album"
29CONF_DEFAULT_CLICK_ACTION_TRACK = "default_click_action_track"
30CONF_DEFAULT_CLICK_ACTION_GENRE = "default_click_action_genre"
31CONF_DEFAULT_CLICK_ACTION_RADIO = "default_click_action_radio"
32CONF_DEFAULT_CLICK_ACTION_PLAYLIST = "default_click_action_playlist"
33
34CLICK_ACTION_BROWSE = "browse"
35CLICK_ACTION_PLAY = "play"
36CLICK_ACTION_DEFAULT_VALUE = CLICK_ACTION_BROWSE
37
38CONF_DEFAULT_PLAY_ACTION_ALBUM_TRACK = "default_play_action_album_track"
39CONF_DEFAULT_PLAY_ACTION_PLAYLIST_TRACK = "default_play_action_playlist_track"
40
41PLAY_ACTION_PLAY_FROM_HERE = "play_from_here"
42PLAY_ACTION_PLAY_TRACK = "play_track"
43PLAY_ACTION_TRACK_DEFAULT_VALUE = PLAY_ACTION_PLAY_FROM_HERE
44
45CONF_AUTOPLAY_LABEL = "autoplay_label"
46CONF_AUTOPLAY_MODE = "autoplay_mode"
47CONF_AUTOPLAY_PLAYLIST = "autoplay_playlist"
48CONF_CROSSFADE_LABEL = "crossfade_label"
49
50CONF_SMART_SHUFFLE_LABEL = "smart_shuffle_label"
51CONF_SMART_SHUFFLE_ENABLED = "smart_shuffle_enabled"
52CONF_SMART_SHUFFLE_SONG_RECENCY = "smart_shuffle_song_recency"
53CONF_SMART_SHUFFLE_ARTIST_RECENCY = "smart_shuffle_artist_recency"
54CONF_SMART_SHUFFLE_DUPLICATE_GAP = "smart_shuffle_duplicate_gap"
55
56# window preset values are stored in seconds (0 = off)
57SMART_SHUFFLE_SONG_RECENCY_DEFAULT = 7 * 24 * 3600
58SMART_SHUFFLE_ARTIST_RECENCY_DEFAULT = 30 * 60
59SMART_SHUFFLE_DUPLICATE_GAP_DEFAULT = 3 * 3600
60
61# preset window values in seconds for the smart-shuffle recency selects (0 = off);
62# the per-option titles live in strings.json (config_entries.<key>.options.<seconds>)
63SMART_SHUFFLE_SONG_RECENCY_OPTIONS = (
64 0,
65 3600,
66 14400,
67 43200,
68 86400,
69 259200,
70 604800,
71 1209600,
72 2419200,
73)
74SMART_SHUFFLE_ARTIST_RECENCY_OPTIONS = (0, 300, 900, 1800, 3600, 7200)
75SMART_SHUFFLE_DUPLICATE_GAP_OPTIONS = (0, 3600, 7200, 10800, 14400, 21600, 28800, 43200, 86400)
76
77# Managed-pool sizing: a queue with dynamic sources is kept as a small bounded pool, topped up
78# near the end instead of enqueuing thousands of tracks.
79MANAGED_POOL_TARGET = 25
80MANAGED_POOL_MAX = 50
81# A finite (TRACKS) source is materialized into its own deque and dequeued progressively. This caps
82# how many of its tracks are held in memory at once; a larger source pages the remainder in as the
83# deque drains, so a huge playlist or a bulk manual enqueue can't balloon internal state.
84MANAGED_POOL_SOURCE_CAP = 250
85
86# Media types that are not a pool of tracks to shuffle: an album is sequenced by its artist, a
87# podcast or audiobook only makes sense front to back, and a radio station is a single endless
88# stream. Starting one of these plays it as it comes, switching the queue's shuffle off with it,
89# unless the caller asks for shuffle explicitly. Every other type (playlist, artist, genre, ...)
90# keeps whatever the queue is set to.
91ORDERED_MEDIA_TYPES = (
92 MediaType.ALBUM,
93 MediaType.AUDIOBOOK,
94 MediaType.PODCAST,
95 MediaType.PODCAST_EPISODE,
96 MediaType.RADIO,
97)
98
99CACHE_CATEGORY_PLAYER_QUEUE_STATE = 0
100CACHE_CATEGORY_PLAYER_QUEUE_ITEMS = 1
101
102# A play command is only complete once the player actually reports playback: several player
103# implementations return from play_media as soon as the start command is out while the device
104# needs another moment to connect and start (AirPlay anchors its audible start in the future).
105# The play action - and with it the UI's in-progress indication - is held until the player
106# reports PLAYING, capped by this timeout so a player that never reports state can't block.
107PLAYBACK_START_TIMEOUT = 5.0
108
109# The queue's cached state/items are written through a debounced timer, so a burst of updates (or
110# the per-track updates during playback) collapses into a single write instead of hitting the cache
111# db on every signal_update.
112QUEUE_CACHE_SAVE_DELAY = 5
113# Bumped when the on-disk queue cache layout changes in a way older code can't read; a version
114# mismatch makes the restore fall back to a clean queue instead of trusting incompatible data.
115CACHE_FORMAT_VERSION = 1
116
117# Media types that may reach us without a duration, so one determined while streaming is applied.
118# Radio and audio sources would wrongly become seekable. Tracks always carry a duration and a
119# rounded value would affect crossfade and gapless timing.
120PROBED_DURATION_MEDIA_TYPES = (
121 MediaType.PODCAST_EPISODE,
122 MediaType.AUDIOBOOK,
123)
124