Playing music
First, add the mp3
module:
mod mp3;
Copy the src/mp3.rs
file from the previous chapter.
We also need the following dependencies:
[dependencies] crossbeam = "^0.3.0" futures = "^0.1.16" pulse-simple = "^1.0.0" simplemad = "^0.8.1"
And add these statements to the main
module:
extern crate crossbeam; extern crate futures; extern crate pulse_simple; extern crate simplemad;
We'll now add a player
module:
mod player;
This new module will start with a bunch of import statements:
use std::cell::Cell; use std::fs::File; use std::io::BufReader; use std::path::{Path, PathBuf}; use std::sync::{Arc, Condvar, Mutex}; use std::thread; use std::time::Duration; use crossbeam::sync::SegQueue; use futures::{AsyncSink, Sink}; use futures::sync::mpsc::UnboundedSender; use pulse_simple::Playback; use mp3::Mp3Decoder; use playlist::PlayerMsg::{ self, PlayerPlay, PlayerStop, PlayerTime, }; use self::Action::*;
We imported a new PlayerMsg
type from the playlist
module, so let's add it:
#[derive...