From 3d37cec36bb5aad916f494f1651fa2040b8c0a0d Mon Sep 17 00:00:00 2001 From: gemstone Date: Wed, 15 May 2024 13:57:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20(xgplayer-hls)=20MSE?= =?UTF-8?q?=20ChangeType=E4=B8=8D=E6=94=AF=E6=8C=81=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8A=9B=E5=87=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/xgplayer-hls/src/hls/buffer-service/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/xgplayer-hls/src/hls/buffer-service/index.js b/packages/xgplayer-hls/src/hls/buffer-service/index.js index f7e132d2..652f0f51 100644 --- a/packages/xgplayer-hls/src/hls/buffer-service/index.js +++ b/packages/xgplayer-hls/src/hls/buffer-service/index.js @@ -165,7 +165,7 @@ export class BufferService { if (needInit && !isFirstAppend) { // handle codec change during midstream - this._handleCodecChange(video, audio) + this._handleCodecChange(video, audio).forEach(task => p.push(task)) } if (video) { @@ -269,6 +269,7 @@ export class BufferService { * @private */ _handleCodecChange (video, audio) { + const tasks = [] const mse = this._mse const codecList = [{ type: MSE.VIDEO, @@ -283,10 +284,13 @@ export class BufferService { if (sourceBuffer) { const codec = codecs.split(',')[0] if (!new RegExp(codec, 'ig').test(sourceBuffer.mimeType)) { - mse.changeType(type, `${type}/mp4;codecs=${codecs}`) + tasks.push( + mse.changeType(type, `${type}/mp4;codecs=${codecs}`) + ) } } }) + return tasks } seamlessSwitch () {