audiocogs / aurora.js

JavaScript audio decoding framework
http://audiocogs.org/codecs
1.26k stars 185 forks source link

seeking & playback #43

Open andrei4002 opened 11 years ago

andrei4002 commented 11 years ago

I often get an AV.UnderflowError when seeking into areas that aren't loaded yet. Is there anything I could do on my side to improve this process?

I'm also having issues regarding playback of a song from url, it takes quite a while until the ready event fires and the song starts playing, so I'm also wondering if there's something I can do to improve this, some pointers to where I should be looking at least

devongovett commented 11 years ago

Yep, we should be handling the underflow errors during seeking, that's a bug. Leaving this issue open for that.

As for HTTP, there are some known issues that we cannot solve due to limitations of the browser's XMLHttpRequest interface. So there are a few things that are dependent on your server. Make sure the server supports both HEAD and Range requests. The HTTPSource first does a HEAD request to get the file size, and then loads chunks using range requests. If your server wasn't configured to support both of those things, it could result in the entire file being downloaded at once instead, which would definitely slow down startup time. Let me know if that's the issue.

andrei4002 commented 11 years ago

the server is working properly, and I also subclassed the HTTPSource to not use the head request since I already have the file size before downloading the file (I'm simply initializing the @length var with the filesize and skipping the head request) - No matter, it's the same result with/without my custom source

I also tried modifying the chunk size but got basically the same result (as in having enough buffer to play the song but not being 'ready')

On Wednesday, September 11, 2013, Devon Govett wrote:

Yep, we should be handling the underflow errors during seeking, that's a bug. Leaving this issue open for that.

As for HTTP, there are some known issues that we cannot solve due to limitations of the browser's XMLHttpRequest interface. So there are a few things that are dependent on your server. Make sure the server supports both HEAD and Range requests. The HTTPSource first does a HEAD request to get the file size, and then loads chunks using range requests. If your server wasn't configured to support both of those things, it could result in the entire file being downloaded at once instead, which would definitely slow down startup time. Let me know if that's the issue.

— Reply to this email directly or view it on GitHubhttps://github.com/audiocogs/aurora.js/issues/43#issuecomment-24266318 .

devongovett commented 11 years ago

Yeah I just want to make sure that the server isn't sending back the whole file when the first range is requested and ignoring the range. That would definitely slow it down. Could you add some logging or check the chrome network inspector to see if multiple chunks are being returned? If adjusting the chunk size has no effect, this sounds more plausible.

If that's not it, it could be the file you're playing. Some formats like M4A support putting the audio format metadata at the end of the file instead of the beginning, which would force the whole file to be downloaded before playback could occur.

andrei4002 commented 11 years ago

Multiple chunks are being returned (sequentially), and I tried doing something like have a first and/or second chunk smaller, but it downloads more chunks until it gets a too reasonable (high) buffer to start playing. I'm only doing mp3 as a file type. I could give you a (private) link to check things out.

I also saw some strange things like the progress going nuts on (at least I think) VBR mp3's

andrei4002 commented 11 years ago

I kind of solved my previous issues, but right now I'm clueless of how I should approach a 'seek anywhere' feature. I do have a custom HTTPSource working, but I'm only emitting data sequentially.

If I make a request for a buffer that's way ahead of the loaded file, what would be the proper way to send it forward for playback? Can the decoder work with sort of incomplete files? I'm not even sure I'm asking the right questions

NekR commented 9 years ago

Hi guys, so is there a way to seek to yet not loaded time/buffer? Can asset sources also support seeking so it HTTPSource could download needed buffer instead of downloading them in a sequence?

sspilleman commented 8 years ago

Question. How would you seek? If I look at the docs I see a property currentTime... But that is a getter only I believe... Am I missing something?

master255 commented 7 years ago

Look at my web site, for that would make seeking for your player: http://master255.org/?file=/res/Музыка/last_add.m3u8