apple_music/
application_data.rs

1use crate::playlist::Playlist;
2use crate::track::Track;
3use serde::Deserialize;
4
5/// Contains data related to the Apple Music player, as well as a list of user's Playlists.
6#[derive(Deserialize, Debug)]
7#[serde(rename_all = "camelCase")]
8pub struct ApplicationData {
9    /// Is AirPlay currently enabled?
10    pub airplay_enabled: Option<bool>,
11
12    /// Is a track currently being converted?
13    pub converting: Option<bool>,
14
15    /// The currently selected AirPlay device(s)
16    pub current_airplay_devices: Vec<AirplayDevice>,
17
18    /// The currently selected encoder (MP3, AIFF, WAV, etc.)
19    pub current_encoder: Encoder,
20
21    /// The playlist containing the currently targeted track
22    pub current_playlist: Option<Playlist>,
23
24    /// The name of the current track in the playing stream (provided by streaming server)
25    pub current_stream_title: Option<String>,
26
27    /// The URL of the playing stream or streaming web site (provided by streaming server)
28    pub current_stream_url: Option<String>,
29
30    /// The currently selected visual plug-in
31    pub current_visual: Visual,
32
33    /// Is the equalizer enabled?
34    pub eq_enabled: bool,
35
36    /// True if all AppleScript track indices should be independent of the play order of the owning playlist.
37    pub fixed_indexing: bool,
38
39    /// Is this the active application?
40    pub frontmost: bool,
41
42    /// Is the application using the entire screen?
43    pub full_screen: bool,
44
45    /// The name of the application
46    pub name: Option<String>,
47
48    /// Has the sound output been muted?
49    pub mute: bool,
50
51    /// : the player’s position within the currently playing track in seconds.
52    pub player_position: Option<f64>,
53
54    /// Is the player stopped, paused, or playing?
55    pub player_state: Option<PlayerState>,
56
57    /// List of all user playlists
58    pub playlists: Option<Vec<Playlist>>,
59
60    /// Track selected on the app by the user
61    pub selection: Option<Vec<Track>>,
62
63    /// Are songs played in random order?
64    pub shuffle_enabled: bool,
65
66    /// The playback shuffle mode
67    pub shuffle_mode: ShuffleMode,
68
69    /// The playback repeat mode
70    pub song_repeat: SongRepeat,
71
72    /// The sound output volume (0 = minimum, 100 = maximum)
73    pub sound_volume: i8,
74
75    /// The version of the application
76    pub version: Option<String>,
77
78    /// List of visuals
79    pub visuals: Vec<Visual>,
80
81    /// Are visuals currently being displayed?
82    pub visuals_enabled: bool,
83}
84
85/// Information about devices connected via AirPlay.
86#[derive(Deserialize, Debug)]
87#[serde(rename_all = "camelCase")]
88pub struct AirplayDevice {
89    /// The class of the item
90    pub class: String,
91
92    /// The id of the item
93    pub id: i32,
94
95    /// The index of the item in internal application order
96    pub index: i32,
97
98    /// The name of the item
99    pub name: String,
100
101    /// The id of the item as a hexadecimal string. This id does not change over time.
102    #[serde(rename = "persistentID")]
103    pub persistent_id: String,
104
105    /// Is the device currently being played to?
106    pub active: Option<bool>,
107
108    /// Is the device currently available?
109    pub available: Option<bool>,
110
111    /// The kind of the device
112    pub kind: AirplayDeviceKind,
113
114    /// The network (MAC) address of the device
115    pub network_address: Option<String>,
116
117    /// Is the device password- or passcode-protected?
118    pub protected: Option<bool>,
119
120    /// Is the device currently selected?
121    pub selected: bool,
122
123    /// Does the device support audio playback?
124    pub supports_audio: Option<bool>,
125
126    /// Does the device support video playback?
127    pub supports_video: Option<bool>,
128
129    /// The output volume for the device (0 = minimum, 100 = maximum)
130    pub sound_volume: i8,
131}
132
133/// Information about a given Encoder.
134#[derive(Deserialize, Debug)]
135pub struct Encoder {
136    /// The class of the item
137    pub class: String,
138
139    /// The id of the item
140    pub id: i32,
141
142    /// The index of the item in internal application order
143    pub index: i32,
144
145    /// The name of the item
146    pub name: String,
147
148    /// The data format created by the encoder
149    pub format: Option<String>,
150}
151
152/// Information about a given Equalizer Preset.
153#[derive(Deserialize, Debug)]
154pub struct EqPreset {
155    /// The class of the item
156    pub class: String,
157
158    /// The id of the item
159    pub id: i32,
160
161    /// The index of the item in internal application order
162    pub index: i32,
163
164    /// The name of the item
165    pub name: String,
166
167    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
168    pub band1: f32,
169
170    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
171    pub band2: f32,
172
173    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
174    pub band3: f32,
175
176    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
177    pub band4: f32,
178
179    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
180    pub band5: f32,
181
182    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
183    pub band6: f32,
184
185    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
186    pub band7: f32,
187
188    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
189    pub band8: f32,
190
191    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
192    pub band9: f32,
193
194    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
195    pub band10: f32,
196
197    /// Can this preset be modified?
198    pub modifiable: Option<bool>,
199
200    /// The equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
201    pub preamp: f32,
202
203    /// Should tracks which refer to this preset be updated when the preset is renamed or deleted?
204    pub update_tracks: bool,
205}
206
207/// Information about a given Visual.
208#[derive(Deserialize, Debug)]
209pub struct Visual {
210    /// The class of the item
211    pub class: String,
212
213    /// The id of the item
214    pub id: i32,
215
216    /// The index of the item in internal application order
217    pub index: i32,
218
219    /// The name of the item
220    pub name: String,
221}
222
223/// Current State of Player.
224#[derive(Deserialize, Debug)]
225#[serde(rename_all = "lowercase")]
226pub enum PlayerState {
227    Stopped,
228    Playing,
229    Paused,
230    FastForwarding,
231    Rewinding,
232}
233
234/// Type of Shuffle (Songs, Albums, Groupings).
235#[derive(Deserialize, Debug)]
236#[serde(rename_all = "lowercase")]
237pub enum ShuffleMode {
238    Songs,
239    Albums,
240    Groupings,
241}
242
243/// Type of Song Repeat (Off, One, All).
244#[derive(Deserialize, Debug)]
245#[serde(rename_all = "lowercase")]
246pub enum SongRepeat {
247    Off,
248    One,
249    All,
250}
251
252/// Type of Airplay Device (AppleTV, Bluetooth, Computer ...).
253#[derive(Deserialize, Debug)]
254#[serde(rename_all = "lowercase")]
255pub enum AirplayDeviceKind {
256    Computer,
257    AirportExpress,
258    AppleTV,
259    #[serde(rename = "Airplay device")]
260    AirplayDevice,
261    #[serde(rename = "Bluetooth device")]
262    BluetoothDevice,
263    HomePod,
264    Unknown,
265}