Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue load #26

Merged
merged 8 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions src/cast/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub mod media {
pub media_session_id: Option<i32>,
}

// Really LoadRequest
/// https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.LoadRequest
#[derive(Serialize, Debug)]
pub struct MediaRequest {
#[serde(rename = "requestId")]
Expand All @@ -58,6 +60,81 @@ pub mod media {
pub custom_data: CustomData,

pub autoplay: bool,

#[serde(rename = "queueData", skip_serializing_if = "Option::is_none")]
pub queue_data: Option<QueueData>,
}

/// https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.QueueItem
#[derive(Serialize, Debug)]
pub struct QueueItem {
#[serde(rename = "activeTrackIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub active_track_ids: Option<Vec<u16>>,

pub autoplay: bool,

#[serde(rename = "customData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_data: Option<CustomData>,

#[serde(rename = "itemId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub item_id: Option<u16>,

pub media: Media,

#[serde(rename = "playbackDuration")]
pub playback_duration: Option<f64>,

#[serde(rename = "preloadTime")]
pub preload_time: f64,

#[serde(rename = "startTime")]
pub start_time: f64,
}

/// https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.QueueLoadRequest
#[derive(Serialize, Debug)]
pub struct QueueLoadRequest {
#[serde(rename = "type")]
pub typ: String,

#[serde(rename = "requestId")]
pub request_id: u32,

#[serde(rename = "customData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_data: Option<CustomData>,

pub items: Vec<QueueItem>,

// This is from https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.QueueData
#[serde(rename = "queueType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub queue_type: Option<String>,

#[serde(rename = "repeatMode")]
pub repeat_mode: String,

#[serde(rename = "startIndex")]
pub start_index: u16,
}

/// https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.QueueData
#[derive(Serialize, Debug)]
pub struct QueueData {
pub items: Vec<QueueItem>,

#[serde(rename = "queueType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub queue_type: Option<String>,

#[serde(rename = "repeatMode")]
pub repeat_mode: String,

#[serde(rename = "startIndex")]
pub start_index: u16,
}

#[derive(Serialize, Debug)]
Expand Down Expand Up @@ -225,6 +302,15 @@ pub mod media {
}
}

#[derive(Deserialize, Debug)]
pub struct ExtendedStatus {
#[serde(rename = "playerState")]
pub player_state: String,
#[serde(rename = "mediaSessionId")]
pub media_session_id: Option<i32>,
pub media: Option<Media>,
}

#[derive(Deserialize, Debug)]
pub struct Status {
#[serde(rename = "mediaSessionId")]
Expand All @@ -235,8 +321,16 @@ pub mod media {
pub playback_rate: f32,
#[serde(rename = "playerState")]
pub player_state: String,
#[serde(rename = "currentItemId")]
pub current_item_id: Option<u16>,
#[serde(rename = "loadingItemId")]
pub loading_item_id: Option<u16>,
#[serde(rename = "preloadedItemId")]
pub preloaded_item_id: Option<u16>,
#[serde(rename = "idleReason")]
pub idle_reason: Option<String>,
#[serde(rename = "extendedStatus")]
pub extended_status: Option<ExtendedStatus>,
#[serde(rename = "currentTime")]
pub current_time: Option<f32>,
#[serde(rename = "supportedMediaCommands")]
Expand Down
Loading
Loading