TheGuy
TheGuy

Reputation: 33

why doesn't Chrome stream a song using SoundCloud API V3

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

Any idea to make it working in Chrome?

Upvotes: 2

Views: 653

Answers (3)

loudmouth
loudmouth

Reputation: 2004

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

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

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();
});

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

Upvotes: 1

Elliott McNary
Elliott McNary

Reputation: 1209

As JAL said, this is unfortunately known and there doesn't seem to be a fix out there.

Instead what I would suggest doing is using their widget API to create a custom iFrame (you can make it invisible if you want), and then use the .load() method to load whichever track, or tracks you want. You can read about that here.

The widget API is really nice because it comes with a bunch of event listeners that are very helpful, depending on what you're doing.

Upvotes: 0

JAL
JAL

Reputation: 42449

This is a known compatibility issue due to Chrome's version of Flash. There is little you can do besides disable Flash or play with the different versions of the SDK to see which one works for your specific build of Chrome.

Upvotes: 0

Related Questions