react-native-audio-toolkit
react-native-audio-toolkit copied to clipboard
Looping not working
Looping not working
const notificationPlayerRef = new Player('notification.mp3')
notificationPlayerRef.looping = true
notificationPlayerRef.prepare(err => {
if(err) { return; }
notificationPlayerRef.play()
})
Environment info
React native info output:
System:
OS: macOS 10.15
CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
Memory: 247.98 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.1 - /usr/local/bin/node
Yarn: 1.12.1 - ~/.yarn/bin/yarn
npm: 6.11.2 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.3, 25.0.0, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.2, 28.0.3
System Images: android-27 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
Android NDK: 19.2.5345600
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
create-react-native-app: 2.0.2
Library version: 2.0.2
I founded that by adding autoDestroy: false while initializing make it work like a charm!
const notificationPlayerRef = new Player('notification.mp3', {
+ autoDestroy: false
})
notificationPlayerRef.looping = true
notificationPlayerRef.prepare(err => {
if(err) { return; }
notificationPlayerRef.play()
})
Thanks for your help. It will loop then, but only after a delay of 1 second. So this looping feature is a little bit useless.
Thanks for your help. It will loop then, but only after a delay of 1 second. So this looping feature is a little bit useless.
Correct. The delay is total ruining the user experience