Unverified 提交 b7a39957 authored 作者: 王嘉豪's avatar 王嘉豪 提交者: GitHub

Merge pull request #1213 from dataease/pr@dev@refactor_panel-video

refactor:优化视频拖拽效果
...@@ -61,8 +61,18 @@ export default { ...@@ -61,8 +61,18 @@ export default {
] ]
} }
}, },
watch: {
linkInfo: {
handler: function() {
this.init()
},
deep: true
}
},
created() {
this.init()
},
mounted() { mounted() {
this.linkInfoTemp = deepCopy(this.linkInfo)
}, },
computed: { computed: {
...mapState([ ...mapState([
...@@ -70,6 +80,9 @@ export default { ...@@ -70,6 +80,9 @@ export default {
]) ])
}, },
methods: { methods: {
init() {
this.linkInfoTemp = deepCopy(this.linkInfo)
},
onSubmit() { onSubmit() {
this.curComponent.videoLinks = this.linkInfoTemp this.curComponent.videoLinks = this.linkInfoTemp
this.$store.state.styleChangeTimes++ this.$store.state.styleChangeTimes++
......
<template> <template>
<el-row ref="mainPlayer"> <el-row ref="mainPlayer">
<div v-if="this.element.videoLinks[this.element.videoLinks.videoType].sources[0].src" class="player"> <div v-if="this.element.videoLinks[this.element.videoLinks.videoType].sources[0].src" :class="{'move-bg':moveFlag}" class="player">
<video-player <video-player
v-if="!moveFlag"
ref="videoPlayer" ref="videoPlayer"
class="vjs-custom-skin" class="vjs-custom-skin"
:options="playerOptions" :options="playerOptions"
...@@ -62,13 +63,16 @@ export default { ...@@ -62,13 +63,16 @@ export default {
} }
}, },
computed: { computed: {
moveFlag() {
return (this.element.optStatus.dragging || this.element.optStatus.resizing)
},
player() { player() {
return this.$refs.videoPlayer.player return this.$refs.videoPlayer.player
}, },
playerOptions() { playerOptions() {
const videoPlayerOptions = this.element.videoLinks[this.element.videoLinks.videoType] const videoPlayerOptions = this.element.videoLinks[this.element.videoLinks.videoType]
let playHeight = this.h let playHeight = this.h
if (this.canvasStyleData.panel.gap) { if (this.canvasStyleData.panel.gap === 'yes') {
playHeight = this.h - (this.componentGap * 2) playHeight = this.h - (this.componentGap * 2)
} }
videoPlayerOptions.height = playHeight videoPlayerOptions.height = playHeight
...@@ -82,26 +86,6 @@ export default { ...@@ -82,26 +86,6 @@ export default {
]) ])
}, },
mounted() { mounted() {
// console.log('this is current player instance object', this.player)
setTimeout(() => {
console.log('dynamic change options', this.player)
// change src
// this.playerOptions.sources[0].src = 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm';
// change item
// this.$set(this.playerOptions.sources, 0, {
// type: "video/mp4",
// src: 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm',
// })
// change array
// this.playerOptions.sources = [{
// type: "video/mp4",
// src: 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm',
// }]
this.player.muted(false)
}, 5000)
}, },
methods: { methods: {
// listen event // listen event
...@@ -142,7 +126,7 @@ export default { ...@@ -142,7 +126,7 @@ export default {
// player is ready // player is ready
playerReadied(player) { playerReadied(player) {
// seek to 10s // seek to 10s
console.log('example player 1 readied', player) // console.log('example player 1 readied', player)
// player.currentTime(10): the player is readied', player) // player.currentTime(10): the player is readied', player)
} }
} }
...@@ -160,5 +144,10 @@ export default { ...@@ -160,5 +144,10 @@ export default {
font-size: 12px; font-size: 12px;
color: #9ea6b2; color: #9ea6b2;
} }
.move-bg {
height: 100%;
width: 100%;
background-color: #000000;
}
</style> </style>
...@@ -29,6 +29,11 @@ export const VIDEOLINKS = { ...@@ -29,6 +29,11 @@ export const VIDEOLINKS = {
muted: true, muted: true,
loop: true, loop: true,
controlBar: { controlBar: {
timeDivider: false,
durationDisplay: false,
remainingTimeDisplay: false,
currentTimeDisplay: false, // 当前时间
volumeControl: false, // 声音控制键
fullscreenToggle: false fullscreenToggle: false
}, },
sources: [{ sources: [{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论