zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 748 forks source link

iOS getDuration always returns -1 #733

Closed amirito closed 2 years ago

amirito commented 3 years ago

:beetle: Description

getDuration() and getNumberOfChannels() methods always return -1 in iOS it works well in Android

:beetle: What have you tried?

I tried .aac and .mp3 formats in both iOS emulator and physical iOS device

:beetle: Please post your code:

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

amirito commented 3 years ago

Thank you I found the solution here you should just leave the second parameter to be null

import Sound from 'react-native-sound';

const sound = new Sound('http://sounds.com/some-sound', null, (error) => {
  if (error) {
    // do something
  }

  // play when loaded
  sound.play();
});