Reputation: 191
I am trying to make a music player that works with SoundCloud. So I have buttons like play, next, prev. and I made functions like:
function playIt(){
SC.stream("/tracks/293", function(sound){
sound.play();
});
}
So it plays song when the button is player:
<button onclick="playIt()">Play</button>
But it does not work. Any idea? Here is the demo
Upvotes: 0
Views: 5955
Reputation: 4331
According to @lago above, let me deliver a full short code, so you can do your own labs ;-)
<!DOCTYPE html>
<html>
<head>
<script src=http://connect.soundcloud.com/sdk.js></script>
<script>
SC.initialize({client_id:'your client_id goes here'});
function p()
{
SC.stream
(
'/tracks/293',
function(s)
{
s.play()
}
)
}
</script>
</head>
<body>
<button onclick=p()>play</button>
</body>
</html>
API guide here
Upvotes: 0
Reputation: 1214
1º - Put the JS files in the head. Use the "External Resources" on JSfiddle.
2º - Put var sound
= [...] before the SC.steam
.
Is that.
Demo: http://jsfiddle.net/don/zcN7G/3/
Upvotes: 1