click to load and play playlist

click to load and play playlist

click to load and play playlist

  1. <script>
  2.  
  3. // Put variable on the window scope so all function have access to the var.
  4. var player;
  5.  
  6. var myPlaylist1 = '[{"title":"json track 1","file":"../song1.mp3"},{"title":"json track 2","file":"../song2.mp3"},{"title":"json track 3","file":"../song3.mp3"}]';
  7.  
  8. var myPlaylist2 = [
  9. {
  10. title : "js track 1",
  11. file : "../song1.mp3"
  12. },
  13. {
  14. title : "js track 2",
  15. file : "../song2.mp3"
  16. },
  17. {
  18. title : "js track 2",
  19. file : "../song2.mp3"
  20. }
  21. ];
  22.  
  23. // The function to edit the "live" playlist
  24. function loadAndPlayPlaylist(playlist, kind){
  25.  
  26. if( ! player ){
  27. player = wimpy.getPlayer("myPlayer");
  28. }
  29. player.setPlaylist(playlist, true, kind);
  30. }
  31.  
  32. </script>
  33.  
  34. <div id="myPlayer" data-wimpyplayer data-media="none"></div>
  35.  
  36.  
  37. <p onclick="loadAndPlayPlaylist('../song1.mp3|../song2.mp3|../song3.mp3', 'dtxt')">click to load and play playlist</p>
  38. <p onclick="loadAndPlayPlaylist(myPlaylist1, 'json')">click to load and play playlist</p>
  39. <p onclick="loadAndPlayPlaylist(myPlaylist2, 'js')">click to load and play playlist</p>
giItT1WQy@!-/#