Skip to content

Commit c2f0df4

Browse files
committed
feat: 更新低端浏览器没有globalThis
1 parent 40585b1 commit c2f0df4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/xgplayer-flv/src/adapt/worker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import Media from './media'
66
export default class PlayerWorker {
77
constructor () {
88
this._bindWorkerEvent()
9-
globalThis.inPlayerWorker = true
9+
if (typeof window === 'undefined') {
10+
globalThis.inPlayerWorker = true
11+
}
1012
}
1113

1214
postMessage (type, data = {}) {

packages/xgplayer-streaming-shared/src/mse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class MSE {
246246
const costTime = nowTime() - this._st
247247
this._logger.debug('sourceopen')
248248
ms.removeEventListener('sourceopen', onOpen)
249-
if (!globalThis.inPlayerWorker) {
249+
if (!(typeof window === 'undefined' && globalThis?.inPlayerWorker)) {
250250
URL.revokeObjectURL(media.src)
251251
}
252252
this._openPromise.resolve({costtime: costTime})
@@ -257,7 +257,7 @@ export class MSE {
257257
ms.addEventListener('endstreaming', this._onEndStreaming)
258258
}
259259

260-
if (globalThis.inPlayerWorker) {
260+
if (typeof window === 'undefined' && globalThis?.inPlayerWorker) {
261261
globalThis.postMessage({
262262
type: 'handle', handle: ms.handle
263263
}, [ms.handle])

0 commit comments

Comments
 (0)