I am trying to play audio files but the thing is the source of audio is coming from socket. When multiple audio's URL come from socket one after another in some fraction of seconds then latest URL is playing but I want to play the audio file one after another
Here below is the code
useEffect(() => {
socket.on("newsAudioStream", async (AudioStream) => {
if (speech && settings.rFeeds) {
const uInt8Array = new Uint8Array(AudioStream);
const arrayBuffer = uInt8Array.buffer;
const blob = new Blob([arrayBuffer]);
const url = URL.createObjectURL(blob);
pollyPlayerRef.current.src = url;
pollyPlayerRef.current.load();
pollyPlayerRef.current.play();
}
});
return () => socket.off("newsAudioStream");
}, [settings.rFeeds, speech]);
Can anyone please help me to fix this problem.