fix audio player js ref error
This commit is contained in:
parent
04a7445f68
commit
315f532719
|
|
@ -60,7 +60,7 @@ const JKAudioPlayer = ({ audioUrl }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const togglePlayPause = (e) => {
|
const togglePlayPause = (e) => {
|
||||||
if (!audio) return;
|
if (!audio || e === "undefined") return;
|
||||||
if (audio.paused) {
|
if (audio.paused) {
|
||||||
audio.play();
|
audio.play();
|
||||||
setIsPlaying(true);
|
setIsPlaying(true);
|
||||||
|
|
@ -70,14 +70,8 @@ const JKAudioPlayer = ({ audioUrl }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onVolumeButtonClick = () => {
|
|
||||||
if (!audio) return;
|
|
||||||
audio.muted = !audio.muted;
|
|
||||||
setIsMuted(audio.muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
const onClickTimeline = (e) => {
|
const onClickTimeline = (e) => {
|
||||||
if (!audio) return;
|
if (!audio || e === "undefined") return;
|
||||||
let timeToSeek = 0;
|
let timeToSeek = 0;
|
||||||
try {
|
try {
|
||||||
let timelineWidth = window.getComputedStyle(audioPlayer.current.querySelector(".timeline")).width;
|
let timelineWidth = window.getComputedStyle(audioPlayer.current.querySelector(".timeline")).width;
|
||||||
|
|
@ -94,7 +88,7 @@ const JKAudioPlayer = ({ audioUrl }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const onVolumeSliderClick = (e) => {
|
const onVolumeSliderClick = (e) => {
|
||||||
if (!audio) return;
|
if (!audio || e === "undefined") return;
|
||||||
let volume = .75;
|
let volume = .75;
|
||||||
try {
|
try {
|
||||||
let sliderWidth = window.getComputedStyle(audioPlayer.current.querySelector(".controls .volume-slider")).width;
|
let sliderWidth = window.getComputedStyle(audioPlayer.current.querySelector(".controls .volume-slider")).width;
|
||||||
|
|
@ -110,7 +104,13 @@ const JKAudioPlayer = ({ audioUrl }) => {
|
||||||
audioPlayer.current.querySelector(".controls .volume-percentage").style.width = volume * 100 + '%';
|
audioPlayer.current.querySelector(".controls .volume-percentage").style.width = volume * 100 + '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeCodeFromNum(num) {
|
const onVolumeButtonClick = () => {
|
||||||
|
if (!audio) return;
|
||||||
|
audio.muted = !audio.muted;
|
||||||
|
setIsMuted(audio.muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getTimeCodeFromNum = (num) => {
|
||||||
let seconds = parseInt(num);
|
let seconds = parseInt(num);
|
||||||
let minutes = parseInt(seconds / 60);
|
let minutes = parseInt(seconds / 60);
|
||||||
seconds -= minutes * 60;
|
seconds -= minutes * 60;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue