Pergunta

I am able to stream songs from Grooveshark using there public streaming API. I am using this with jPlayer(jplayer.org) and it's streaming the songs correctly.

But the problem is that in Firefox (checked on latest version) the full duration of the song keeps on increasing from 00:00 to the full song length. Basically the full song duration is the amount of the song buffered.

For e.g. a song of length 04:00 minutes starts buffering. Now when it buffers a quarter of the song (i.e. 01:00 minutes), jPlayer shows the song duration as 01:00 minutes whereas it should be 04:00 minutes.

Screenshot: (The song playing has total length 05:06 minutes)

http://i.stack.imgur.com/wzxPx.png

In Google Chrome (checked on latest version) the full duration of the song is shown and jplayer shows that the whole song is buffered even from the start of the song.

Screenshot: (Chrome shows that the full song is buffered but it is still buffering)

http://i.stack.imgur.com/PSkct.png

jPlayer uses HTML5 first and falls back to flash if HTML5 not supported. Google Chrome supports playing mp3 using HTML5 (Grooveshark stream is an mp3). But Firefox does not supports mp3 in HTML5.

So it is clear that Firefox is using flash and Chrome is using HTML5.

Now the problems I want to solve are :-

  • Getting full duration of song in Firefox and keep everything else like it is.
  • Keeping the full duration of song in Chrome and to show the correct amount of song buffered.

All of this should be possible as grooveshark website itself also uses the same stream.php file.

Grooveshark is also providing it's own flash player but it does not has enough features and specially it's not HTML5.

And if it's not possible with jPlayer then please suggest me a better alternative that supports HTML5 and is good for streaming.

Foi útil?

Solução

One thing you can do, which Grooveshark does sometimes, is take the current length of the song and divide it by the percentage loaded. This will give you a good estimate to the actual duration of the file except for possibly VBR files. You can also try looking at the ID3 tags.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top