解决文件上传无法播放问题

This commit is contained in:
神仙都没用 2023-12-15 12:26:11 +08:00
parent bd6ae251e4
commit c8582a7547
3 changed files with 19 additions and 12 deletions

View File

@ -424,6 +424,7 @@ const Table = useTable({
dict: dict.get("occupation"), dict: dict.get("occupation"),
dictColor: true, dictColor: true,
minWidth: 150, minWidth: 150,
dictAllLevels: true, //
// //
search: { search: {

View File

@ -22,8 +22,8 @@
</template> </template>
<!-- 视频 --> <!-- 视频 -->
<template v-else-if="item.type === 'video' && item.url"> <template v-else-if="item.type === 'video'">
<video :ref="setRefs('video')" :src="item.url" /> <video :ref="setRefs('video')" :src="item.url" :key="item.url" />
</template> </template>
<!-- 其他 --> <!-- 其他 -->
@ -42,7 +42,7 @@
<!-- 音频 --> <!-- 音频 -->
<template v-if="item.type === 'audio'"> <template v-if="item.type === 'audio'">
<audio controls :ref="setRefs('audio')"> <audio controls :ref="setRefs('audio')">
<source :src="item.url" type="audio/mpeg" /> <source :src="item.url" type="audio/mpeg" :key="item.url" />
</audio> </audio>
</template> </template>
@ -220,24 +220,30 @@ const media = reactive({
} }
// //
const el = refs[props.item.type!]; let el: HTMLVideoElement | HTMLAudioElement | undefined;
// \ // \
watch( watch(
() => props.item.isPlay, () => props.item.isPlay,
(val) => { (val) => {
if (!el) {
el = refs[props.item.type!];
console.log(el);
//
el?.addEventListener("ended", () => {
media.pause();
});
}
if (val) { if (val) {
el.play(); el?.play();
} else { } else {
el.pause(); el?.pause();
} }
} }
); );
//
el?.addEventListener("ended", () => {
media.pause();
});
} }
}); });

File diff suppressed because one or more lines are too long