Skip to content

Commit

Permalink
fix: always reset volume when initializing player
Browse files Browse the repository at this point in the history
Sometimes, the player can be initialized with an empty audioList. In
this case, the default volume doesn't get set from the defaultVolume
prop, and soundValue gets set to 100, which is out of range.

While here, fix the default value for soundValue.
  • Loading branch information
sparkhom committed Sep 29, 2021
1 parent a0f0d7b commit c7a38f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class ReactJkMusicPlayer extends PureComponent {
toggle: this.props.mode === MODE.FULL,
playing: false,
currentTime: 0,
soundValue: DEFAULT_VOLUME * 100,
soundValue: DEFAULT_VOLUME,
moveX: 0,
moveY: 0,
loading: false,
Expand Down Expand Up @@ -2319,12 +2319,12 @@ export default class ReactJkMusicPlayer extends PureComponent {
isBindKeyDownEvents = true,
resetAudioVolume = true,
) => {
if (!Array.isArray(audioLists) || !audioLists.length) {
return
}
if (resetAudioVolume) {
this.setDefaultAudioVolume()
}
if (!Array.isArray(audioLists) || !audioLists.length) {
return
}
this.bindUnhandledRejection()
this.bindEvents(this.audio)
this.initLyricParser()
Expand Down

0 comments on commit c7a38f1

Please sign in to comment.