Commit f331602b by chenwq

录播循环播放

1 parent d87133d4
...@@ -65,7 +65,7 @@ const IMAGES = Object.freeze({ ...@@ -65,7 +65,7 @@ const IMAGES = Object.freeze({
}) })
const TCPlayerConfig = Object.freeze({ const TCPlayerConfig = Object.freeze({
autoplay: true, // 自动播放 autoplay: true, // 自动播放
loop: true, // 循环播放 // loop: false, // 循环播放
muted: true, // 是否静音 muted: true, // 是否静音
controlBar: { // 控制条配置 controlBar: { // 控制条配置
fullscreenToggle: false // 隐藏全屏按钮 fullscreenToggle: false // 隐藏全屏按钮
...@@ -91,7 +91,8 @@ export default { ...@@ -91,7 +91,8 @@ export default {
videoStyle: '', videoStyle: '',
isSmallBox: false, //是否显示小容器直播 isSmallBox: false, //是否显示小容器直播
LiveProps, LiveProps,
IMAGES IMAGES,
fileIdx: 0
} }
}, },
computed: { computed: {
...@@ -138,14 +139,23 @@ export default { ...@@ -138,14 +139,23 @@ export default {
// console.log('====', { result }); // console.log('====', { result });
this.player.ready(() => { // 设置播放器初始化完成后的回调 this.player.ready(() => { // 设置播放器初始化完成后的回调
this.fixHls() this.fixHls()
const src = this.LiveProps[this.liveDetail.status].isLive ? this.liveDetail.pullWebRtcUrl : (this.liveDetail.liveBroadcastRecordingFileList || [])[0]?.videoUrl const _this = this
const src = this.LiveProps[this.liveDetail.status].isLive ? this.liveDetail.pullWebRtcUrl : (this.liveDetail.liveBroadcastRecordingFileList || [])[this.fileIdx]?.videoUrl
this.player.src(src) this.player.src(src)
this.player.poster() this.player.poster()
this.player.play() // 播放视频 this.player.play() // 播放视频
// this.player.on('error', function (event) { // 录播,视频播放ended
// // 从回调参数 event 中获取事件状态码及相关数据 this.player.on('ended', function (event) {
// console.log(event, 'error-----------') let fileList = _this.liveDetail.liveBroadcastRecordingFileList
// }) if(fileList.length == 1) {
_this.player.play()
return true
}
// 从回调参数 event 中获取事件状态码及相关数据
_this.fileIdx = _this.fileIdx == (fileList.length - 1) ? 0 : _this.fileIdx + 1
_this.player.src(fileList[_this.fileIdx]?.videoUrl)
_this.player.play()
})
this.draggable(document.getElementById('live-box'), this.openFullscreen, 'icon-live-close') this.draggable(document.getElementById('live-box'), this.openFullscreen, 'icon-live-close')
}) })
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!