Wednesday.
How to create a sound cloud API
1) We will create a basic HTML page which will seve our home page
It's include SDK
<!DOCType html>
<html>
<head>
<title>
Include SDK-Using SoundCloud Api
</title>
</head>
<body>
</body>
</html>
2) Register a SoundCloud App
Open the SoundCloud apps page
Click on the Register a new application button.
Give it a name and accept SoundCloud's Developer policies by checking the check box
Click Register button
3) Initialize the client
By "initializing the client" we mean to make the client ready to exchange data between itself and SoundCloud Apiexternal.js
SC.initialize ({
client_id : "CLIENT_ID",
redirect_uri : "CALLBACK_URI"
});
CLIENT_APP => It is provide to us when we register our app
CALBACK_URL => It is the URL to callback .html, an HTML file which gets called after the user has logged in.
4)Getting a list of Treacks
To get a list of random tracks, we can use SC.get()
SC.get("/tracks", function(response){
for (var i=0;i<response.length;i++){
$("ul").append("li")+response[i].title+"</li>");
}
});
tracks expects a callback function
5) Embedding a Track
The SC object offers another method, SC.oEmbed (Url,options,callback), Which embeds the SoundCloud player in our website and allows us to play a track of our choice.
SC.oEmbed('https://soundcloud.com/username/complete-url-to-the-track',
{maxheight: 200, auto-play: $(""#player).html(res.html();
});
6) Implementing user login
Create the callback page
Logging the User In
Playing with the user's data
No comments:
Post a Comment