Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var songs = new Sound();
- function Sound() {
- this.song = SC.stream('/tracks/262466922')
- }
- Sound.prototype.play = function() {
- this.song.then(function(player) {
- player.play();
- });
- SC.get("/tracks/262466922").then(function(response) { // things to do after the tracks load...
- // this should display all relevant information regarding the track // e.g title, author, album art console.log(response); });
- var myDiv = document.getElementById("myDiv")
- document.getElementById("demo").innerHTML = [response.title]
- document.getElementById("tuna").innerHTML = [response.description]
- document.getElementById("t").innerHTML = [response.permalink_url]
- var st = [response.permalink_url]
- var image = document.createElement("img");
- var imageParent = document.getElementById("My");
- image.id = "Id";
- image.className = "class";
- image.src = "https://i1.sndcdn.com/artworks-000161362583-la3l7n-large.jpg";
- imageParent.appendChild(image);
- console.log(response);
- });
- }
- var tracks = ['262466922', '269161148', '269161148'];
- var currentSong = 0;
- function playNext() {
- SC.stream("/tracks/" + tracks[currentSong].id).then(function(player) { // streams the track player.play();
- // does something when the track is done playing player.on("finish",function(){ // increase currentSong by 1 currentSong += 1;
- // call itself and plays the next track playNext(); }); }); }
- player.play();
- player.on("finish", function() {
- currentSong += 1;
- playNext();
- });
- });
- }
- Sound.prototype.pause = function() {
- this.song.then(function(player) {
- player.pause();
- });
- }
- var button = document.getElementById('t');
- button.addEventListener('click', function() {
- playNext();
- });
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <script src="https://connect.soundcloud.com/sdk/sdk-3.1.2.js"></script>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- </head>
- <body>
- <div id="search">
- <input id="searchterm" type="text" required autofocus cols="50" placeholder="Search on SoundCloud" />
- </div>
- <button onclick="instaSearch()" id="s">serch</button>
- <p id="demo"></p>
- <p id="My"></p>
- <p id="cra"></p>
- <p id="tuna"></p>
- <p id="t"></p>
- <img id="ismg" src="">
- <button onclick="songs.play()">Play</button>
- <button onclick="songs.pause()">Pausey</button>
- <button id='t'>next</button>
- <style>
- </style>
- <script src="main7.js">
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement