player-demo.js 447 B

123456789101112131415161718
  1. var Player = require('player');
  2. var player = new Player();
  3. playerAddSong('./downloads/\'IS THAT A MAN RIDING A SHRIMP\'.mp3');
  4. // event: on error (No next song was found)
  5. player.on('error', function(err){
  6. // Reset the object, resetting the playlist.
  7. player = new Player();
  8. });
  9. // Add a song and start the playlist, if it's empty
  10. function playerAddSong(song) {
  11. player.add(song);
  12. if (player.list.length == 1) {
  13. player.play();
  14. }
  15. }