react-native-use-sound icon indicating copy to clipboard operation
react-native-use-sound copied to clipboard

Hook not working on iOS

Open pierroo opened this issue 3 years ago • 4 comments

Is there any known issue on iOS ?

I am using the code below:

export const AudioChat = ({ src }) => {
  const [play, pause, stop, data] = useSound(src);
  const handlePlay = () => {
    if (data.isPlaying) pause()
    else play()
  }

  return (
    <TouchableOpacity onPress={handlePlay}>
        {data.isPlaying ?
          <Icon size={24} name="pause"  />
          :
          <Icon size={24} name="play-outline" />
        }
    </TouchableOpacity>
  )
}

Which works perfectly on Android, however on iOS when pressing it toggles to "isPlaying" icon, but no sound can be heard, and it never turns back to !isPlaying

I'm using a remote source, again it works fine on android and the remote source is correct. ( latest version of this plugin and react-native )

pierroo avatar Dec 27 '21 12:12 pierroo

By any chance if you happen to pass by here, can you let me know @remigallego if this hook is also meant to work on iOS?

pierroo avatar Jan 04 '22 13:01 pierroo

@pierroo Thanks for the feedback. The library should work with iOS out of the box. Can you let me know which iOS version you're using?

remigallego avatar Jan 04 '22 13:01 remigallego

Hi @remigallego thanks for passing by! I am using iOS 15.1; I am using your hook exactly as it is mentioned in your docs; and again it works fine on Android so I really don't understand why nothing happens (beside the state toggle of icon)

Additional info:

When doing a console.log(sound) in the "play" function I get the following:

{"_duration": -1, "_filename": "source_fake", "_key": 33, "_loaded": false, "_numberOfChannels": -1, "_numberOfLoops": 0, "_pan": 0, "_pitch": 1, "_playing": false, "_speed": 1, "_volume": 1, "registerOnPlay": [Function anonymous]}

I believe the "duration: -1" might be the issue? Is there anything else that could help with this?

Random thought: could iOS require any specific permission to play remote sound? from their info.plist or whatever?

pierroo avatar Jan 04 '22 14:01 pierroo

In case you wondered, I am still facing the issue and unable to find a fix. Would you mind sharing your react-native-sound version with which it works? Might be the latest release that breaks it?

pierroo avatar Feb 04 '22 16:02 pierroo