pub struct Playerctl;Expand description
§Playerctl
Playerctl wrapper struct allowing to send commands and control the player.
§Examples
§Stop the current player
Playerctl::stop().unwrap();§Advance and rewind 10 seconds
Playerctl::position(10.).unwrap();
Playerctl::position(-10.).unwrap();§Get metadata
let metadata = Playerctl::metadata().unwrap();
println!("Track title: {}", metadata.title);Implementations§
Source§impl Playerctl
impl Playerctl
Sourcepub fn play() -> Result<()>
pub fn play() -> Result<()>
Command the player to play.
Playerctl::play().unwrap();Examples found in repository?
examples/basic.rs (line 5)
3fn main() {
4 // Command the player to play
5 Playerctl::play().unwrap_or_default();
6
7 // Command the player to pause
8 Playerctl::pause().unwrap_or_default();
9
10 // Command the player to toggle between play/pause
11 Playerctl::play_pause().unwrap_or_default();
12
13 // Command the player to seek forward/backward OFFSET in seconds
14 Playerctl::position(10.).unwrap_or_default();
15
16 // Get metadata information for the current track
17 let metadata = Playerctl::metadata().unwrap_or_default();
18
19 println!(
20 "Title: {}\nAlbum: {}\nArtist: {}\nURL: {}\nLength: {}",
21 metadata.title, metadata.album, metadata.artist, metadata.url, metadata.length
22 )
23}Sourcepub fn pause() -> Result<()>
pub fn pause() -> Result<()>
Command the player to pause.
Playerctl::pause().unwrap();Examples found in repository?
examples/basic.rs (line 8)
3fn main() {
4 // Command the player to play
5 Playerctl::play().unwrap_or_default();
6
7 // Command the player to pause
8 Playerctl::pause().unwrap_or_default();
9
10 // Command the player to toggle between play/pause
11 Playerctl::play_pause().unwrap_or_default();
12
13 // Command the player to seek forward/backward OFFSET in seconds
14 Playerctl::position(10.).unwrap_or_default();
15
16 // Get metadata information for the current track
17 let metadata = Playerctl::metadata().unwrap_or_default();
18
19 println!(
20 "Title: {}\nAlbum: {}\nArtist: {}\nURL: {}\nLength: {}",
21 metadata.title, metadata.album, metadata.artist, metadata.url, metadata.length
22 )
23}Sourcepub fn play_pause() -> Result<()>
pub fn play_pause() -> Result<()>
Command the player to toggle between play/pause.
Playerctl::play_pause().unwrap();Examples found in repository?
examples/basic.rs (line 11)
3fn main() {
4 // Command the player to play
5 Playerctl::play().unwrap_or_default();
6
7 // Command the player to pause
8 Playerctl::pause().unwrap_or_default();
9
10 // Command the player to toggle between play/pause
11 Playerctl::play_pause().unwrap_or_default();
12
13 // Command the player to seek forward/backward OFFSET in seconds
14 Playerctl::position(10.).unwrap_or_default();
15
16 // Get metadata information for the current track
17 let metadata = Playerctl::metadata().unwrap_or_default();
18
19 println!(
20 "Title: {}\nAlbum: {}\nArtist: {}\nURL: {}\nLength: {}",
21 metadata.title, metadata.album, metadata.artist, metadata.url, metadata.length
22 )
23}Sourcepub fn next() -> Result<()>
pub fn next() -> Result<()>
Command the player to skip to the next track.
Playerctl::next().unwrap();Sourcepub fn previous() -> Result<()>
pub fn previous() -> Result<()>
Command the player to skip to the previous track.
Playerctl::previous().unwrap();Sourcepub fn position(secs: f32) -> Result<()>
pub fn position(secs: f32) -> Result<()>
Command the player to seek forward/backward OFFSET in seconds.
Playerctl::position(10.).unwrap();Examples found in repository?
examples/basic.rs (line 14)
3fn main() {
4 // Command the player to play
5 Playerctl::play().unwrap_or_default();
6
7 // Command the player to pause
8 Playerctl::pause().unwrap_or_default();
9
10 // Command the player to toggle between play/pause
11 Playerctl::play_pause().unwrap_or_default();
12
13 // Command the player to seek forward/backward OFFSET in seconds
14 Playerctl::position(10.).unwrap_or_default();
15
16 // Get metadata information for the current track
17 let metadata = Playerctl::metadata().unwrap_or_default();
18
19 println!(
20 "Title: {}\nAlbum: {}\nArtist: {}\nURL: {}\nLength: {}",
21 metadata.title, metadata.album, metadata.artist, metadata.url, metadata.length
22 )
23}Sourcepub fn volume(percent: f32) -> Result<()>
pub fn volume(percent: f32) -> Result<()>
Set the volume to LEVEL from 0.0 to 1.0.
Playerctl::volume(10.).unwrap();Sourcepub fn status() -> Result<TrackStatus>
pub fn status() -> Result<TrackStatus>
Get the play status of the player.
Playerctl::status(10.).unwrap();Sourcepub fn metadata() -> Result<TrackMetadata>
pub fn metadata() -> Result<TrackMetadata>
Get metadata information for the current track.
let metadata = Playerctl::metadata().unwrap();
println!("Title: {}", metadata.title);Examples found in repository?
examples/basic.rs (line 17)
3fn main() {
4 // Command the player to play
5 Playerctl::play().unwrap_or_default();
6
7 // Command the player to pause
8 Playerctl::pause().unwrap_or_default();
9
10 // Command the player to toggle between play/pause
11 Playerctl::play_pause().unwrap_or_default();
12
13 // Command the player to seek forward/backward OFFSET in seconds
14 Playerctl::position(10.).unwrap_or_default();
15
16 // Get metadata information for the current track
17 let metadata = Playerctl::metadata().unwrap_or_default();
18
19 println!(
20 "Title: {}\nAlbum: {}\nArtist: {}\nURL: {}\nLength: {}",
21 metadata.title, metadata.album, metadata.artist, metadata.url, metadata.length
22 )
23}Auto Trait Implementations§
impl Freeze for Playerctl
impl RefUnwindSafe for Playerctl
impl Send for Playerctl
impl Sync for Playerctl
impl Unpin for Playerctl
impl UnsafeUnpin for Playerctl
impl UnwindSafe for Playerctl
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