SoundCloud API v3 Stream not working in Chrome

2019-04-28 08:17发布

I have been trying to get this to work for months but it's still not working. It works fine in all browsers except Google Chrome. The problem is audio doesn't stream in Chrome.

Here's a JS fiddle of the most basic example. https://jsfiddle.net/sq23uxqs/

First I include the new javascript SDK

 <script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>

Then in my Javascript

 SC.initialize({
            client_id: "78c2f0ffbef212328769a921e5663879"
          });


 SC.stream('/tracks/293').then(function(player){
         player.play();
 });

Does anyone know why this is or is it a problem with the API?

2条回答
Evening l夕情丶
2楼-- · 2019-04-28 08:29

After investigation it seems to be related to issues with the flash player. Proof is that if you go here chrome://plugins/ and disactivate the flash player it will work again in Chrome. But obviously when developing a site you don't want the site to work just for you.

Soundcloud Api seems to use soundmanager2 as a base to handle audio stream that itself have 2 modes flash and html5. The issue is that if the flash player is avaible it will try to use it and fail while if it's not available it will just use html5 and work right away.

https://github.com/soundcloud/soundcloud-javascript/issues/39

查看更多
叼着烟拽天下
3楼-- · 2019-04-28 08:46

'rtmp' protocol on chrome causes that issue.. reverse the order of available protocols so 'http' will be before 'rtmp'

if (player.options.protocols[0] === 'rtmp') {
    player.options.protocols = player.options.protocols.reverse();
}
查看更多
登录 后发表回答