|
|
@ -30,33 +30,24 @@ use gd::gd_path;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Guider {
|
|
|
|
struct Guider {
|
|
|
|
sink: Sink,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
enum Message {
|
|
|
|
enum Message {
|
|
|
|
Play,
|
|
|
|
Msg,
|
|
|
|
Pause,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Sandbox for Guider {
|
|
|
|
impl Sandbox for Guider {
|
|
|
|
type Message = Message;
|
|
|
|
type Message = Message;
|
|
|
|
fn new() -> Self {
|
|
|
|
fn new() -> Self {
|
|
|
|
let gd_path = gd_path();
|
|
|
|
Self {}
|
|
|
|
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
|
|
|
|
|
|
|
let sink = Sink::try_new(&stream_handle).unwrap();
|
|
|
|
|
|
|
|
let music_file = BufReader::new(File::open(gd_path.join("613929.mp3")).unwrap());
|
|
|
|
|
|
|
|
let source = Decoder::new(music_file).unwrap();
|
|
|
|
|
|
|
|
//sink.append(source);
|
|
|
|
|
|
|
|
//sink.pause();
|
|
|
|
|
|
|
|
Self {sink}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn view(&self) -> Element<Message> {
|
|
|
|
fn view(&self) -> Element<Message> {
|
|
|
|
// column![button("pause").on_press(Message::Pause), button("play").on_press(Message::Play)].into()
|
|
|
|
// column![button("pause").on_press(Message::Pause), button("play").on_press(Message::Play)].into()
|
|
|
|
row![
|
|
|
|
row![
|
|
|
|
scrollable(["lvl 1", "lvl 2", "lvl 3"].iter().fold(
|
|
|
|
scrollable(["lvl 1", "lvl 2", "lvl 3"].iter().fold(
|
|
|
|
Column::new(), |col, item| col.push(button(*item).on_press(Message::Pause))
|
|
|
|
Column::new(), |col, item| col.push(button(*item).on_press(Message::Msg))
|
|
|
|
)),
|
|
|
|
)),
|
|
|
|
column![
|
|
|
|
column![
|
|
|
|
row![
|
|
|
|
row![
|
|
|
@ -75,8 +66,7 @@ impl Sandbox for Guider {
|
|
|
|
|
|
|
|
|
|
|
|
fn update(&mut self, message: Message) {
|
|
|
|
fn update(&mut self, message: Message) {
|
|
|
|
match message {
|
|
|
|
match message {
|
|
|
|
Message::Pause => self.sink.pause(),
|
|
|
|
Message::Msg => {println!("Message received!")}
|
|
|
|
Message::Play => self.sink.play(),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|