Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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. 3. The `getDuration()` method returns `this.soundObject.getDuration()`. It appears to be a wrapper for a method available on `this.soundObject`.
  13. 4. The `getTime()` method returns `this.soundObject.getTime()`. It also appears to be a wrapper for a method available on `this.soundObject`.
  14. 6. 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:
  15. - Stops the `soundObject` property.
  16. - Removes the `"playing"` and `"paused"` classes from the `element` property of `this.currentlyPlaying`.
  17. - Sets `this.currentlyPlaying` to the function's parameter, `song`.
  18. - Changes the `playState` property to `"stopped"`.
  19. - Instantiates a new sound object using `this.currentlyPlaying`, which was just updated to `song`.
  20. 7. The `skipTo()` method takes the `percent` of duration of the song it wants to skip to. If the `playState` property is not `playing`, it will:
  21. - Sets `this.soundObject.setTime` to the functions parameter, `percent` of the `this.soundObject.getDuration`.
  22. 8. The `setVolume()` method takes the `percent` of the `this.volume` and sets `this.soundObject.setVolume` to that percent.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement