mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 17:07:19 +08:00
fix: wavesurfer (#699)
This commit is contained in:
parent
9bb8820025
commit
967a9d4507
@ -16,8 +16,10 @@ const vTippy = tippy;
|
|||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const wavesurfer = ref(null);
|
const wavesurfer = ref(null);
|
||||||
const wavesurferRef = ref();
|
const wavesurferRef = ref();
|
||||||
// 音频总时长
|
// 音频总时长(格式化后 mm:ss)
|
||||||
const totalTime = ref();
|
const totalTime = ref();
|
||||||
|
// 音频总时长(单位秒)
|
||||||
|
const totalSecondTime = ref();
|
||||||
// 音频当前播放位置时长
|
// 音频当前播放位置时长
|
||||||
const curTime = ref();
|
const curTime = ref();
|
||||||
// 音频是否正在播放
|
// 音频是否正在播放
|
||||||
@ -44,17 +46,19 @@ function init() {
|
|||||||
// 当音频已解码并可以播放时触发
|
// 当音频已解码并可以播放时触发
|
||||||
wavesurfer.value.on("ready", () => {
|
wavesurfer.value.on("ready", () => {
|
||||||
if (!wavesurfer.value) return;
|
if (!wavesurfer.value) return;
|
||||||
const { duration } = wavesurfer.value;
|
const { decodedData } = wavesurfer.value;
|
||||||
const { m, s } = getTime(duration);
|
totalSecondTime.value = decodedData.duration;
|
||||||
|
const { m, s } = getTime(decodedData.duration);
|
||||||
totalTime.value = `${m}:${s}`;
|
totalTime.value = `${m}:${s}`;
|
||||||
// 光标位置取中
|
// 光标位置取中
|
||||||
wavesurfer.value.setTime(duration / 2);
|
wavesurfer.value.setTime(decodedData.duration / 2);
|
||||||
// 设置音频音量(范围0-1)
|
// 设置音频音量(范围0-1)
|
||||||
// wavesurfer.value.setVolume(1);
|
// wavesurfer.value.setVolume(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 音频位置改变时,播放期间连续触发
|
// 音频位置改变时,播放期间连续触发
|
||||||
wavesurfer.value.on("timeupdate", timer => {
|
wavesurfer.value.on("timeupdate", timer => {
|
||||||
|
if (timer > totalSecondTime.value) return;
|
||||||
const { m, s } = getTime(timer);
|
const { m, s } = getTime(timer);
|
||||||
curTime.value = `${m}:${s}`;
|
curTime.value = `${m}:${s}`;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user