javascript - SoundCloud Api redirect confusion and Audio Api Streams -


i attempting make request soundcloud api. when response set stream_url source of < audio > element.

this works:

http://matthiasdv.org/beta/

but not always... when search 'bonobo' example, can play first few tracks without issue. when try play 'london grammar - hey (bonobo remix)' - 7th result - won't play. throws no errors whatsoever.

i've been tinkering around chrome's webdev-tools , under network tab see requests being made. found tracks play have short request url, this:

https://ec-media.sndcdn.com/vr5ukuozylbw.128.mp3?f10880d39085a94a0418a7ef69b03d522cd6dfee9399eeb9a522029f6bfab939b9ae57af14bba24e44e1542924c205ad28a52352010cd0e7dd461e9243ab54dc0f0bba897d 

and ones don't this:

https://cf-media.sndcdn.com/8pcswwlkswod.128.mp3?policy=eyjtdgf0zw1lbnqiolt7iljlc291cmnlijoikjovl2nmlw1lzglhlnnuzgnkbi5jb20vofbdc3d3bgtzd09kljeyoc5tcdmilcjdb25kaxrpb24ionsirgf0zuxlc3nuagfuijp7ikfxuzpfcg9jafrpbwuioje0mzm0mjc2mdn9fx1dfq__&signature=cd-xvhnvqniatkfrbddvy0q7996c8dymwxrlwbbduab0~l0mynf1ftcmky~21t8q-gcz2~dmk8dz7uvxvjtijgxpxezvhntbvescmk6ifmg-xsaty-4ohjyjrizj2j8ne4una4ml7mwbwcqw4ktutpzitoqugus3dpfdii3vf-dvzb2l~xg-g8uu3uoni1whnaafhf1qwmo7swwb89htcciuvbmflug28elrjeq-au8mqimb3sltno6nuuttphxr2ayxbsycylljvxa3ul8p1rhls5xwhkwxy8xug4jwey27~c5pvaomk6z5ljx-mz-0zys4riuytl0zacbz1ofwtq__&key-pair-id=apkajagz7vmh2pfpw6uq 

now @ first glance figured encoding issue, wrapping quick encodeuri() around ajax url did not work.

furthermore not understand these urls come from. in code directing ajax request towards, example:

https://api.soundcloud.com/tracks/140326936/stream?client_id=5c6ceaa17461a1c79d503b345a26a54e 

thus, request url in request (as found under 'network' in chrome's webdev tools) makes no sense me. soundcloud redirecting requests cdn-host? 1 more thing i've noticed each time 2 requests fired instead of one. first 1 canceled , contains 'provisional headers shown' warning. believe because setting crossorigin = "anonymous", otherwise browsers not load content.

what guess may cause problem when url set src attribute of element evenlistener fired in dancer.js library, handles audio api , playback (https://github.com/jsantell/dancer.js/). may encodeuri() required somewhere in library.

i decided ask question anyhow because don't understand how request urls's above formed , why two, instead of one, requests being fired , why first cancelled.

any hints solve playback issue more welcome too...

when run request for

 https://api.soundcloud.com/tracks/140326936/stream?client_id=5c6ceaa17461a1c79d503b345a26a54e 

you http 302 found response server, url redirect (http://en.wikipedia.org/wiki/http_302). cause browser load new url server returns, , 2 requests see. server says "yeah, know find file, ask guy on there".

the reason why 1 works , other not, i'd think, https://ec-media.sndcdn.com has access-control headers set while https://cf-media.sndcdn.com doesn't. issue server configuration , unfortunately nothing can control client side. dunno if it's deliberate move soundcloud or if it's ask them about.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -