Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 audio with a HTTP 302 redirect in Chrome

I am trying to write an HTML 5 based last.fm player using the popular jPlayer jQuery plugin (http://jplayer.org). The player works fine in Firefox. However I ran into a problem: From the last.fm API (http://last.fm/api) I get a playlist with urls to the files. When requesting one of these, last.fm does a HTTP 302 redirect from play.last.fm to something like "http://s03.last.fm/someurl/128.mp3".

It looks like there is some same origin policy for html 5 tags, because jPlayer is unable to play the file in Chrome and Chromium. If jPlayer uses the flash solution (using "flash, html" instead of "html, flash"), everything works fine.

I installed the extra codecs on my Ubuntu and mp3 playback works nicely for the jPlayer demos.

HEAD requests are not supported by the streaming servers. I already tried to do a normal GET request and then tried to get the "Location" header of the xmlhttprequest, but it fails with a security error.

You can find the sources of my (proof of concept) project at https://github.com/tburny/html5-lastfm-player

Is there any hint/solution to this problem?

like image 417
user3001 Avatar asked Mar 30 '12 13:03

user3001


1 Answers

i had a similar problem but only on android browser. there are lots of gotchas. the key question is if either the original url which gives 302 and the end one is https? if so it'll fail.

check out this test suite http://areweplayingyet.org/

like image 96
wangii Avatar answered Sep 20 '22 23:09

wangii