Home > Web Front-end > JS Tutorial > Detailed explanation of graphic code on how to use SoundCloud API in JavaScript SDK

Detailed explanation of graphic code on how to use SoundCloud API in JavaScript SDK

黄舟
Release: 2017-03-08 14:41:58
Original
2281 people have browsed it

SoundCloud has developed an API that can be used by developers. This API allows developers to obtain almost any data they want. However, the usage of this API is a bit confusing, especially for beginners, because the SoundCloud API development documentation and documentation examples at this time use different versions of the SDK (Software Development Kit).

What is the difference between SoundCloud API and SoundCloud SDK? Fundamentally speaking, the SoundCloud API is a collection of URLs that provides developers with permission to obtain data from the SoundCloud server, and the SoundCloud SDK is a library (or client) written in advance for querying the SoundCloud API. If you want to know more about this, click the following link: http://www.php.cn/

In this tutorial, we will learn how to access the SoundCloud API and how to simplify The process of using SoundCloud SDK. We'll learn how to set up the SoundCloud SDK from SoundCloud, and then go on to write JavaScript code to get SoundCloud data, play audio and more functions provided by SoundCloud.

Getting Started Guide

Understanding the concepts and working methods of HTTP and API will be helpful for you to study this tutorial. If you want to know more about APIs, I recommend you take a look: An Introduction to APIs (an introduction to APIs. Link address: http://www.php.cn/). It will also be helpful to know a little bit about asynchronous JavaScript, promises, and callback functions as you follow this tutorial. We use jQuery in our code examples in this article, so if you understand the basics of jQuery, reading the code examples in this article will be less painful.

In order to start querying the SoundClound API using JavaScript, we need to download the JavaScript SDK provided by SoundClound. As mentioned at the beginning of the article, there are two different SDK versions available.

Which version of the SDK should I use?

The main difference between these two versions of the SDK is the way they return data when an asynchronous request is made and sent to the SoundClound API. . The latest version of the SDK returns a Promise, while another version of the SDK needs to return a callback function as a parameter.

I noticed a problem. With the SDK version used in the document, there seems to be a problem on the SDK user login function interface of that version. This problem is that the pop-up login window will not automatically close.

Therefore, for the sake of simplicity, and because the older version of the SDK is more stable, we will use the older version of the SDK in the article examples throughout this tutorial. This version of the SDK will need to return a callback function for the client's asynchronous request.

Using the SoundCloud API

Set up a basic HTML document

We create a basic HTML page that serves as our home page. We include the address of the SDK in the attribute src of the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template