Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. var songs = new Sound();
  2.  
  3. function Sound() {
  4. this.song = SC.stream('/tracks/262466922')
  5. }
  6.  
  7. Sound.prototype.play = function() {
  8. this.song.then(function(player) {
  9. player.play();
  10. });
  11. SC.get("/tracks/262466922").then(function(response) { // things to do after the tracks load...
  12. // this should display all relevant information regarding the track // e.g title, author, album art console.log(response); });
  13. var myDiv = document.getElementById("myDiv")
  14. document.getElementById("demo").innerHTML = [response.title]
  15. document.getElementById("tuna").innerHTML = [response.description]
  16. document.getElementById("t").innerHTML = [response.permalink_url]
  17. var st = [response.permalink_url]
  18. var image = document.createElement("img");
  19. var imageParent = document.getElementById("My");
  20. image.id = "Id";
  21.  
  22. image.className = "class";
  23. image.src = "https://i1.sndcdn.com/artworks-000161362583-la3l7n-large.jpg";
  24. imageParent.appendChild(image);
  25.  
  26. console.log(response);
  27. });
  28. }
  29.  
  30. var tracks = ['262466922', '269161148', '269161148'];
  31. var currentSong = 0;
  32.  
  33. function playNext() {
  34. SC.stream("/tracks/" + tracks[currentSong].id).then(function(player) { // streams the track player.play();
  35. // does something when the track is done playing player.on("finish",function(){ // increase currentSong by 1 currentSong += 1;
  36. // call itself and plays the next track playNext(); }); }); }
  37. player.play();
  38. player.on("finish", function() {
  39. currentSong += 1;
  40. playNext();
  41. });
  42. });
  43. }
  44.  
  45. Sound.prototype.pause = function() {
  46. this.song.then(function(player) {
  47. player.pause();
  48. });
  49. }
  50.  
  51. var button = document.getElementById('t');
  52.  
  53. button.addEventListener('click', function() {
  54. playNext();
  55. });
  56.  
  57. <!DOCTYPE html>
  58. <html>
  59.  
  60. <head>
  61. <meta charset="utf-8">
  62. <title></title>
  63. <script src="https://connect.soundcloud.com/sdk/sdk-3.1.2.js"></script>
  64. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  65. </head>
  66. <body>
  67. <div id="search">
  68. <input id="searchterm" type="text" required autofocus cols="50" placeholder="Search on SoundCloud" />
  69. </div>
  70. <button onclick="instaSearch()" id="s">serch</button>
  71.  
  72. <p id="demo"></p>
  73. <p id="My"></p>
  74. <p id="cra"></p>
  75. <p id="tuna"></p>
  76. <p id="t"></p>
  77. <img id="ismg" src="">
  78. <button onclick="songs.play()">Play</button>
  79. <button onclick="songs.pause()">Pausey</button>
  80. <button id='t'>next</button>
  81. <style>
  82.  
  83. </style>
  84. <script src="main7.js">
  85. </script>
  86. </body>
  87. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement