onPlaybackStatusUpdate should return the output after every 100ms but only returns on play or stop. am I missing something in my code. (I am new to Expo and Expo AV). Please see code below used for loading and playing audio file
if(!sound._loaded)
await sound.loadAsync(
require('./assets/Audio.mp3'),
initialStatus,
);
sound.setStatusAsync({progressUpdateIntervalMillis: 200});
sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
await sound.playAsync();
console.log(sound);
}
const initialStatus = (status) => {
console.log("initialStatus");
console.log(status);
}
let onPlaybackStatusUpdate = async (playbackStatus) => {
//if(!isNaN(playbackStatus.durationMillis))
//setTotalLength(playbackStatus.durationMillis/1000);
//setCurrentPos(playbackStatus.positionMillis.toString().split(".")[0]/1000);
//setIsPlaying(playbackStatus.isPlaying);
console.log("onPlaybackStatusUpdate");
console.log(playbackStatus);
}
Found a fix for web.
The issue lies with the event emitter between react-native and react-native-web.
It's a small change between two files but I made a new .web.js file for Sound.js since ios and android were fine. The main difference is in
this._key.ontimeupdate
You'll have to patch expo-av.
I'm stil on sdk 42 so here's my patch for version 9.2.3 of expo-av that worked as expected.
Would've submitted a PR to expo but I'm still on version 42 and 45 is in beta. I looked around version 45 and major changes have happened since v43 even with the EvenEmitter logic I dug into to solve this.
Hope this helps someone out!