Donc voil� je voudrais r�cup�rer le lien du player embarque de soundcloud pour pouvoir l'afficher sur mon site. Il se trouve l� :
<input id="embed-code-field" class="url auto-select" type="text" value="<object height="81" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fapi.soundcloud.com%2Ftracks%2F15059521"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fapi.soundcloud.com%2Ftracks%2F15059521" type="application/x-shockwave-flash" width="100%"></embed> </object> <span><a href="http://soundcloud.com/doa-3/english-time">English Time</a> by <a href="http://soundcloud.com/doa-3">DoA</a></span> "
Donc j'ai �crit ce petit bout de code qui ne marche pas (la requete se lance mais son status ne d�passe jamais 2) et je n'y connais quasiment rien en javascript. A noter que j�ex�cute le script en local mais je ne crois pas que �a change beaucoup de choses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| function player(){
alert('go');
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP')
}catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
}
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if(xhr.status == 200) {
alert('page trouvée');
var doc = xhr.responseXML;
var input = doc.getElementById("embed-code-field");
var obj = input.value;
alert(obj);
document.getElementById("audio").innerHTML = obj;
}
else {
document.ajax.dyn="Error code " + xhr.status;
}
}
}
xhr.open( "GET", "http://soundcloud.com/doa-3/english-time", true);
xhr.send(null);
} |
puis
1 2 3 4
| <body onload='player()'>
TEST
<div id="audio"></div>
</body> |
Partager