我已经为soundcloud注册了一个练习应用程序,以便获得一个客户端id。我的应用程序没有官方网站,因为我不想注册域名。我只是想学习如何使用.html和.js文件来使用soundcloud。我已经跟踪了API tutorials exactly,但每当我尝试使用soundcloud时都没有任何反应。我使用我的客户机ID初始化了SC,并导入了JQuery和我需要的所有东西。谢谢你的帮助
我的html文件(practice.html):
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="//connect.soundcloud.com/sdk.js"></script>
<script src= "script.js"></script>
</head>
<body>
<div id="player"></div>
</body>
</html>我的.js文件(script.js):
SC.initialize({
client_id: 'the client id they gave me...'
});
$(document).ready(function() {
SC.get('/tracks/293', function(track) {
SC.oEmbed(track.permalink_url, document.getElementById('player'));
});
});同样,当我加载页面时没有任何反应...
发布于 2013-06-24 14:23:23
看起来你缺少SoundCloud JavaScript SDK的完整url (缺少http:):
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://connect.soundcloud.com/sdk.js"></script>
<script src= "script.js"></script>
</head>
<body>
<div id="player"></div>
</body>
</html>您应该能够在浏览器中本地运行此程序,因为SoundCloud支持跨域资源共享标头,从而消除了对XSS:Of CORS We Do的限制
https://stackoverflow.com/questions/17266590
复制相似问题