MSE WebM 在没有结束事件的持续时间之前完成

问题描述

媒体源扩展中的 WebM 有一个奇怪的问题。

视频时长(根据 videoEl.duration)为 8.354999999999999。

视频到达当前时间 = 8.328015 并停止,没有触发任何事件。

MediaSource 的持续时间是 8.403,当我看到的结束时没有触发任何事件。

我找不到视频文件有什么问题。我的代码是相当标准的附加到缓冲区,它适用于其他 WebM。

这是我的代码(在 Redux Saga 中)

while(chunks.length && !complete){
        const event = yield take(sourceBufferEvents)
        console.log(event)
        if(event.type === "updateend"){
            if(loading){
                yield fork(loaded,true)

                while(loading){
                    const event = yield take(videoEvents)

                    if(chunks && event.type === "playing"){
                        loading = false
                        yield fetchNextSegment(asset.id,asset.remoteUrl,sourceBuffer,chunks.shift())
                        videoEvents.close()
                    }
                }
            }
            else {
                yield fetchNextSegment(asset.id,chunks.shift() ) 
                index ++;
            }    
        }
       
        if(total === index){
            // yield mediaSource.endOfStream()
            // complete = true
            while(sourceBuffer.updating){
                console.log(total,index)
            }
            console.log(sourceBuffer.updating)
           
        }
    }

这些事件在 updateEnd 上调用

sourceBuffer.updating 永远不会是假的

我得到 DOMException: Failed to execute 'endOfStream' on 'MediaSource': The 'updating' attribute is true on one or more of this MediaSource's SourceBuffers.

当我尝试结束直播时

解决方法

根据 Kaiido 的评论,我不得不使用 endOfStream 并且我错过了最后的 updateended 事件。