編輯查看要點信息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', () => {
...
})
複製代碼