pub struct PlayerInfo {
pub player_name: String,
pub current_track: Option<Track>,
pub playback_state: PlaybackState,
pub position: Option<Duration>,
pub volume: Option<f64>,
}Expand description
Complete information about a media player’s current state.
This structure contains comprehensive information about a media player’s current state, including the currently playing track, playback state, position, and volume.
§Examples
use nowhear::{MediaSource, MediaSourceBuilder, Result};
let source = MediaSourceBuilder::new().build().await?;
let player_info = source.get_player("spotify").await?;
if let Some(track) = player_info.current_track {
println!("Playing: {} by {}", track.title, track.artist.join(", "));
}Fields§
§player_name: StringName or identifier of the player
current_track: Option<Track>Currently playing track, if any
playback_state: PlaybackStateCurrent playback state (playing, paused, or stopped)
position: Option<Duration>Current playback position within the track
volume: Option<f64>Current volume level (0.0 to 1.0)
Implementations§
Source§impl PlayerInfo
impl PlayerInfo
Sourcepub fn empty(player_name: impl Into<String>) -> Self
pub fn empty(player_name: impl Into<String>) -> Self
Creates player info for a player with no active playback.
This is useful when a player is detected but not currently playing any media.
The returned PlayerInfo will have no track, stopped playback state, and
no position or volume information.
§Arguments
player_name- The name of the player
§Examples
use nowhear::{PlayerInfo, PlaybackState};
let info = PlayerInfo::empty("spotify");
assert_eq!(info.player_name, "spotify");
assert_eq!(info.current_track, None);
assert_eq!(info.playback_state, PlaybackState::Stopped);Trait Implementations§
Source§impl Clone for PlayerInfo
impl Clone for PlayerInfo
Source§fn clone(&self) -> PlayerInfo
fn clone(&self) -> PlayerInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PlayerInfo
impl Debug for PlayerInfo
Source§impl PartialEq for PlayerInfo
impl PartialEq for PlayerInfo
impl StructuralPartialEq for PlayerInfo
Auto Trait Implementations§
impl Freeze for PlayerInfo
impl RefUnwindSafe for PlayerInfo
impl Send for PlayerInfo
impl Sync for PlayerInfo
impl Unpin for PlayerInfo
impl UnwindSafe for PlayerInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more