apm-react-audio-player 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -101,9 +101,10 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
|
|
|
101
101
|
}
|
|
102
102
|
}, [currentTime]);
|
|
103
103
|
var onLoadedMetadata = function onLoadedMetadata() {
|
|
104
|
+
var _audioRef$current;
|
|
104
105
|
var seconds = Math.floor(audioRef.current.duration);
|
|
105
106
|
setDuration(seconds);
|
|
106
|
-
if (!
|
|
107
|
+
if (!(audioRef !== null && audioRef !== void 0 && (_audioRef$current = audioRef.current) !== null && _audioRef$current !== void 0 && _audioRef$current.currentSrc.includes('stream'))) {
|
|
107
108
|
progressBarRef.current.max = seconds;
|
|
108
109
|
}
|
|
109
110
|
};
|
|
@@ -111,7 +112,10 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
|
|
|
111
112
|
setCurrentTime(progressBarRef.current.value);
|
|
112
113
|
};
|
|
113
114
|
var whilePlaying = function whilePlaying() {
|
|
114
|
-
|
|
115
|
+
var _audioRef$current2;
|
|
116
|
+
if (!(audioRef !== null && audioRef !== void 0 && (_audioRef$current2 = audioRef.current) !== null && _audioRef$current2 !== void 0 && _audioRef$current2.currentSrc.includes('stream'))) {
|
|
117
|
+
// isStream isn't correct here
|
|
118
|
+
|
|
115
119
|
progressBarRef.current.value = Math.floor(audioRef.current.currentTime);
|
|
116
120
|
}
|
|
117
121
|
progressBarRef.current.style.setProperty('--seek-before-width', "".concat(progressBarRef.current.value / duration * 100, "%"));
|
|
@@ -141,7 +145,8 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
|
|
|
141
145
|
setIsPlaying(true);
|
|
142
146
|
setIsFinishedPlaying(false);
|
|
143
147
|
audioRef.current.play();
|
|
144
|
-
if (!
|
|
148
|
+
if (!audioRef.current.currentSrc.includes('stream')) {
|
|
149
|
+
// isStream isn't correctly set here
|
|
145
150
|
animationRef.current = window.requestAnimationFrame(whilePlaying);
|
|
146
151
|
}
|
|
147
152
|
};
|
|
@@ -298,7 +303,7 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
298
303
|
}, /*#__PURE__*/React__default.createElement("audio", {
|
|
299
304
|
ref: audioPlayerRef,
|
|
300
305
|
src: audioSrc,
|
|
301
|
-
preload: "
|
|
306
|
+
preload: "metadata",
|
|
302
307
|
onLoadedMetadata: onLoadedMetadata,
|
|
303
308
|
muted: isMuted
|
|
304
309
|
}), /*#__PURE__*/React__default.createElement("div", {
|