get_current_song implémenté testé
This commit is contained in:
parent
fdceee8e54
commit
123f41930d
@ -35,7 +35,7 @@ pub mod audioplayer {
|
||||
//-----------------------------------------Structs
|
||||
pub struct AudioPlayer {
|
||||
///A facility for controlling the playing of sound.
|
||||
pub sink: Sink,
|
||||
sink: Sink,
|
||||
///A handle to the sound device. Must live as long as the sink.
|
||||
stream: OutputStream,
|
||||
///List of songs to pick from.
|
||||
@ -93,63 +93,70 @@ pub mod audioplayer {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fn get_current_song(&self) {
|
||||
///Returns a copy of the current song and its index in the playlist
|
||||
///Or None if the playlist's empty
|
||||
pub fn get_current_song(&self) -> Option<(SongMeta, usize)> {
|
||||
if self.playlist.songs.len() == 0 {
|
||||
return None;
|
||||
}
|
||||
let index: usize = self.playlist.songs.len() - self.sink.len();
|
||||
let songcopy = self.playlist.songs[index].clone();
|
||||
return Some((songcopy, index));
|
||||
}
|
||||
|
||||
pub fn skip_forward(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn skip_forward(&mut self) {
|
||||
pub fn skip_backwards(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn skip_backwards(&mut self) {
|
||||
pub fn pause(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn pause(&mut self) {
|
||||
pub fn unpause(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn unpause(&mut self) {
|
||||
pub fn get_pos(&self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn get_pos(&self) {
|
||||
pub fn set_vol(&mut self, vol: f32) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn set_vol(&mut self, vol: f32) {
|
||||
pub fn get_vol(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn get_vol(&mut self) {
|
||||
pub fn goto(&mut self, index: usize) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn goto(&mut self, index: usize) {
|
||||
pub fn press_shuffle(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn press_shuffle(&mut self) {
|
||||
pub fn press_repeat(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn press_repeat(&mut self) {
|
||||
pub fn seek(&mut self, goto: Duration) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn seek(&mut self, goto: Duration) {
|
||||
pub fn stop(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn stop(&mut self) {
|
||||
pub fn load_file(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn load_file(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn load_folder(&mut self) {
|
||||
pub fn load_folder(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
11
src/main.rs
11
src/main.rs
@ -23,15 +23,8 @@ fn main() {
|
||||
let mut player = AudioPlayer::new().unwrap();
|
||||
|
||||
|
||||
player.playlist = playlist;
|
||||
|
||||
player.play_at(0).unwrap();
|
||||
println!("{:?} {:?} {:?}", player.state, player.sink.volume(), player.sink.is_paused());
|
||||
sleep(Duration::from_secs(10));
|
||||
player.play_at(2).unwrap();
|
||||
loop {
|
||||
dbg!(player.sink.get_pos());
|
||||
}
|
||||
player.playlist = Playlist::new();
|
||||
dbg!(player.get_current_song());
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user