/
/
/
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_AUTOPLAY_ENABLED = "autoplay_enabled"
49CONF_CROSSFADE_LABEL = "crossfade_label"
50CONF_CROSSFADE_ENABLED = "crossfade_enabled"
51
52# global defaults the per-queue autoplay/crossfade toggles follow when not overridden
53DEFAULT_AUTOPLAY_ENABLED = True
54DEFAULT_CROSSFADE_ENABLED = False
55
56CONF_SMART_SHUFFLE_LABEL = "smart_shuffle_label"
57CONF_SMART_SHUFFLE_ENABLED = "smart_shuffle_enabled"
58CONF_SMART_SHUFFLE_SONG_RECENCY = "smart_shuffle_song_recency"
59CONF_SMART_SHUFFLE_ARTIST_RECENCY = "smart_shuffle_artist_recency"
60CONF_SMART_SHUFFLE_DUPLICATE_GAP = "smart_shuffle_duplicate_gap"
61
62# window preset values are stored in seconds (0 = off)
63SMART_SHUFFLE_SONG_RECENCY_DEFAULT = 7 * 24 * 3600
64SMART_SHUFFLE_ARTIST_RECENCY_DEFAULT = 30 * 60
65SMART_SHUFFLE_DUPLICATE_GAP_DEFAULT = 3 * 3600
66
67# preset window values in seconds for the smart-shuffle recency selects (0 = off);
68# the per-option titles live in strings.json (config_entries.<key>.options.<seconds>)
69SMART_SHUFFLE_SONG_RECENCY_OPTIONS = (
70 0,
71 3600,
72 14400,
73 43200,
74 86400,
75 259200,
76 604800,
77 1209600,
78 2419200,
79)
80SMART_SHUFFLE_ARTIST_RECENCY_OPTIONS = (0, 300, 900, 1800, 3600, 7200)
81SMART_SHUFFLE_DUPLICATE_GAP_OPTIONS = (0, 3600, 7200, 10800, 14400, 21600, 28800, 43200, 86400)
82
83# Managed-pool sizing: a queue with dynamic sources is kept as a small bounded pool, topped up
84# near the end instead of enqueuing thousands of tracks.
85MANAGED_POOL_TARGET = 25
86MANAGED_POOL_MAX = 50
87# A finite (TRACKS) source is materialized into its own deque and dequeued progressively. This caps
88# how many of its tracks are held in memory at once; a larger source pages the remainder in as the
89# deque drains, so a huge playlist or a bulk manual enqueue can't balloon internal state.
90MANAGED_POOL_SOURCE_CAP = 250
91
92# Media types that are not a pool of tracks to shuffle: an album is sequenced by its artist, a
93# podcast or audiobook only makes sense front to back, and a radio station is a single endless
94# stream. Starting one of these plays it as it comes, switching the queue's shuffle off with it,
95# unless the caller asks for shuffle explicitly. Every other type (playlist, artist, genre, ...)
96# keeps whatever the queue is set to.
97ORDERED_MEDIA_TYPES = (
98 MediaType.ALBUM,
99 MediaType.AUDIOBOOK,
100 MediaType.PODCAST,
101 MediaType.PODCAST_EPISODE,
102 MediaType.RADIO,
103)
104
105CACHE_CATEGORY_PLAYER_QUEUE_STATE = 0
106CACHE_CATEGORY_PLAYER_QUEUE_ITEMS = 1
107
108# A play command is only complete once the player actually reports playback: several player
109# implementations return from play_media as soon as the start command is out while the device
110# needs another moment to connect and start (AirPlay anchors its audible start in the future).
111# The play action - and with it the UI's in-progress indication - is held until the player
112# reports PLAYING, capped by this timeout so a player that never reports state can't block.
113PLAYBACK_START_TIMEOUT = 5.0
114
115# The queue's cached state/items are written through a debounced timer, so a burst of updates (or
116# the per-track updates during playback) collapses into a single write instead of hitting the cache
117# db on every signal_update.
118QUEUE_CACHE_SAVE_DELAY = 5
119# Bumped when the on-disk queue cache layout changes in a way older code can't read; a version
120# mismatch makes the restore fall back to a clean queue instead of trusting incompatible data.
121CACHE_FORMAT_VERSION = 1
122
123# Media types that may reach us without a duration, so one determined while streaming is applied.
124# Radio and audio sources would wrongly become seekable. Tracks always carry a duration and a
125# rounded value would affect crossfade and gapless timing.
126PROBED_DURATION_MEDIA_TYPES = (
127 MediaType.PODCAST_EPISODE,
128 MediaType.AUDIOBOOK,
129)
130