mirror of
https://github.com/bytedance/xgplayer.git
synced 2025-04-05 11:18:46 +08:00
fix(xgplayer): 修复伪切片插件loadeddata多次触发引起的回条问题; 在urlchange的时候一次loadeddata监听
This commit is contained in:
parent
c6e60b1370
commit
7d293789d3
@ -63,6 +63,9 @@ const APIS = {
|
||||
return
|
||||
}
|
||||
const ret = this.calcuPosition(offset.time, offset.duration)
|
||||
if (!ret) {
|
||||
return
|
||||
}
|
||||
const style = iSpot.style || {}
|
||||
style.left = `${ret.left}%`
|
||||
style.width = `${ret.width}%`
|
||||
|
@ -372,7 +372,9 @@ export default class ProgressPreview extends Plugin {
|
||||
const totalWidth = progress.root.getBoundingClientRect().width
|
||||
const widthPerSeconds = duration / totalWidth * 6
|
||||
const ret = {}
|
||||
if (time + dur > duration) {
|
||||
if (time > duration) {
|
||||
return null
|
||||
} else if (time + dur > duration) {
|
||||
dur = duration - time
|
||||
}
|
||||
ret.left = time / duration * 100
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { BasePlugin, Events, Util } from '../../plugin'
|
||||
|
||||
/**
|
||||
* 进行事件分段控制
|
||||
*/
|
||||
@ -22,6 +23,7 @@ export default class TimeSegmentsControls extends BasePlugin {
|
||||
this.updateSegments()
|
||||
|
||||
this.on(Events.DURATION_CHANGE, this._onDurationChange)
|
||||
this.on(Events.URL_CHANGE, this._onUrlChange)
|
||||
this.on(Events.LOADED_DATA, this._onLoadedData)
|
||||
|
||||
this.on(Events.TIME_UPDATE, this._onTimeupdate)
|
||||
@ -98,17 +100,14 @@ export default class TimeSegmentsControls extends BasePlugin {
|
||||
|
||||
_onDurationChange = () => {
|
||||
this.updateSegments()
|
||||
// const { currentTime, timeSegments } = this.player
|
||||
// if (!this._checkIfEnabled(timeSegments)) {
|
||||
// return
|
||||
// }
|
||||
// const index = Util.getIndexByTime(currentTime,timeSegments)
|
||||
// const time = Util.getOffsetCurrentTime(currentTime, timeSegments, index)
|
||||
// this.player.offsetCurrentTime = time
|
||||
// this.changeIndex(index, timeSegments)
|
||||
}
|
||||
|
||||
_onLoadedData = () => {
|
||||
_onUrlChange = () => {
|
||||
this.off(Events.LOADED_DATA, this._onceLoadedData)
|
||||
this.once(Events.LOADED_DATA, this._onceLoadedData)
|
||||
}
|
||||
|
||||
_onceLoadedData = () => {
|
||||
// console.log('》》》_onLoadedData')
|
||||
const { timeSegments } = this.player
|
||||
if (!this._checkIfEnabled(timeSegments)) {
|
||||
@ -118,7 +117,6 @@ export default class TimeSegmentsControls extends BasePlugin {
|
||||
this.player.offsetCurrentTime = time
|
||||
this.changeIndex(0, timeSegments)
|
||||
if (this.curPos.start > 0){
|
||||
// console.log('》》》seek6', this.curPos.start)
|
||||
this.player.currentTime = this.curPos.start
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user