编辑查看要点信息git
const arr = videoData.map((item: any) => {
return {
time: item.time,
text: item.title
}
})
this.player = Video('myvideo', {
controls: true, // 必填,显示各控制组件测试
autoplay: false, // 是否自动播放
preload: 'auto', // 预加载
poster: this.videoData.content.cover, // 视频封面
loop: false, // 是否循环播放
fluid: true,
playbackRates: [0.5, 0.75, 1.25 , 1, 1.5, 2], // 是否显示倍速
controlBar: {
volumePanel: {
inline: false // 将音量横向改成纵向
}
},
})
this.player.on('loadeddata', () => {
this.showVideo = true
})
this.player.src({
src: url,
type: 'video/mp4'
})
this.player.markers({
markerTip: {
display: true,
text: (marker: any) => {
return marker.text
},
time: (marker: any) => {
return marker.time
}
},
breakOverlay: {
display: false,
displayTime: 3,
style: {
'width': '100%',
'height': '20%',
'background-color': 'red',
'color': 'white',
'font-size': '17px'
},
text: (marker: any) => {
return 'Break overlay: ' + marker.overlayText
}
},
markerStyle: {
// 标记样式
'width': '0.7em',
'height': '0.7em',
'bottom': '-0.2em',
'border-radius': '50%',
'background-color': '#5584FF',
'z-index': '100',
'position': 'absolute'
},
onMarkerClick: (marker: any) => {
return true
// return false
},
markers: arr
})
复制代码
video..addEventListener('play', () => {
console.log('监听到播放----')
const videoData = {
play: true,
time: myVideo.currentTime
}
this.$emit('play', videoData)
}, false)
<VideoPlayer v-if="showElement('video')" :from="'teacher'" :key="currentVideo" :videoData="videoData" :videoUrl="videoUrl" @play="videoChangeState" />
private videoChangeState(videoData: any) {
this.handleChangeVideo(videoData)
}
public handleChangeVideo(videoData: any) {
const video: IChannelData = {
action: 'video',
data: {
videoData
}
}
this.channelCanvas.emiter.publish(video)
}
复制代码
(data){
if (data.action === 'video') {
if (this.$refs.videoPanel) {
const video = this.$refs.videoPanel as any
video.videoChagestate(data.data.videoData)
}
}
}
private videoChagestate (videoData: any) {
video.currentTime = videoData.time
myVideo.play()
}
复制代码
报错缘由是chrome新特性,内容大体意思是开发者不能利用手中权限去给用户形成噪音干扰,首次加载页面须要用户和audio/video进行交互, 使用muted能够解决github
this.player.on('loadeddata', () => {
...
})
复制代码