Add docs for media inputs

v5-api
Dominik Nakamura 2 years ago
parent 6e1e3a902d
commit 4090bde8a5
No known key found for this signature in database
GPG Key ID: E4C6A749B2491910

@ -9,12 +9,21 @@ pub struct MediaInputs<'a> {
}
impl<'a> MediaInputs<'a> {
/// Gets the status of a media input.
///
/// - `input_name`: Name of the media input.
pub async fn get_media_input_status(&self, input_name: &str) -> Result<responses::MediaStatus> {
self.client
.send_message(RequestType::GetMediaInputStatus { input_name })
.await
}
/// Sets the cursor position of a media input.
///
/// This request does not perform bounds checking of the cursor position.
///
/// - `input_name`: Name of the media input.
/// - `media_cursor`: New cursor position to set.
pub async fn set_media_input_cursor(
&self,
input_name: &str,
@ -28,6 +37,12 @@ impl<'a> MediaInputs<'a> {
.await
}
/// Offsets the current cursor position of a media input by the specified value.
///
/// This request does not perform bounds checking of the cursor position.
///
/// - `input_name`: Name of the media input.
/// - `media_cursor_offset`: Value to offset the current cursor position by.
pub async fn offset_media_input_cursor(
&self,
input_name: &str,
@ -41,6 +56,10 @@ impl<'a> MediaInputs<'a> {
.await
}
/// Triggers an action on a media input.
///
/// - `input_name`: Name of the media input.
/// - `media_action`: Identifier of the media action.
pub async fn trigger_media_input_action(
&self,
input_name: &str,

@ -420,23 +420,30 @@ pub(crate) enum RequestType<'a> {
// --------------------------------
#[serde(rename_all = "camelCase")]
GetMediaInputStatus {
/// Name of the media input.
input_name: &'a str,
},
#[serde(rename_all = "camelCase")]
SetMediaInputCursor {
/// Name of the media input.
input_name: &'a str,
/// New cursor position to set.
#[serde(serialize_with = "ser::duration_millis")]
media_cursor: Duration,
},
#[serde(rename_all = "camelCase")]
OffsetMediaInputCursor {
/// Name of the media input.
input_name: &'a str,
/// Value to offset the current cursor position by.
#[serde(serialize_with = "ser::duration_millis")]
media_cursor_offset: Duration,
},
#[serde(rename_all = "camelCase")]
TriggerMediaInputAction {
/// Name of the media input.
input_name: &'a str,
/// Identifier of the media action.
media_action: MediaAction,
},
// --------------------------------

@ -426,9 +426,12 @@ pub struct InputVolume {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MediaStatus {
/// State of the media input.
pub media_state: MediaState,
/// Total duration of the playing media. [`None`] if not playing.
#[serde(deserialize_with = "crate::de::duration_millis_opt")]
pub media_duration: Option<Duration>,
/// Position of the cursor. [`None`] if not playing.
#[serde(deserialize_with = "crate::de::duration_millis_opt")]
pub media_cursor: Option<Duration>,
}

Loading…
Cancel
Save