Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook not working on iOS #4

Open
pierroo opened this issue Dec 27, 2021 · 4 comments
Open

Hook not working on iOS #4

pierroo opened this issue Dec 27, 2021 · 4 comments

Comments

@pierroo
Copy link

pierroo commented Dec 27, 2021

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
Copy link
Author

pierroo commented Jan 4, 2022

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?

@remigallego
Copy link
Owner

@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?

@pierroo
Copy link
Author

pierroo commented Jan 4, 2022

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
Copy link
Author

pierroo commented Feb 4, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants