SoundCloud API - how to play private sound with HTML5 <audio> tag

不想你离开。 提交于 2019-12-12 01:35:54

问题


I would like to play sound with HTML5 tag.

The sourcecode is shown as below:

  SC.get("/tracks/153068147", {}, function(sound, error) {
    $('#player').attr('src', sound.stream_url + '?client_id=' + client_id);
  });

When I set the sound to be public, it works well. But when I set it to be private, it does not work. What is the problem?

By the way, I also authenticated my APP with SC.connect before I play it. And the sound is also uploaded with my SoundCloud account.


回答1:


you need to replace http to https and add user_auth_token in the url so:

`$('#player').attr('src', sound.stream_url.replace('http:','https:') + '?client_id=' + client_id+'&oauth_token=' + oAuthToken);`


来源:https://stackoverflow.com/questions/24076885/soundcloud-api-how-to-play-private-sound-with-html5-audio-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!