Move PlayerEvent into player.

This commit is contained in:
Simon Persson 2018-02-20 21:57:42 +01:00
parent b0ee03112f
commit 1b943d069f
3 changed files with 20 additions and 18 deletions

View file

@ -1,6 +1,7 @@
use std::str::FromStr; use std::str::FromStr;
use core::spotify_id::SpotifyId; use core::spotify_id::SpotifyId;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use player::PlayerEvent;
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum Bitrate { pub enum Bitrate {
@ -27,22 +28,6 @@ impl Default for Bitrate {
} }
} }
#[derive(Debug, Clone)]
pub enum PlayerEvent {
Started {
track_id: SpotifyId,
},
Changed {
old_track_id: SpotifyId,
new_track_id: SpotifyId,
},
Stopped {
track_id: SpotifyId,
}
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct PlayerConfig { pub struct PlayerConfig {
pub bitrate: Bitrate, pub bitrate: Bitrate,

View file

@ -8,7 +8,7 @@ use std::sync::mpsc::{RecvError, TryRecvError, RecvTimeoutError};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use config::{Bitrate, PlayerConfig, PlayerEvent}; use config::{Bitrate, PlayerConfig};
use core::session::Session; use core::session::Session;
use core::spotify_id::SpotifyId; use core::spotify_id::SpotifyId;
@ -42,6 +42,23 @@ enum PlayerCommand {
Seek(u32), Seek(u32),
} }
#[derive(Debug, Clone)]
pub enum PlayerEvent {
Started {
track_id: SpotifyId,
},
Changed {
old_track_id: SpotifyId,
new_track_id: SpotifyId,
},
Stopped {
track_id: SpotifyId,
}
}
impl Player { impl Player {
pub fn new<F>(config: PlayerConfig, session: Session, pub fn new<F>(config: PlayerConfig, session: Session,
audio_filter: Option<Box<AudioFilter + Send>>, audio_filter: Option<Box<AudioFilter + Send>>,

View file

@ -1,7 +1,7 @@
use std::process::Command; use std::process::Command;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread; use std::thread;
use librespot::playback::config::PlayerEvent; use librespot::playback::player::PlayerEvent;
fn run_program(program: &str, args: Vec<String>) { fn run_program(program: &str, args: Vec<String>) {
info!("Running {}", program); info!("Running {}", program);