7

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.

Is there any hint/solution to this problem?

user3001
  • 3,437
  • 5
  • 28
  • 54
  • i regularly use the jPlayer HTML5 solution in Chrome to play audio from a different origin - that's fine.. it's only AJAX requests that are restricted to the same origin.. something else is going on here.. – Lloyd Mar 30 '12 at 21:32
  • I took the time to do some research and it seems I was wrong. I'll make a seperate question for what I found out. – user3001 Apr 06 '12 at 17:01
  • ran into the same issue using jwPlayer – Danny G Aug 06 '12 at 18:04
  • did you change the source with jQuery? If yes then did you execute `$("#my_audio").load()`? – Steel Brain Jun 05 '14 at 19:55

1 Answers1

4

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/

wangii
  • 2,570
  • 1
  • 22
  • 29
  • @torazaburo, you got me. it was a problem I had 4 or 5 years ago. If my memory serves me correctly, I ended up with a micro service hosted on google app engine just to do the 302 redirection with SSL support. – wangii May 26 '16 at 20:51