Failed to set the 'timestampOffset' property on 'SourceBuffer'
kelvin 发布于 2023-09-11

在media source extension api操作中,执行source buffer的append操作可能会出现以下问题,

1、Uncaught DOMException: Failed to set the 'timestampOffset' property on 'SourceBuffer': The timestamp offset may not be set while the SourceBuffer's append state is 'PARSING_MEDIA_SEGMENT'.

2、Uncaught DOMException: Failed to set the 'timestampOffset' property on 'SourceBuffer': This SourceBuffer is still processing an 'appendBuffer' or 'remove' operation.

3、Uncaught DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer is still processing an 'appendBuffer' or 'remove' operation.

第一个问题,主要是在updateend事件回调处理中执行下面两句代码时候发生的错误,把 sourceBuffer.timestampOffset 注释掉就可以,因为是segment模式的数据,所以不需要设置

sourceBuffer.appendBuffer(_loadedBuffers.shift());

 sourceBuffer.timestampOffset = video.duration-0.001;

第三个问题很好解决,只要在updaeend事件中继续appendBuffer就不会再出现,因为两个appendBuffer如果执行挨的很近,第一个执行还没结束,所以要等待上一个结束最好就是监听updateend事件,

第二个问题其实跟第三个问题差不多同样解决,因为设置timestampOffset要等上一个appendBuffer执行完

kelvin
关注 私信
文章
92
关注
0
粉丝
0