From 6bacba47ecbc173ada8431a133807a2d6d8d6bf9 Mon Sep 17 00:00:00 2001 From: zzzhr Date: Tue, 27 Aug 2024 23:13:11 +0800 Subject: [PATCH] set Mp4Plugin support Apple's MMS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix issue https://github.com/bytedance/xgplayer/issues/1578 使MP4插件支持苹果ios17 的MMS。 默认关闭 需要在配置中打开: { plugins: [Mp4Plugin], // set mp4Plugin support Apple's MMS mp4Plugin: { preferMMS: true } } --- fixtures/mp4/index.html | 9 ++++++++- packages/xgplayer-mp4/src/mp4.js | 4 +++- packages/xgplayer-mp4/src/mp4Plugin.js | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fixtures/mp4/index.html b/fixtures/mp4/index.html index 9a26fd8a..b821fc48 100644 --- a/fixtures/mp4/index.html +++ b/fixtures/mp4/index.html @@ -95,7 +95,14 @@ // }, height: window.innerHeight -300, width: window.innerWidth, - // plugins: [Mp4Plugin] + preferMMS: true, + waitingInBufferTimeOut: 5001, + //plugins: [Mp4Plugin], + + // set mp4Plugin support Apple's MMS + //mp4Plugin: { + // preferMMS: true, + //} }); window.player = player diff --git a/packages/xgplayer-mp4/src/mp4.js b/packages/xgplayer-mp4/src/mp4.js index 4d9b5a6e..2d7e6478 100644 --- a/packages/xgplayer-mp4/src/mp4.js +++ b/packages/xgplayer-mp4/src/mp4.js @@ -27,7 +27,8 @@ class MP4 extends EventEmitter { enableWorker: false, playerId: '', vid: '', - ext: {} + ext: {}, + preferMMS: false } } /** @@ -66,6 +67,7 @@ class MP4 extends EventEmitter { retryDelay: this.options.retryDelay, timeout: this.options.timeout, ...options.reqOptions, + preferMMS: this.options.preferMMS, openLog: checkOpenLog() }) this.fMP4Demuxer = null diff --git a/packages/xgplayer-mp4/src/mp4Plugin.js b/packages/xgplayer-mp4/src/mp4Plugin.js index 56120fa3..c9e00895 100644 --- a/packages/xgplayer-mp4/src/mp4Plugin.js +++ b/packages/xgplayer-mp4/src/mp4Plugin.js @@ -34,7 +34,8 @@ export default class Mp4Plugin extends BasePlugin { waitJampBufferMaxCnt:3, tickInSeconds: 0.1, reqOptions: null, - closeDowngrade: false + closeDowngrade: false, + preferMMS: false } } @@ -381,7 +382,8 @@ export default class Mp4Plugin extends BasePlugin { } const contentTypes = { [MSE.VIDEO]: { mimeType: 'video/mp4', codec } } - this.mse = new MSE() + + this.mse = new MSE(null, { preferMMS: this.config.preferMMS }) const openPromise = this.mse.bindMedia(this.player.video) openPromise.then(()=> { const contentTypesLocal = Object.keys(contentTypes)