aplayer-react
Advanced tools
Comparing version 1.0.1 to 1.0.2-alpha.1
@@ -361,2 +361,5 @@ "use strict"; | ||
const audio = audioElementRef.current = document.createElement("audio"); | ||
if (typeof options?.src !== "undefined") { | ||
audio.src = options.src; | ||
} | ||
if (typeof options?.autoPlay !== "undefined") { | ||
@@ -405,5 +408,7 @@ audio.autoplay = options.autoPlay; | ||
if (audio) { | ||
audio.pause(); | ||
audio.currentTime = 0; | ||
audio.src = src; | ||
if (audio.src !== src) { | ||
audio.pause(); | ||
audio.currentTime = 0; | ||
audio.src = src; | ||
} | ||
try { | ||
@@ -417,13 +422,16 @@ await audioElementRef.current?.play(); | ||
); | ||
const togglePlay = (0, import_react3.useCallback)(() => { | ||
const audio = audioElementRef.current; | ||
if (!audio) { | ||
return; | ||
} | ||
if (audio.paused) { | ||
audio.play(); | ||
} else { | ||
audio.pause(); | ||
} | ||
}, [audioElementRef]); | ||
const togglePlay = (0, import_react3.useCallback)( | ||
(src) => { | ||
const audio = audioElementRef.current; | ||
if (!audio) { | ||
return; | ||
} | ||
if (audio.paused) { | ||
playAudio(src); | ||
} else { | ||
audio.pause(); | ||
} | ||
}, | ||
[audioElementRef, playAudio] | ||
); | ||
const seek = (0, import_react3.useCallback)( | ||
@@ -802,2 +810,3 @@ (second) => { | ||
const audioControl = useAudioControl({ | ||
src: playlist.currentSong.url, | ||
initialVolume: volume, | ||
@@ -858,3 +867,3 @@ autoPlay, | ||
), | ||
onClick: () => audioControl.togglePlay(), | ||
onClick: () => audioControl.togglePlay(playlist.currentSong.url), | ||
children: audioControl.isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SvgPause, {}) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SvgPlay, {}) | ||
@@ -861,0 +870,0 @@ } |
{ | ||
"name": "aplayer-react", | ||
"version": "1.0.1", | ||
"version": "1.0.2-alpha.1", | ||
"description": "The missing APlayer for React applications", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75419
1829
1