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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
| <template>
| <el-row ref="mainPlayer">
| <div v-if="element.videoLinks[element.videoLinks.videoType].src" class="player">
| <VideoPlayer :src="playerOptions.src" :options="playerOptions" />
| </div>
| <div v-else class="info-class">
| <span>{{ t('visualization.video_add_tips') }}</span>
| </div>
| </el-row>
| </template>
|
| <script setup lang="ts">
| import { VideoPlayer } from '@videojs-player/vue'
| import 'video.js/dist/video-js.css'
| import { computed, nextTick, reactive, toRefs, watch, onMounted } from 'vue'
| import { useEmitt } from '@/hooks/web/useEmitt'
| import { useI18n } from '@/hooks/web/useI18n'
| const { t } = useI18n()
| const props = defineProps({
| propValue: {
| type: String,
| require: true
| },
| element: {
| type: Object
| },
| editMode: {
| type: String,
| require: false,
| default: 'edit'
| },
| active: {
| type: Boolean,
| require: false,
| default: false
| },
| h: {
| type: Number,
| default: 200
| }
| })
| const state = reactive({
| pOption: {
| height: null
| },
| showVideo: true
| })
| const { element, h } = toRefs(props)
|
| onMounted(() => {
| useEmitt({
| name: 'videoLinksChange-' + element.value.id,
| callback: function () {
| videoLinksChange()
| }
| })
| })
|
| const playerOptions = computed(() => element.value.videoLinks[element.value.videoLinks.videoType])
|
| const videoLinksChange = () => {
| state.showVideo = false
| nextTick(() => {
| state.showVideo = true
| initOption()
| })
| }
|
| const initOption = () => {
| state.pOption = element.value.videoLinks[element.value.videoLinks.videoType]
| state.pOption.height = h.value
| }
| watch(
| () => h.value,
| () => {
| initOption()
| }
| )
| </script>
|
| <style lang="less" scoped>
| .info-class {
| text-align: center;
| width: 100%;
| height: 100%;
| display: flex;
| align-items: center;
| justify-content: center;
| background-color: rgba(255, 255, 255, 0.1);
| font-size: 12px;
| }
|
| .player {
| height: 100%;
| width: 100%;
| display: flex;
| align-items: center;
| background-color: #000000;
| }
|
| .d-player-state {
| display: none;
| }
| </style>
|
|