Player.js 445 B

12345678910111213141516171819202122
  1. function Player() {
  2. }
  3. Player.prototype.play = function(song) {
  4. this.currentlyPlayingSong = song;
  5. this.isPlaying = true;
  6. };
  7. Player.prototype.pause = function() {
  8. this.isPlaying = false;
  9. };
  10. Player.prototype.resume = function() {
  11. if (this.isPlaying) {
  12. throw new Error("song is already playing");
  13. }
  14. this.isPlaying = true;
  15. };
  16. Player.prototype.makeFavorite = function() {
  17. this.currentlyPlayingSong.persistFavoriteStatus(true);
  18. };