Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

A connection to a VLC player’s TCP interface.

Implementations§

Source§

impl Client

Source

pub fn connect<A>(addr: A) -> Result<Client>
where A: ToSocketAddrs,

Establishes a connection to a VLC player’s TCP interface at the given address.

§Examples
use vlc_rc::Client;

let player = Client::connect("127.0.0.1:9090").unwrap();
Source

pub fn playlist(&mut self) -> Result<Playlist>

Gets a list of tracks in the VLC player’s playlist.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

let playlist = player.playlist().unwrap();
for track in playlist {
    println!("{}", track);
}
Source

pub fn subtitles(&mut self) -> Result<Subtitles>

Gets a list of subtitle tracks for the current media file.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

let subtitles = player.subtitles().unwrap();
for strack in subtitles {
    println!("{}", strack);
}
Source

pub fn get_volume(&mut self) -> Result<u8>

Gets the VLC player’s current volume.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

let volume = player.get_volume().unwrap();
println!("the current volume is {}", volume);
Source

pub fn set_volume(&mut self, amt: u8) -> Result<()>

Sets the VLC player’s volume to the given amount.

If amt is greater than MAX_VOLUME, it defaults to the max volume.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.set_volume(50).unwrap();
assert_eq!(player.get_volume().unwrap(), 50);
Source

pub fn is_playing(&mut self) -> Result<bool>

Returns whether or not the current media track is playing.

Note that if the track is paused, the method still returns true.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

let is_playing = player.is_playing().unwrap();
if is_playing {
    println!("the track is currently playing!");
} else {
    println!("the track is currently stopped!");
}
Source

pub fn play(&mut self) -> Result<()>

Plays the current media track.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.play().unwrap();
assert_eq!(player.is_playing().unwrap(), true);
Source

pub fn stop(&mut self) -> Result<()>

Stops the current media track’s playback.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.stop().unwrap();
assert_eq!(player.is_playing().unwrap(), false);
Source

pub fn pause(&mut self) -> Result<()>

Pauses the current track’s playback.

Does nothing if the track is stopped.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.pause().unwrap();
Source

pub fn get_time(&mut self) -> Result<Option<u32>>

Gets the elapsed time since the track’s beginning (in seconds).

Returns None if the current track is stopped.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

let seconds = player.get_time().unwrap();
Source

pub fn forward(&mut self, secs: u32) -> Result<()>

Moves the track’s playback forward by the given amount (in seconds).

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.forward(5).unwrap();
Source

pub fn rewind(&mut self, secs: u32) -> Result<()>

Moves the track’s playback backward by the given amount (in seconds).

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.rewind(5).unwrap();
Source

pub fn get_title(&mut self) -> Result<Option<String>>

Gets the current media track’s title.

Returns None if the media player is stopped.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

let current_track = player.get_title().unwrap();
if let Some(title) = current_track {
    println!("the track '{}' is currently playing!", title);
}
Source

pub fn next(&mut self) -> Result<()>

Plays the next track in the playlist.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.next().unwrap();
Source

pub fn prev(&mut self) -> Result<()>

Plays the previous track in the playlist.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.prev().unwrap();
Source

pub fn fullscreen(&mut self, on: bool) -> Result<()>

Toggles the media player’s fullscreen mode on/off.

§Examples
use vlc_rc::Client;

let mut player = Client::connect("127.0.0.1:9090").unwrap();

player.fullscreen(true).unwrap();
println!("fullscreen is on!");

player.fullscreen(false).unwrap();
println!("fullscreen is off!");

Trait Implementations§

Source§

impl Drop for Client

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.