fn play_action(&mut self) {
        if self.path.as_str() != "" {
            self.play = !self.play;

            if self.stop {
                self.stop = false;

                let path = self.path.as_str();
                let file = File::open(path).expect("File not found");
                let decoder = Decoder::new(file).expect("Decoding error");
                let mut player = self.player.as_ref().unwrap().clone();

                player.create_stream(decoder);

                self.player = Some(player);
                self.player.as_ref().unwrap().play_stream();
            } else {
                if self.play {
                    self.player.as_ref().unwrap().play_stream();
                } else {
                    self.player.as_ref().unwrap().pause_stream();
                }
            }
        }
    }
/// Play the audio after clicking on button
Play the audio after clicking on button
Play the audio after clicking on button
fn play_action(&mut self) {
        if self.path.as_str() != "" {
            self.play = !self.play;
            if self.stop {
                self.stop = false;
                let path = self.path.as_str();
                let file = File::open(path).expect("File not found");
                let decoder = Decoder::new(file).expect("Decoding error");
                let mut player = self.player.as_ref().unwrap().clone();
                player.create_stream(decoder);
                self.player = Some(player);
                self.player.as_ref().unwrap().play_stream();
            } else {
                if self.play {
                    self.player.as_ref().unwrap().play_stream();
                } else {
                    self.player.as_ref().unwrap().pause_stream();
                }
            }
        }
    }
fn play_action ( & mut self ) { if self . path . as_str ( ) != " " { self . play = ! self . play ; if self . stop { self . stop = false ; let path = self . path . as_str ( ) ; let file = File :: open ( path ) . expect ( " " ) ; let decoder = Decoder :: new ( file ) . expect ( " " ) ; let mut player = self . player . as_ref ( ) . unwrap ( ) . clone ( ) ; player . create_stream ( decoder ) ; self . player = Some ( player ) ; self . player . as_ref ( ) . unwrap ( ) . play_stream ( ) ; } else { if self . play { self . player . as_ref ( ) . unwrap ( ) . play_stream ( ) ; } else { self . player . as_ref ( ) . unwrap ( ) . pause_stream ( ) ; } } } }
Play the audio after clicking on button
Play the audio after clicking on button
&mut self
&mut self