pub fn new<T, R>(decoder: Decoder<R>) -> Self
    where
        T: cpal::Sample,
        R: Read + Seek + Send + 'static,
    {
        let (tx, rx) = unbounded();

        std::thread::spawn(move || {
            let stream = create_stream::<T, R>(decoder);

            stream.pause().expect("Pause error");

            println!("Wait for reception");
            while let Ok(res) = rx.recv() {
                println!("{:?}", res);
                match res {
                    Controls::Pause => {
                        stream.pause().expect("Pause error");
                    }
                    Controls::Play => {
                        stream.play().expect("Play error");
                    }
                    Controls::Stop => {
                        stream.pause().expect("Stop error");
                        drop(stream);
                        break;
                    }
                }
            }
        });

        Self { tx_stream: tx }
    }
/// Returns a new thread containing a stream.
Returns a new thread containing a stream.
Returns a new thread containing a stream .
pub fn new<T, R>(decoder: Decoder<R>) -> Self
    where
        T: cpal::Sample,
        R: Read + Seek + Send + 'static,
    {
        let (tx, rx) = unbounded();
        std::thread::spawn(move || {
            let stream = create_stream::<T, R>(decoder);
            stream.pause().expect("Pause error");
            println!("Wait for reception");
            while let Ok(res) = rx.recv() {
                println!("{:?}", res);
                match res {
                    Controls::Pause => {
                        stream.pause().expect("Pause error");
                    }
                    Controls::Play => {
                        stream.play().expect("Play error");
                    }
                    Controls::Stop => {
                        stream.pause().expect("Stop error");
                        drop(stream);
                        break;
                    }
                }
            }
        });
        Self { tx_stream: tx }
    }
pub fn new < T , R > ( decoder : Decoder < R > ) -> Self where T : cpal :: Sample , R : Read + Seek + Send + ' static , { let ( tx , rx ) = unbounded ( ) ; std :: thread :: spawn ( move | | { let stream = create_stream :: < T , R > ( decoder ) ; stream . pause ( ) . expect ( " " ) ; println ! ( " " ) ; while let Ok ( res ) = rx . recv ( ) { println ! ( " " res ) ; match res { Controls :: Pause => { stream . pause ( ) . expect ( " " ) ; } Controls :: Play => { stream . play ( ) . expect ( " " ) ; } Controls :: Stop => { stream . pause ( ) . expect ( " " ) ; drop ( stream ) ; break ; } } } } ) ; Self { tx_stream : tx } }
Returns a new thread containing a stream.
Returns a new thread containing a stream .
decoder
Decoder<R>
decoder
Decoder<R>