Skip to content

Commit

Permalink
fix: 🐛 (xgplayer-hls) 修复播放到结尾一直loading的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
gemxx committed Jun 25, 2024
1 parent 4c1e758 commit fc0c5b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/xgplayer-hls/src/hls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,13 @@ export class Hls extends EventEmitter {
if (this._segmentProcessing || !this.media) return
const { nextSegment, lastSegment } = this._playlist
const { config } = this
const minFrameDuration = 0.016
// Constrain in the range of 0.016 ~ 0.1, 0.016 is the duration of 1 frame at 60fps
const maxBufferThroughout = Math.min(Math.max(lastSegment?.duration || 0, 0.016), 0.1)
// “minFrameDuration / 2” is to handle the media buffer precision deviation problem
const maxBufferThroughout = Math.min(
Math.max(lastSegment?.duration - minFrameDuration / 2 || 0, minFrameDuration),
0.1
)

if (!nextSegment) return

Expand Down

0 comments on commit fc0c5b8

Please sign in to comment.