pub struct Client { /* private fields */ }
Expand description
A connection to a VLC player’s TCP interface.
Implementations§
Source§impl Client
impl Client
Sourcepub fn connect<A>(addr: A) -> Result<Client>where
A: ToSocketAddrs,
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();
Sourcepub fn playlist(&mut self) -> Result<Playlist>
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);
}
Sourcepub fn subtitles(&mut self) -> Result<Subtitles>
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);
}
Sourcepub fn get_volume(&mut self) -> Result<u8>
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);
Sourcepub fn set_volume(&mut self, amt: u8) -> Result<()>
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);
Sourcepub fn is_playing(&mut self) -> Result<bool>
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!");
}
Sourcepub fn play(&mut self) -> Result<()>
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);
Sourcepub fn stop(&mut self) -> Result<()>
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);
Sourcepub fn pause(&mut self) -> Result<()>
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();
Sourcepub fn get_time(&mut self) -> Result<Option<u32>>
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();
Sourcepub fn forward(&mut self, secs: u32) -> Result<()>
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();
Sourcepub fn rewind(&mut self, secs: u32) -> Result<()>
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();
Sourcepub fn get_title(&mut self) -> Result<Option<String>>
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);
}
Sourcepub fn next(&mut self) -> Result<()>
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();
Sourcepub fn prev(&mut self) -> Result<()>
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();
Sourcepub fn fullscreen(&mut self, on: bool) -> Result<()>
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!");