Audio Pause issue

i have read the docs about playing sounds and audio and it work good
but i want to be able to play/pause the sound like toggle click
when first click performed the sound should be played
when click another one it could pause
and so on

here is my code for doing this but its work just for play

   playSound = async () => {
        const source = {
            uri: 'http://217.66.226.47:8046/;stream.mp3'
          };
          const sound = new Audio.Sound();
          await Audio.setIsEnabledAsync(true);
          await sound.loadAsync(source);
        if (this.state.playing === true) {
            try {
                await sound.pauseAsync();
                this.setState({ playing: false });
              } catch (error) {
                console.error(error);
              }
        } else {
            try {
                await sound.playAsync(); 
                this.setState({ playing: true });
              } catch (error) {
                console.error(error);
              }
        }
      };

which sdk version are you using? (see in app.json)

cc @sjchmiela

“sdkVersion”: “23.0.0”

please update to sdk25 to see if it resolves your issue

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.