Output will appear here after link is clicked

A one-liner

 

  1. <script>
  2.  
  3.  
  4. var simpleList = "../song1.mp3|../song2.mp3|../song3.mp3"
  5.  
  6. var myplayer = new wimpyPlayer({
  7. target: "MyTarget",
  8. media: simpleList,
  9. autoPlay : 1,
  10. startOnTrack : 3
  11. });
  12.  
  13. function restorePlaylist(){
  14. myplayer.setPlaylist(simpleList);
  15. }
  16.  
  17. function showPlaylist(){
  18. showObject(myplayer.getPlaylist(), "output");
  19. }
  20.  
  21. function doit1(){
  22. // "i" is a special reference to the internal array index.
  23. // The "i" field is automatically added to each playlist item by wimpy.
  24. // Indices are zero-based (e.g. the first item is 0, the second 1)
  25. myplayer.removePlaylistItems("i", 1);
  26. }
  27.  
  28. function doit2(){
  29. myplayer.removePlaylistItems("file", ["../song1.mp3", "../song2.mp3"]);
  30. }
  31.  
  32. function doit3(){
  33. myplayer.removePlaylistItems("i", [0,2]);
  34. }
  35.  
  36. function whatAmIPlaying() {
  37. var info = myplayer.getTrackDataset();
  38. var index = info["i"];
  39. var file = info["file"];
  40. var title = info["title"];
  41. var output = "array index: " + index + " (Which is track number: " + (index+1) + " in the wimpy playlist)";
  42. output += "\n\nfile: " + file;
  43. output += "\n\ntitle: " + title;
  44. output += "\n\ngetStopped: " + myplayer.getStopped();
  45. alert(output);
  46. }
  47.  
  48.  
  49. </script>
  50.  
  51. <!-- Player gets rendered here-->
  52. <div id="MyTarget"></div>
  53.  
  54.  
  55. <p>
  56. <input type="button" onclick="restorePlaylist()" value="Restore Playlist">
  57. <input type="button" onclick="showPlaylist()" value="ShowPlaylist">
  58. </p>
  59. <p><input type="button" onclick="doit1()" value="Remove the second item (zero-based indices!)"></p>
  60. <p><input type="button" onclick="doit2()" value="Remove items by file URL"></p>
  61. <p><input type="button" onclick="doit3()" value="Remove first and last"></p>
  62. <p><input type="button" onclick="whatAmIPlaying()" value="whatAmIPlaying"></p>
  63.  
  64.  
  65. <pre id="output">Output will appear here after link is clicked</pre>
  66.  
  67.  
  68. <!-- Create a player instance and set the "id" to
  69. "myPlayerAsDiv" so we can reference it in our javascript -->
  70. <div id="myPlayerAsDiv" data-wimpyplayer data-media="song1.mp3|song2.mp3|song3.mp3"></div>
  71.  
  72. <p> A one-liner </p>
  73. <p><input type="button" onclick="javascript:wimpy.getPlayer("myPlayerAsDiv").removePlaylistItems("i", 1)" value="Remove The second Item (which is indice 1 of a zero-based array)"></p>
giItT1WQy@!-/#