bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.16k stars 275 forks source link

Problem to re play a streaming audio #515

Open CaleoSystems opened 7 months ago

CaleoSystems commented 7 months ago

Discussed in https://github.com/bbc/peaks.js/discussions/514

Originally posted by **CaleoSystems** November 28, 2023 Hello, I am using Peaks to play audios stored on a remote server served by a NodeJS based streaming server. Everything works fine before the audio ends, when the audio ends and I play it again I can't go forward or back since it always sends it to the beginning. This behavior only occurs with streaming and not with local audio. Thanks for your help.
chrisn commented 7 months ago

Which streaming server / library are you using?

Related: https://github.com/bbc/peaks.js/issues/189

CaleoSystems commented 7 months ago

Hi Chris,

I am using : const http = require('http'); ... ... const src = fs.createReadStream(fileName); res.writeHead(200, {'Content-Type':'audio/wav','Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'OPTIONS, POST, GET'}); src.pipe(res);

The waveform is generated using "audiowaveform".

Node v18.16.0

Thanks.

chrisn commented 7 months ago

Thanks. Seeking probably isn't working because the browser isn't caching all the audio, and it can only seek within time regions it has cached. For that to work, you can serve the audio as a static file, so the browser can request the time regions it wants to play (see https://github.com/bbc/peaks.js/blob/master/doc/faq.md).

CaleoSystems commented 7 months ago

Chris, I really appreciate your help.

This problem is not happening on Firefox, I will try some fix according to the reference you mentioned.

Thank you very much.