Commit 3607f304aef84f35ecf276fa7de7c03596bd7fc9
Merge branch 'dev-ft' into 'main'
fix:修改视频预览 See merge request huang/yun-teng-iot-front!223
Showing
2 changed files
with
72 additions
and
72 deletions
| @@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
| 46 | "cropperjs": "^1.5.12", | 46 | "cropperjs": "^1.5.12", |
| 47 | "crypto-js": "^4.1.1", | 47 | "crypto-js": "^4.1.1", |
| 48 | "echarts": "^5.1.2", | 48 | "echarts": "^5.1.2", |
| 49 | + "hls.js": "^1.0.10", | ||
| 49 | "intro.js": "^4.1.0", | 50 | "intro.js": "^4.1.0", |
| 50 | "jsoneditor": "^9.7.2", | 51 | "jsoneditor": "^9.7.2", |
| 51 | "jwt-decode": "^3.1.2", | 52 | "jwt-decode": "^3.1.2", |
| @@ -65,7 +66,7 @@ | @@ -65,7 +66,7 @@ | ||
| 65 | "vue-json-pretty": "^2.0.4", | 66 | "vue-json-pretty": "^2.0.4", |
| 66 | "vue-router": "^4.0.11", | 67 | "vue-router": "^4.0.11", |
| 67 | "vue-types": "^4.0.3", | 68 | "vue-types": "^4.0.3", |
| 68 | - "vue3-video-play": "^1.3.1-beta.6", | 69 | + "vue3-video-play": "^1.3.1-beta.4", |
| 69 | "xlsx": "^0.17.0" | 70 | "xlsx": "^0.17.0" |
| 70 | }, | 71 | }, |
| 71 | "devDependencies": { | 72 | "devDependencies": { |
| @@ -140,6 +141,20 @@ | @@ -140,6 +141,20 @@ | ||
| 140 | "vue-eslint-parser": "^7.10.0", | 141 | "vue-eslint-parser": "^7.10.0", |
| 141 | "vue-tsc": "^0.2.3" | 142 | "vue-tsc": "^0.2.3" |
| 142 | }, | 143 | }, |
| 144 | + "keywords": [ | ||
| 145 | + "vue 3", | ||
| 146 | + "vue3", | ||
| 147 | + "vue", | ||
| 148 | + "vue3-video-play", | ||
| 149 | + "hlsjs", | ||
| 150 | + "hls.js", | ||
| 151 | + "vue video player", | ||
| 152 | + "vue3 video player", | ||
| 153 | + "video player video", | ||
| 154 | + "video player", | ||
| 155 | + "vue player", | ||
| 156 | + "vue video" | ||
| 157 | + ], | ||
| 143 | "resolutions": { | 158 | "resolutions": { |
| 144 | "//": "Used to install imagemin dependencies, because imagemin may not be installed in China. If it is abroad, you can delete it", | 159 | "//": "Used to install imagemin dependencies, because imagemin may not be installed in China. If it is abroad, you can delete it", |
| 145 | "bin-wrapper": "npm:bin-wrapper-china", | 160 | "bin-wrapper": "npm:bin-wrapper-china", |
| @@ -11,86 +11,71 @@ | @@ -11,86 +11,71 @@ | ||
| 11 | > | 11 | > |
| 12 | <div class="video-sty"> | 12 | <div class="video-sty"> |
| 13 | <div> | 13 | <div> |
| 14 | - <vue3videoPlay :src="videoUrl" ref="videoRef" v-bind="options" :poster="videoPoster" /> | 14 | + <videoPlay |
| 15 | + v-if="showVideo" | ||
| 16 | + ref="video" | ||
| 17 | + style="display: inline-block; width: 100%" | ||
| 18 | + v-bind="options" | ||
| 19 | + /> | ||
| 15 | </div> | 20 | </div> |
| 16 | </div> | 21 | </div> |
| 17 | </BasicModal> | 22 | </BasicModal> |
| 18 | </div> | 23 | </div> |
| 19 | </template> | 24 | </template> |
| 20 | -<script lang="ts"> | ||
| 21 | - import { defineComponent, reactive, ref, nextTick } from 'vue'; | 25 | +<script setup lang="ts"> |
| 26 | + import { ref, nextTick, reactive } from 'vue'; | ||
| 22 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 27 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
| 23 | - import vue3videoPlay from 'vue3-video-play'; // 引入组件 | 28 | + import { videoPlay } from 'vue3-video-play'; // 引入组件 |
| 24 | import 'vue3-video-play/dist/style.css'; // 引入css | 29 | import 'vue3-video-play/dist/style.css'; // 引入css |
| 25 | 30 | ||
| 26 | - export default defineComponent({ | ||
| 27 | - name: 'DialogPreviewVideo', | ||
| 28 | - components: { | ||
| 29 | - BasicModal, | ||
| 30 | - vue3videoPlay, | ||
| 31 | - }, | ||
| 32 | - emits: ['success', 'register'], | ||
| 33 | - setup() { | ||
| 34 | - let options: any = reactive({}); | ||
| 35 | - const videoRef: any = ref(null); | ||
| 36 | - const videoUrl = ref<String>(''); | ||
| 37 | - const videoPoster = ref(''); | ||
| 38 | - const heightNum = ref(800); | ||
| 39 | - const [register] = useModalInner(async (data) => { | ||
| 40 | - if (data) { | ||
| 41 | - if (data.record.videoUrl) { | ||
| 42 | - videoUrl.value = data.record.videoUrl; | ||
| 43 | - nextTick(() => { | ||
| 44 | - /** | ||
| 45 | - * options配置项(使用vue3-video-play插件) | ||
| 46 | - * 新增支持m3u8流视频 | ||
| 47 | - */ | ||
| 48 | - const fileText = data.record?.videoUrl.split('.').pop(); | ||
| 49 | - videoPoster.value = data.record?.avatar; | ||
| 50 | - options.width = '800px'; //播放器高度 | ||
| 51 | - options.height = '500px'; //播放器高度 | ||
| 52 | - options.color = ''; //主题色 | ||
| 53 | - options.type = fileText === 'm3u8' ? 'm3u8' : fileText === 'mp4' ? 'video/mp4' : ''; | ||
| 54 | - options.title = data.record?.name || '无'; //视频名称 | ||
| 55 | - options.src = data.record?.videoUrl || ''; //视频源 | ||
| 56 | - options.muted = false; //静音 | ||
| 57 | - options.webFullScreen = false; | ||
| 58 | - options.speedRate = ['0.75', '1.0', '1.25', '1.5', '2.0']; //播放倍速 | ||
| 59 | - options.autoPlay = false; //自动播放 | ||
| 60 | - options.loop = false; //循环播放 | ||
| 61 | - options.mirror = false; //镜像画面 | ||
| 62 | - options.ligthOff = false; //关灯模式 | ||
| 63 | - options.volume = 0.3; //默认音量大小 | ||
| 64 | - options.control = true; //是否显示控制 | ||
| 65 | - options.controlBtns = [ | ||
| 66 | - 'audioTrack', | ||
| 67 | - 'quality', | ||
| 68 | - 'speedRate', | ||
| 69 | - 'volume', | ||
| 70 | - 'setting', | ||
| 71 | - 'pip', | ||
| 72 | - 'pageFullScreen', | ||
| 73 | - 'fullScreen', | ||
| 74 | - ]; //显示所有按钮, | ||
| 75 | - }); | ||
| 76 | - } | ||
| 77 | - } | ||
| 78 | - }); | ||
| 79 | - const handleCancel = () => { | ||
| 80 | - //关闭暂停播放视频 | ||
| 81 | - videoRef.value.pause(); | ||
| 82 | - }; | ||
| 83 | - return { | ||
| 84 | - register, | ||
| 85 | - handleCancel, | ||
| 86 | - options, | ||
| 87 | - heightNum, | ||
| 88 | - videoPoster, | ||
| 89 | - videoRef, | ||
| 90 | - videoUrl, | ||
| 91 | - }; | ||
| 92 | - }, | 31 | + const heightNum = ref(800); |
| 32 | + const showVideo = ref(false); | ||
| 33 | + const options = reactive({ | ||
| 34 | + width: '800px', | ||
| 35 | + height: '450px', | ||
| 36 | + color: '#409eff', | ||
| 37 | + muted: false, //静音 | ||
| 38 | + webFullScreen: false, | ||
| 39 | + autoPlay: true, //自动播放 | ||
| 40 | + currentTime: 0, | ||
| 41 | + loop: false, //循环播放 | ||
| 42 | + mirror: false, //镜像画面 | ||
| 43 | + ligthOff: false, //关灯模式 | ||
| 44 | + volume: 0.3, //默认音量大小 | ||
| 45 | + control: true, //是否显示控制器 | ||
| 46 | + title: '', //视频名称 | ||
| 47 | + type: 'm3u8', | ||
| 48 | + src: '', //视频源 | ||
| 49 | + controlBtns: [ | ||
| 50 | + 'audioTrack', | ||
| 51 | + 'quality', | ||
| 52 | + 'speedRate', | ||
| 53 | + 'volume', | ||
| 54 | + 'setting', | ||
| 55 | + 'pip', | ||
| 56 | + 'pageFullScreen', | ||
| 57 | + 'fullScreen', | ||
| 58 | + ], | ||
| 93 | }); | 59 | }); |
| 60 | + const video: any = ref(null); | ||
| 61 | + | ||
| 62 | + nextTick(() => { | ||
| 63 | + console.log(video.value); | ||
| 64 | + }); | ||
| 65 | + | ||
| 66 | + const [register] = useModalInner((data) => { | ||
| 67 | + if (data) { | ||
| 68 | + if (data.record.videoUrl) { | ||
| 69 | + showVideo.value = true; | ||
| 70 | + options.src = data.record.videoUrl; | ||
| 71 | + options.autoPlay = true; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + }); | ||
| 75 | + const handleCancel = () => { | ||
| 76 | + //关闭暂停播放视频 | ||
| 77 | + video.value.pause(); | ||
| 78 | + }; | ||
| 94 | </script> | 79 | </script> |
| 95 | <style> | 80 | <style> |
| 96 | .video-sty { | 81 | .video-sty { |