feat(yb-video): 添加倍速播放配置和错误恢复功能
- 新增 playbackRates 属性支持自定义倍速列表 - 增加错误自动恢复机制,处理视频播放错误 - 优化 DOM 查找逻辑,增加延迟和错误处理 - 调整播放器样式和版本号更新 - 修改 edu-core 依赖为本地引用
This commit is contained in:
@@ -254,9 +254,21 @@
|
||||
methods: {
|
||||
dataIdWatcher (newVal) {
|
||||
if ( newVal ) {
|
||||
this.dom = document.querySelector('.rvideo' + newVal)
|
||||
this.domSlot = document.querySelector('.rvideoslot' + newVal)
|
||||
this.init()
|
||||
// 延迟一下再查找 DOM 元素,确保 DOM 已经渲染完成
|
||||
setTimeout(() => {
|
||||
this.dom = document.querySelector('.rvideo' + newVal)
|
||||
this.domSlot = document.querySelector('.rvideoslot' + newVal)
|
||||
// 检查 DOM 元素是否存在
|
||||
if ( this.dom && this.domSlot ) {
|
||||
this.init()
|
||||
} else {
|
||||
console.error('yb-video: DOM 元素未找到,可能渲染失败', {
|
||||
dataId: newVal,
|
||||
dom: this.dom,
|
||||
domSlot: this.domSlot
|
||||
})
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
async init () {
|
||||
@@ -348,8 +360,9 @@
|
||||
parseSrc (path) {
|
||||
// #ifdef H5
|
||||
const isHash = window.location.hash
|
||||
const route = this.dom.getAttribute('data-route')
|
||||
const pathName = isHash ? window.location.pathname : window.location.pathname.replace(route, '')
|
||||
// 安全检查 this.dom 是否存在
|
||||
const route = this.dom ? this.dom.getAttribute('data-route') : ''
|
||||
const pathName = isHash ? window.location.pathname : window.location.pathname.replace(route || '', '')
|
||||
return window.location.origin + pathName + path.substring(1)
|
||||
// #endif
|
||||
// #ifdef APP-VUE
|
||||
@@ -466,6 +479,7 @@
|
||||
workIndex: params.workIndex,
|
||||
subtitles: params.subtitles,
|
||||
subtitleIndex: params.subtitleIndex,
|
||||
playbackRates: params.playbackRates,
|
||||
custom,
|
||||
decoder: {
|
||||
hls: {
|
||||
|
||||
@@ -105,6 +105,16 @@
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
//倍速列表配置
|
||||
playbackRates: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
//是否显示倍速提示
|
||||
showRateTips: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
//循环播放
|
||||
loop: {
|
||||
type: Boolean,
|
||||
@@ -531,6 +541,7 @@
|
||||
muted: this.muted,
|
||||
loop: this.loop,
|
||||
playbackRate: this.playbackRate,
|
||||
playbackRates: this.playbackRates,
|
||||
isLive: this.isLive,
|
||||
header: this.header,
|
||||
controls: this.controls,
|
||||
@@ -785,6 +796,12 @@
|
||||
playbackRate (newVal) {
|
||||
this.setVideo('playbackRate', newVal)
|
||||
},
|
||||
//监听倍速列表
|
||||
playbackRates (newVal) {
|
||||
if (newVal && newVal.length > 0) {
|
||||
this.reloadVideo()
|
||||
}
|
||||
},
|
||||
//监听循环属性
|
||||
loop (newVal) {
|
||||
this.setVideo('loop', newVal)
|
||||
|
||||
Reference in New Issue
Block a user