du
2025-04-17 6edb85addb16585e471e90559bba8eb252f77a6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<template>
  <el-dialog
    :title="t('myCourse.videoPlayback')"
    v-model="videoDialogVisible"
    width="800px"
    append-to-body
    destroy-on-close
    :close-on-click-modal="false"
  >
    <video width="100%" height="500px" controls :src="videoPath" style="object-fit: contain;">
      <track v-if="subtitlePath" kind="subtitles" :src="subtitlePath" srclang="zh" label="中文" default />
     {{ t('myCourse.videoPlaybackText')}}
    </video>
  </el-dialog>
</template>
 
<script setup name="videoDialog">
import { ref, defineExpose } from 'vue';
const { t } = useI18n() // 国际化
const videoDialogVisible = ref(false);
const videoPath = ref('');
const subtitlePath = ref(''); // 新增字幕路径
 
const open = (videoUrl, subtitleUrl) => {
  videoPath.value = '';
  subtitlePath.value = '';
  videoDialogVisible.value = false;
 
  // Allow DOM update
  setTimeout(() => {
    videoPath.value = videoUrl;
    subtitlePath.value = subtitleUrl || '';
    videoDialogVisible.value = true;
  }, 50);
};
 
 
defineExpose({ open });
</script>
 
<style scoped lang="scss"></style>