为什么不流Chrome浏览器使用的SoundCloud API V3的一首歌 [英] why doesn't Chrome stream a song using SoundCloud API V3

查看:275
本文介绍了为什么不流Chrome浏览器使用的SoundCloud API V3的一首歌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用流的SoundCloud的API的一首歌,但apprantly不会在Chrome中播放。但是它适用于其他浏览器。

I am trying to stream a song using SoundCloud api, but apprantly it does not play it in Chrome. However it works on other browsers.

SC.initialize({
  client_id: '65243ec784b284f1d8a8f950312240fa',
  redirect_uri: 'http://example.com/callback'
});

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

的jsfiddle

任何想法,使其在Chrome中工作吗?

Any idea to make it working in Chrome?

推荐答案

看到我在的打开Github上的问题(code粘贴下面为了方便)。

see my solution on the open Github issue (code pasted below for convenience).

如果您使用SoundManager2,然后呼叫建立时,DOM已准备就绪。

If you use SoundManager2, then call setup when the dom is ready.

而不是使用的SoundCloud API的流函数,调用SC.get然后在SoundManager类使用创建soundobject createSound(),在stream_url通过从轨道您刚才抓住。

Rather than using the stream function of the SoundCloud api, call SC.get and then create a soundobject in SoundManager using createSound(), passing in the stream_url from the track that you just grabbed.

SC.get('/users/711016/tracks').then(function(tracks) {
    var sound = soundManager.createSound({
        id: 'mySound',
        url: tracks[0].stream_url + "?client_id=YOUR_CLIENT_ID",
        stream: true
    });
    sound.play();
});

我想象中的API路线你试图播放可能会比我的不同的音轨。

I imagine the api route to the track(s) you are trying to play may be different than mine.

这篇关于为什么不流Chrome浏览器使用的SoundCloud API V3的一首歌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆