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