shaka-video-element 0.7.0 → 0.7.1
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/dist/shaka-video-element.js +64 -34
- package/package.json +3 -3
|
@@ -31918,6 +31918,7 @@ function CustomMediaMixin(superclass, { tag, is }) {
|
|
|
31918
31918
|
#nativeEl = null;
|
|
31919
31919
|
#childMap = /* @__PURE__ */ new Map();
|
|
31920
31920
|
#childObserver;
|
|
31921
|
+
#slotChangeHandler;
|
|
31921
31922
|
get;
|
|
31922
31923
|
set;
|
|
31923
31924
|
call;
|
|
@@ -31967,11 +31968,15 @@ function CustomMediaMixin(superclass, { tag, is }) {
|
|
|
31967
31968
|
for (const prop of nativeElProps) {
|
|
31968
31969
|
this.#upgradeProperty(prop);
|
|
31969
31970
|
}
|
|
31971
|
+
this.#setupListeners();
|
|
31972
|
+
}
|
|
31973
|
+
#setupListeners() {
|
|
31970
31974
|
this.#childObserver = new MutationObserver(this.#syncMediaChildAttribute.bind(this));
|
|
31971
|
-
this
|
|
31975
|
+
this.#slotChangeHandler = () => this.#syncMediaChildren();
|
|
31976
|
+
this.shadowRoot?.addEventListener("slotchange", this.#slotChangeHandler);
|
|
31972
31977
|
this.#syncMediaChildren();
|
|
31973
31978
|
for (const type of this.constructor.Events) {
|
|
31974
|
-
this.shadowRoot
|
|
31979
|
+
this.shadowRoot?.addEventListener(type, this, true);
|
|
31975
31980
|
}
|
|
31976
31981
|
}
|
|
31977
31982
|
handleEvent(event) {
|
|
@@ -32040,6 +32045,23 @@ function CustomMediaMixin(superclass, { tag, is }) {
|
|
|
32040
32045
|
}
|
|
32041
32046
|
connectedCallback() {
|
|
32042
32047
|
this.#init();
|
|
32048
|
+
if (!this.#slotChangeHandler) {
|
|
32049
|
+
this.#setupListeners();
|
|
32050
|
+
}
|
|
32051
|
+
}
|
|
32052
|
+
disconnectedCallback() {
|
|
32053
|
+
this.#childObserver?.disconnect();
|
|
32054
|
+
this.#childObserver = void 0;
|
|
32055
|
+
if (this.#slotChangeHandler) {
|
|
32056
|
+
this.shadowRoot?.removeEventListener("slotchange", this.#slotChangeHandler);
|
|
32057
|
+
this.#slotChangeHandler = void 0;
|
|
32058
|
+
}
|
|
32059
|
+
for (const type of this.constructor.Events) {
|
|
32060
|
+
this.shadowRoot?.removeEventListener(type, this, true);
|
|
32061
|
+
}
|
|
32062
|
+
this.#childMap.forEach((clone) => clone.remove());
|
|
32063
|
+
this.#childMap.clear();
|
|
32064
|
+
this.#nativeEl = null;
|
|
32043
32065
|
}
|
|
32044
32066
|
};
|
|
32045
32067
|
}
|
|
@@ -32100,7 +32122,7 @@ function setPrivate(instance, props) {
|
|
|
32100
32122
|
// ../media-tracks/dist/video-track-list.js
|
|
32101
32123
|
function addVideoTrack(media, track) {
|
|
32102
32124
|
const trackList = media.videoTracks;
|
|
32103
|
-
getPrivate(track).media = media;
|
|
32125
|
+
getPrivate(track).media = new WeakRef(media);
|
|
32104
32126
|
if (!getPrivate(track).renditionSet) {
|
|
32105
32127
|
getPrivate(track).renditionSet = /* @__PURE__ */ new Set();
|
|
32106
32128
|
}
|
|
@@ -32119,7 +32141,7 @@ function addVideoTrack(media, track) {
|
|
|
32119
32141
|
});
|
|
32120
32142
|
}
|
|
32121
32143
|
function removeVideoTrack(track) {
|
|
32122
|
-
const trackList = getPrivate(track).media?.videoTracks;
|
|
32144
|
+
const trackList = getPrivate(track).media?.deref()?.videoTracks;
|
|
32123
32145
|
if (!trackList) return;
|
|
32124
32146
|
const trackSet = getPrivate(trackList).trackSet;
|
|
32125
32147
|
trackSet.delete(track);
|
|
@@ -32128,7 +32150,7 @@ function removeVideoTrack(track) {
|
|
|
32128
32150
|
});
|
|
32129
32151
|
}
|
|
32130
32152
|
function selectedChanged(selected) {
|
|
32131
|
-
const trackList = getPrivate(selected).media
|
|
32153
|
+
const trackList = getPrivate(selected).media?.deref()?.videoTracks ?? [];
|
|
32132
32154
|
let hasUnselected = false;
|
|
32133
32155
|
for (const track of trackList) {
|
|
32134
32156
|
if (track === selected) continue;
|
|
@@ -32219,7 +32241,7 @@ var RenditionEvent = class extends Event {
|
|
|
32219
32241
|
|
|
32220
32242
|
// ../media-tracks/dist/video-rendition-list.js
|
|
32221
32243
|
function addRendition(track, rendition) {
|
|
32222
|
-
const renditionList = getPrivate(track).media
|
|
32244
|
+
const renditionList = getPrivate(track).media?.deref()?.videoRenditions;
|
|
32223
32245
|
getPrivate(rendition).media = getPrivate(track).media;
|
|
32224
32246
|
getPrivate(rendition).track = track;
|
|
32225
32247
|
const renditionSet = getPrivate(track).renditionSet;
|
|
@@ -32233,23 +32255,23 @@ function addRendition(track, rendition) {
|
|
|
32233
32255
|
});
|
|
32234
32256
|
}
|
|
32235
32257
|
queueMicrotask(() => {
|
|
32236
|
-
if (!track.selected) return;
|
|
32258
|
+
if (!renditionList || !track.selected) return;
|
|
32237
32259
|
renditionList.dispatchEvent(new RenditionEvent("addrendition", { rendition }));
|
|
32238
32260
|
});
|
|
32239
32261
|
}
|
|
32240
32262
|
function removeRendition(rendition) {
|
|
32241
|
-
const renditionList = getPrivate(rendition).media
|
|
32263
|
+
const renditionList = getPrivate(rendition).media?.deref()?.videoRenditions;
|
|
32242
32264
|
const track = getPrivate(rendition).track;
|
|
32243
32265
|
const renditionSet = getPrivate(track).renditionSet;
|
|
32244
32266
|
renditionSet.delete(rendition);
|
|
32245
32267
|
queueMicrotask(() => {
|
|
32246
32268
|
const track2 = getPrivate(rendition).track;
|
|
32247
|
-
if (!track2.selected) return;
|
|
32269
|
+
if (!renditionList || !track2.selected) return;
|
|
32248
32270
|
renditionList.dispatchEvent(new RenditionEvent("removerendition", { rendition }));
|
|
32249
32271
|
});
|
|
32250
32272
|
}
|
|
32251
32273
|
function selectedChanged2(rendition) {
|
|
32252
|
-
const renditionList = getPrivate(rendition).media
|
|
32274
|
+
const renditionList = getPrivate(rendition).media?.deref()?.videoRenditions;
|
|
32253
32275
|
if (!renditionList || getPrivate(renditionList).changeRequested) return;
|
|
32254
32276
|
getPrivate(renditionList).changeRequested = true;
|
|
32255
32277
|
queueMicrotask(() => {
|
|
@@ -32260,7 +32282,8 @@ function selectedChanged2(rendition) {
|
|
|
32260
32282
|
});
|
|
32261
32283
|
}
|
|
32262
32284
|
function getCurrentRenditions(renditionList) {
|
|
32263
|
-
const media = getPrivate(renditionList).media;
|
|
32285
|
+
const media = getPrivate(renditionList).media?.deref();
|
|
32286
|
+
if (!media) return [];
|
|
32264
32287
|
return [...media.videoTracks].filter((track) => track.selected).flatMap((track) => [...getPrivate(track).renditionSet]);
|
|
32265
32288
|
}
|
|
32266
32289
|
var VideoRenditionList = class extends EventTarget {
|
|
@@ -32380,7 +32403,7 @@ var VideoTrack = class {
|
|
|
32380
32403
|
|
|
32381
32404
|
// ../media-tracks/dist/audio-rendition-list.js
|
|
32382
32405
|
function addRendition2(track, rendition) {
|
|
32383
|
-
const renditionList = getPrivate(track).media
|
|
32406
|
+
const renditionList = getPrivate(track).media?.deref()?.audioRenditions;
|
|
32384
32407
|
getPrivate(rendition).media = getPrivate(track).media;
|
|
32385
32408
|
getPrivate(rendition).track = track;
|
|
32386
32409
|
const renditionSet = getPrivate(track).renditionSet;
|
|
@@ -32394,23 +32417,23 @@ function addRendition2(track, rendition) {
|
|
|
32394
32417
|
});
|
|
32395
32418
|
}
|
|
32396
32419
|
queueMicrotask(() => {
|
|
32397
|
-
if (!track.enabled) return;
|
|
32420
|
+
if (!renditionList || !track.enabled) return;
|
|
32398
32421
|
renditionList.dispatchEvent(new RenditionEvent("addrendition", { rendition }));
|
|
32399
32422
|
});
|
|
32400
32423
|
}
|
|
32401
32424
|
function removeRendition2(rendition) {
|
|
32402
|
-
const renditionList = getPrivate(rendition).media
|
|
32425
|
+
const renditionList = getPrivate(rendition).media?.deref()?.audioRenditions;
|
|
32403
32426
|
const track = getPrivate(rendition).track;
|
|
32404
32427
|
const renditionSet = getPrivate(track).renditionSet;
|
|
32405
32428
|
renditionSet.delete(rendition);
|
|
32406
32429
|
queueMicrotask(() => {
|
|
32407
32430
|
const track2 = getPrivate(rendition).track;
|
|
32408
|
-
if (!track2.enabled) return;
|
|
32431
|
+
if (!renditionList || !track2.enabled) return;
|
|
32409
32432
|
renditionList.dispatchEvent(new RenditionEvent("removerendition", { rendition }));
|
|
32410
32433
|
});
|
|
32411
32434
|
}
|
|
32412
32435
|
function selectedChanged3(rendition) {
|
|
32413
|
-
const renditionList = getPrivate(rendition).media
|
|
32436
|
+
const renditionList = getPrivate(rendition).media?.deref()?.audioRenditions;
|
|
32414
32437
|
if (!renditionList || getPrivate(renditionList).changeRequested) return;
|
|
32415
32438
|
getPrivate(renditionList).changeRequested = true;
|
|
32416
32439
|
queueMicrotask(() => {
|
|
@@ -32421,7 +32444,8 @@ function selectedChanged3(rendition) {
|
|
|
32421
32444
|
});
|
|
32422
32445
|
}
|
|
32423
32446
|
function getCurrentRenditions2(renditionList) {
|
|
32424
|
-
const media = getPrivate(renditionList).media;
|
|
32447
|
+
const media = getPrivate(renditionList).media?.deref();
|
|
32448
|
+
if (!media) return [];
|
|
32425
32449
|
return [...media.audioTracks].filter((track) => track.enabled).flatMap((track) => [...getPrivate(track).renditionSet]);
|
|
32426
32450
|
}
|
|
32427
32451
|
var AudioRenditionList = class extends EventTarget {
|
|
@@ -32506,7 +32530,7 @@ var AudioRendition = class {
|
|
|
32506
32530
|
// ../media-tracks/dist/audio-track-list.js
|
|
32507
32531
|
function addAudioTrack(media, track) {
|
|
32508
32532
|
const trackList = media.audioTracks;
|
|
32509
|
-
getPrivate(track).media = media;
|
|
32533
|
+
getPrivate(track).media = new WeakRef(media);
|
|
32510
32534
|
if (!getPrivate(track).renditionSet) {
|
|
32511
32535
|
getPrivate(track).renditionSet = /* @__PURE__ */ new Set();
|
|
32512
32536
|
}
|
|
@@ -32525,7 +32549,7 @@ function addAudioTrack(media, track) {
|
|
|
32525
32549
|
});
|
|
32526
32550
|
}
|
|
32527
32551
|
function removeAudioTrack(track) {
|
|
32528
|
-
const trackList = getPrivate(track).media?.audioTracks;
|
|
32552
|
+
const trackList = getPrivate(track).media?.deref()?.audioTracks;
|
|
32529
32553
|
if (!trackList) return;
|
|
32530
32554
|
const trackSet = getPrivate(trackList).trackSet;
|
|
32531
32555
|
trackSet.delete(track);
|
|
@@ -32534,7 +32558,7 @@ function removeAudioTrack(track) {
|
|
|
32534
32558
|
});
|
|
32535
32559
|
}
|
|
32536
32560
|
function enabledChanged(track) {
|
|
32537
|
-
const trackList = getPrivate(track).media
|
|
32561
|
+
const trackList = getPrivate(track).media?.deref()?.audioTracks;
|
|
32538
32562
|
if (!trackList || getPrivate(trackList).changeRequested) return;
|
|
32539
32563
|
getPrivate(trackList).changeRequested = true;
|
|
32540
32564
|
queueMicrotask(() => {
|
|
@@ -32690,7 +32714,7 @@ function MediaTracksMixin(MediaElementClass) {
|
|
|
32690
32714
|
let renditions = getPrivate(media).videoRenditions;
|
|
32691
32715
|
if (!renditions) {
|
|
32692
32716
|
renditions = new VideoRenditionList();
|
|
32693
|
-
getPrivate(renditions).media = media;
|
|
32717
|
+
getPrivate(renditions).media = new WeakRef(media);
|
|
32694
32718
|
getPrivate(media).videoRenditions = renditions;
|
|
32695
32719
|
}
|
|
32696
32720
|
return renditions;
|
|
@@ -32706,7 +32730,7 @@ function MediaTracksMixin(MediaElementClass) {
|
|
|
32706
32730
|
let renditions = getPrivate(media).audioRenditions;
|
|
32707
32731
|
if (!renditions) {
|
|
32708
32732
|
renditions = new AudioRenditionList();
|
|
32709
|
-
getPrivate(renditions).media = media;
|
|
32733
|
+
getPrivate(renditions).media = new WeakRef(media);
|
|
32710
32734
|
getPrivate(media).audioRenditions = renditions;
|
|
32711
32735
|
}
|
|
32712
32736
|
return renditions;
|
|
@@ -32728,10 +32752,10 @@ function getVideoTracks(media) {
|
|
|
32728
32752
|
for (const nativeTrack of nativeTracks) {
|
|
32729
32753
|
addVideoTrack(media, nativeTrack);
|
|
32730
32754
|
}
|
|
32731
|
-
|
|
32755
|
+
const onChange = () => {
|
|
32732
32756
|
tracks.dispatchEvent(new Event("change"));
|
|
32733
|
-
}
|
|
32734
|
-
|
|
32757
|
+
};
|
|
32758
|
+
const onAddTrack = (event) => {
|
|
32735
32759
|
if ([...tracks].some((t) => t instanceof VideoTrack)) {
|
|
32736
32760
|
for (const nativeTrack of nativeTracks) {
|
|
32737
32761
|
removeVideoTrack(nativeTrack);
|
|
@@ -32739,10 +32763,13 @@ function getVideoTracks(media) {
|
|
|
32739
32763
|
return;
|
|
32740
32764
|
}
|
|
32741
32765
|
addVideoTrack(media, event.track);
|
|
32742
|
-
}
|
|
32743
|
-
|
|
32766
|
+
};
|
|
32767
|
+
const onRemoveTrack = (event) => {
|
|
32744
32768
|
removeVideoTrack(event.track);
|
|
32745
|
-
}
|
|
32769
|
+
};
|
|
32770
|
+
nativeTracks.addEventListener("change", onChange);
|
|
32771
|
+
nativeTracks.addEventListener("addtrack", onAddTrack);
|
|
32772
|
+
nativeTracks.addEventListener("removetrack", onRemoveTrack);
|
|
32746
32773
|
}
|
|
32747
32774
|
}
|
|
32748
32775
|
return tracks;
|
|
@@ -32757,10 +32784,10 @@ function getAudioTracks(media) {
|
|
|
32757
32784
|
for (const nativeTrack of nativeTracks) {
|
|
32758
32785
|
addAudioTrack(media, nativeTrack);
|
|
32759
32786
|
}
|
|
32760
|
-
|
|
32787
|
+
const onChange = () => {
|
|
32761
32788
|
tracks.dispatchEvent(new Event("change"));
|
|
32762
|
-
}
|
|
32763
|
-
|
|
32789
|
+
};
|
|
32790
|
+
const onAddTrack = (event) => {
|
|
32764
32791
|
if ([...tracks].some((t) => t instanceof AudioTrack)) {
|
|
32765
32792
|
for (const nativeTrack of nativeTracks) {
|
|
32766
32793
|
removeAudioTrack(nativeTrack);
|
|
@@ -32768,10 +32795,13 @@ function getAudioTracks(media) {
|
|
|
32768
32795
|
return;
|
|
32769
32796
|
}
|
|
32770
32797
|
addAudioTrack(media, event.track);
|
|
32771
|
-
}
|
|
32772
|
-
|
|
32798
|
+
};
|
|
32799
|
+
const onRemoveTrack = (event) => {
|
|
32773
32800
|
removeAudioTrack(event.track);
|
|
32774
|
-
}
|
|
32801
|
+
};
|
|
32802
|
+
nativeTracks.addEventListener("change", onChange);
|
|
32803
|
+
nativeTracks.addEventListener("addtrack", onAddTrack);
|
|
32804
|
+
nativeTracks.addEventListener("removetrack", onRemoveTrack);
|
|
32775
32805
|
}
|
|
32776
32806
|
}
|
|
32777
32807
|
return tracks;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaka-video-element",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Custom element (web component) for Shaka Player",
|
|
5
5
|
"author": "@muxinc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"build": "run-s build:*"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"custom-media-element": "^1.4.
|
|
56
|
-
"media-tracks": "^0.3.
|
|
55
|
+
"custom-media-element": "^1.4.6",
|
|
56
|
+
"media-tracks": "^0.3.5",
|
|
57
57
|
"shaka-player": "~4.15.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|