hls.js 1.5.8-0.canary.10161 → 1.5.8-0.canary.10162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "url-toolkit": "2.2.5",
131
131
  "wrangler": "3.45.0"
132
132
  },
133
- "version": "1.5.8-0.canary.10161"
133
+ "version": "1.5.8-0.canary.10162"
134
134
  }
@@ -6,7 +6,10 @@ import {
6
6
  getCodecCompatibleName,
7
7
  pickMostCompleteCodecName,
8
8
  } from '../utils/codecs';
9
- import { getMediaSource } from '../utils/mediasource-helper';
9
+ import {
10
+ getMediaSource,
11
+ isManagedMediaSource,
12
+ } from '../utils/mediasource-helper';
10
13
  import {
11
14
  ElementaryStreamTypes,
12
15
  type Part,
@@ -101,10 +104,10 @@ export default class BufferController extends Logger implements ComponentAPI {
101
104
  super('buffer-controller', hls.logger);
102
105
  this.hls = hls;
103
106
  this.fragmentTracker = fragmentTracker;
104
- this.appendSource =
105
- hls.config.preferManagedMediaSource &&
106
- typeof self !== 'undefined' &&
107
- (self as any).ManagedMediaSource;
107
+ this.appendSource = isManagedMediaSource(
108
+ getMediaSource(hls.config.preferManagedMediaSource),
109
+ );
110
+
108
111
  this._initSourceBuffer();
109
112
  this.registerListeners();
110
113
  }
@@ -207,6 +210,7 @@ export default class BufferController extends Logger implements ComponentAPI {
207
210
  ) {
208
211
  const media = (this.media = data.media);
209
212
  const MediaSource = getMediaSource(this.appendSource);
213
+
210
214
  if (media && MediaSource) {
211
215
  const ms = (this.mediaSource = new MediaSource());
212
216
  this.log(`created media source: ${ms.constructor?.name}`);
@@ -15,3 +15,9 @@ export function getMediaSource(
15
15
  ((self as any).WebKitMediaSource as typeof MediaSource)
16
16
  );
17
17
  }
18
+
19
+ export function isManagedMediaSource(source: typeof MediaSource | undefined) {
20
+ return (
21
+ typeof self !== 'undefined' && source === (self as any).ManagedMediaSource
22
+ );
23
+ }