/
/
/
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_AUTOPLAY_LABEL = "autoplay_label"
28CONF_AUTOPLAY_MODE = "autoplay_mode"
29CONF_AUTOPLAY_PLAYLIST = "autoplay_playlist"
30CONF_CROSSFADE_LABEL = "crossfade_label"
31
32CONF_SMART_SHUFFLE_LABEL = "smart_shuffle_label"
33CONF_SMART_SHUFFLE_ENABLED = "smart_shuffle_enabled"
34CONF_SMART_SHUFFLE_SONG_RECENCY = "smart_shuffle_song_recency"
35CONF_SMART_SHUFFLE_ARTIST_RECENCY = "smart_shuffle_artist_recency"
36CONF_SMART_SHUFFLE_DUPLICATE_GAP = "smart_shuffle_duplicate_gap"
37
38# window preset values are stored in seconds (0 = off)
39SMART_SHUFFLE_SONG_RECENCY_DEFAULT = 7 * 24 * 3600
40SMART_SHUFFLE_ARTIST_RECENCY_DEFAULT = 30 * 60
41SMART_SHUFFLE_DUPLICATE_GAP_DEFAULT = 3 * 3600
42
43# preset window values in seconds for the smart-shuffle recency selects (0 = off);
44# the per-option titles live in strings.json (config_entries.<key>.options.<seconds>)
45SMART_SHUFFLE_SONG_RECENCY_OPTIONS = (
46 0,
47 3600,
48 14400,
49 43200,
50 86400,
51 259200,
52 604800,
53 1209600,
54 2419200,
55)
56SMART_SHUFFLE_ARTIST_RECENCY_OPTIONS = (0, 300, 900, 1800, 3600, 7200)
57SMART_SHUFFLE_DUPLICATE_GAP_OPTIONS = (0, 3600, 7200, 10800, 14400, 21600, 28800, 43200, 86400)
58
59# Managed-pool sizing: a queue with dynamic sources is kept as a small bounded pool, topped up
60# near the end instead of enqueuing thousands of tracks.
61MANAGED_POOL_TARGET = 25
62MANAGED_POOL_MAX = 50
63# A finite (TRACKS) source is materialized into its own deque and dequeued progressively. This caps
64# how many of its tracks are held in memory at once; a larger source pages the remainder in as the
65# deque drains, so a huge playlist or a bulk manual enqueue can't balloon internal state.
66MANAGED_POOL_SOURCE_CAP = 250
67
68CACHE_CATEGORY_PLAYER_QUEUE_STATE = 0
69CACHE_CATEGORY_PLAYER_QUEUE_ITEMS = 1
70
71# A play command is only complete once the player actually reports playback: several player
72# implementations return from play_media as soon as the start command is out while the device
73# needs another moment to connect and start (AirPlay anchors its audible start in the future).
74# The play action - and with it the UI's in-progress indication - is held until the player
75# reports PLAYING, capped by this timeout so a player that never reports state can't block.
76PLAYBACK_START_TIMEOUT = 5.0
77
78# The queue's cached state/items are written through a debounced timer, so a burst of updates (or
79# the per-track updates during playback) collapses into a single write instead of hitting the cache
80# db on every signal_update.
81QUEUE_CACHE_SAVE_DELAY = 5
82# Bumped when the on-disk queue cache layout changes in a way older code can't read; a version
83# mismatch makes the restore fall back to a clean queue instead of trusting incompatible data.
84CACHE_FORMAT_VERSION = 1
85
86# Media types that may reach us without a duration, so one determined while streaming is applied.
87# Radio and audio sources would wrongly become seekable. Tracks always carry a duration and a
88# rounded value would affect crossfade and gapless timing.
89PROBED_DURATION_MEDIA_TYPES = (
90 MediaType.PODCAST_EPISODE,
91 MediaType.AUDIOBOOK,
92)
93