Guest User

Untitled

a guest
Oct 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 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. - If `playState` has the property of `"paused"` or `"stopped"` then
  20. -Sets the volume of the `soundObject`
  21. -Plays the `soundObject with the `play` function
  22. -Changes the `playState` to `playing`
  23. -Removes the `paused` class from `this.currentlyPlaying` and replaces it with the `playing` class
  24. -if the `playstate` is anything other than `"paused"` or `"stopped"` then
  25. -The `this.soundObject` preforms the `pause` function
  26. -The `playState` is changed to `paused`
  27. -Removes the `playing` class from `this.currentlyPlaying` and replaces it with `paused`
  28. 5. The `skipTo()` method accepts one parameter, `percent`. It checks to see if `this.playState` does not equal `playing` and if it doesn't then it will have a return.
  29. -The `setTime` of `this.soundObject` will be shown as a percentage based on the entire duration of `this.soundObject`
  30. 6. The `setVolume()` method will accept one parameter, `percent`.
  31. -`this.volume` will be set to `percent`
  32. -`this.soundObject` will set the volume based on the `percent`
  33. 7. The constant `player` is reassigned to `Player()`
Add Comment
Please, Sign In to add comment