Guest User

Untitled

a guest
Feb 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 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. 5. If the `playState` is `"paused"` or `"stopped"`
  19. - The `setVolume` is set to `this.volume`
  20. - Plays the `soundObject` property.
  21. - Changes the `playState` property to `"playing"`
  22. - Removes the `"paused"` class from the `element` property of `this.currentlyPlaying` and adds `"playing"`class
  23. Else
  24. - The `soundObject` property is paused
  25. - Changes the `playState` property to `"paused"`
  26. - Removes the `"playing"` class from the `element` property of `this.currentlyPlaying` and adds `"paused"`class
  27. 6. The skipTo( ) method accepts one parameter, "percent." It checks if the `playState` property is different from `"playing"`, and if so, it returns:
  28. - The `soundObject` property is set to the time (percent / 100) multiply by the property of `this.soundObject`, the `getDuration()` method
  29. 7. `setVolume()` accepts one parameter, `percent`
  30. - `this.volume` is set to a percent
  31. - `this.soundObject` is set the value of the percent of `setVolume`.
Add Comment
Please, Sign In to add comment