fix: wavesurfer (#699)

This commit is contained in:
一万 2023-08-30 21:47:53 +08:00 committed by GitHub
parent 9bb8820025
commit 967a9d4507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,8 +16,10 @@ const vTippy = tippy;
const loading = ref(true);
const wavesurfer = ref(null);
const wavesurferRef = ref();
//
// mm:ss
const totalTime = ref();
//
const totalSecondTime = ref();
//
const curTime = ref();
//
@ -44,17 +46,19 @@ function init() {
//
wavesurfer.value.on("ready", () => {
if (!wavesurfer.value) return;
const { duration } = wavesurfer.value;
const { m, s } = getTime(duration);
const { decodedData } = wavesurfer.value;
totalSecondTime.value = decodedData.duration;
const { m, s } = getTime(decodedData.duration);
totalTime.value = `${m}:${s}`;
//
wavesurfer.value.setTime(duration / 2);
wavesurfer.value.setTime(decodedData.duration / 2);
// 0-1
// wavesurfer.value.setVolume(1);
});
//
wavesurfer.value.on("timeupdate", timer => {
if (timer > totalSecondTime.value) return;
const { m, s } = getTime(timer);
curTime.value = `${m}:${s}`;
});