Guest User

Untitled

a guest
Jan 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. 1. This file declares a class, `Player`, instantiates it, and assigns it to a global `player` variable.
  2. 2. The `Player` class contains four methods:
  3. - `constructor()`
  4. - `playPause()`
  5. - `skipTo()`
  6. - `setVolume()`
  7. 3. The `constructor()` method sets initial values for the `currentlyPlaying`, `playState`, `volume`, and `soundObject` properties.
  8. - `currentlyPlaying` is set to the first item in `album.songs`.
  9. - The initial `playState` is `"stopped"`.
  10. - The `volume` is set to the number `80`.
  11. - The `soundObject` instantiates a new `buzz.sound` object using the `soundFileUrl` property of `this.currentlyPlaying`. The `buzz` variable doesn't appear to be initialized here, so presumably it's a dependency loaded elsewhere.
  12. 4. The `playPause()` method accepts one parameter, `song`. It sets it to `this.currentlyPlaying` by default. It checks to see if `this.currentlyPlaying` is different from `song`, and if so, it:
  13. - Stops the `soundObject` property.
  14. - Removes the `"playing"` and `"paused"` classes from the `element` property of `this.currentlyPlaying`.
  15. - Sets `this.currentlyPlaying` to the function's parameter, `song`.
  16. - Changes the `playState` property to `"stopped"`.
  17. - Instantiates a new sound object using `this.currentlyPlaying`, which was just updated to `song`.
  18.  
  19. The 'playPause()' method also checks to see if 'this.playState' is equal to '"paused"' or if 'this.playState' is equal to '"stopped"', and if so it:
  20. - Sets the volume of the 'soundOject' property to 'this.volume' value, which is initially set at 80
  21. - Plays the 'soundObject' property.
  22. - Sets 'this.playState' to '"playing"'.
  23. - Removes the '"paused"' class from the 'element' property of 'this.currentlyPlaying' and adds the '"playing"' to the 'element; property of 'this.currentlyPlaying'
  24. but if 'this.playState' is not equal to either 'paused' or 'stopped', and if so it:
  25. - the 'soundObject' property is Paused.
  26. - Sets 'this.playState' to 'paused'.
  27. - Removes the '"playing"' class from the 'element' property of 'this.currentlyPlaying' and adds the '"paused"' to the 'element; property of 'this.currentlyPlaying'
  28.  
  29. 5. The 'skipTo ()' method accepts one parameter 'percent'. It checks to see if 'this.playState' is different from 'playing', and if so it:
  30. - 'return' or exits out of the 'skipTo' method.
  31. If 'this.playState' is the same as 'playing', if so it:
  32. - Sets Time as a (percentage/100) * ('getDuration ()' value of the 'soundObject' property)
  33.  
  34. 6. The 'setVolume ()' method accepts one parameter 'percent'.
  35. - Sets 'this.volume' to percent value
  36. - Ses volume percent of the 'soundObject' property
Add Comment
Please, Sign In to add comment