Show the status of player.

  1. <!-- Results will appear within this DIV -->
  2. <div id="showStatusID"></div>
  3.  
  4. <!-- Wimpy Player Instance -->
  5. <div id="myPlayerID" data-wimpyplayer></div>
  6.  
  7. <script>
  8.  
  9. // Plce variables here on the window so all functions have access to them.
  10.  
  11. var player;
  12. var statusView;
  13.  
  14. function pollPlayer(){
  15. var info = player.getStatus();
  16. var displayText = "";
  17. displayText += "Enabled: " + info.enabled + "<br/>";
  18. displayText += "Initialized: " + info.init + "<br/>";
  19. displayText += "Status: " + info.status + "<br/>";
  20. displayText += "Activity: " + info.activity + "<br/>";
  21. displayText += "Playing: " + info.playing + "<br/>";
  22. displayText += "Percent: " + info.percent + "<br/>";
  23. displayText += "Duration Nice: " + info.duration_nice + " Raw Seconds: " + info.duration + "<br/>";
  24. displayText += "Remaining Nice: " + info.remaining_nice + " Raw Seconds: " + info.remaining + "<br/>";
  25. displayText += "Current Nice: " + info.current_nice + " Raw Seconds: " + info.current + "<br/>";
  26. statusView.innerHTML = displayText;
  27.  
  28. }
  29.  
  30. function setup(){
  31.  
  32. // Get a handle to the player that has the DIV id set to "myPlayerID"
  33. player = wimpy.getPlayer("myPlayerID");
  34.  
  35. // Get a handle to the DIV we're using to report the values.
  36. statusView = document.getElementById("showStatusID");
  37.  
  38. // Set up a ticker to retrieve the values at regular intervals.
  39. // poll every 500 milliseconds (1/2 seconds)
  40. setInterval(pollPlayer, 500);
  41.  
  42. }
  43.  
  44. // Call our setup function when wimpy is ready. If we don't wait
  45. // until wimpy has set up all the players, we'll get errors.
  46. wimpy.onReady(setup);
  47.  
  48.  
  49. </script>