I have a sound object whose duration I need
this.soundObject = new Audio.Sound();
await this.soundObject.loadAsync(sound);
I've tried this, however the documentation says it only works for recordings.
this.soundObject.durationMillis
Is there something I'm overlooking? I can't seem to find a parameter for the duration.
React Native Sound is a library that allows you to easily play sound effects and music in your React Native apps. It's open-source, easy to use, and works on both iOS and Android.
If you create a bare React Native project through expo-cli by running expo init and choosing a Bare template, your project will have react-native-unimodules installed and configured for you. You can run this project by using react-native run-ios or react-native run-android rather than expo start .
Run your app with expo start --https to enable it. No local file sharing on web: Sharing local files by URI works on iOS and Android, but not on web. You cannot share local files on web by URI — you will need to upload them somewhere and share that URI.
The duration is stored in the status, it needs a promise to access
this.soundObject.getStatusAsync()
.then(function(result) {
console.log(result.durationMillis)
})
.catch(failureCallback);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With