From c7a38f1221964b8268f13845757de6f345d6440f Mon Sep 17 00:00:00 2001 From: Serguey Parkhomovsky Date: Sat, 25 Sep 2021 22:19:46 -0700 Subject: [PATCH] fix: always reset volume when initializing player 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. --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index c648a742..4d277ddb 100644 --- a/src/index.js +++ b/src/index.js @@ -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, @@ -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()