@amazon/vinyl 3.0.0 → 3.0.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/index.cjs +22 -22
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +22 -22
- package/dist/index.js.map +2 -2
- package/dist/test/integ.es5.js +54 -54
- package/dist/test/integ.js +114 -22
- package/dist/test/integ.js.map +2 -2
- package/dist/types/current/track/TrackController.d.ts.map +1 -1
- package/dist/types/current/track/TrackController.js +30 -30
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/unit/types/current/track/TrackController.test.js +36 -0
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
package/dist/test/integ.js
CHANGED
|
@@ -15182,7 +15182,7 @@ ${this.lastInitStack}` : "";
|
|
|
15182
15182
|
// src/global/environment.ts
|
|
15183
15183
|
var vinylVersion = parseVersion(
|
|
15184
15184
|
/* istanbul ignore next */
|
|
15185
|
-
"3.0.
|
|
15185
|
+
"3.0.1"
|
|
15186
15186
|
);
|
|
15187
15187
|
|
|
15188
15188
|
// src/global/globalRef.ts
|
|
@@ -23544,36 +23544,36 @@ ${this.lastInitStack}` : "";
|
|
|
23544
23544
|
logDebug(this, "more adbreaks");
|
|
23545
23545
|
return;
|
|
23546
23546
|
}
|
|
23547
|
-
if (adParent.active) {
|
|
23548
|
-
logDebug(this, "no ads began");
|
|
23549
|
-
return;
|
|
23550
|
-
}
|
|
23551
23547
|
const adParentLoad = this._current;
|
|
23552
23548
|
const placement = event.adBreak.placement;
|
|
23553
23549
|
const isPreroll = placement === "preroll";
|
|
23554
23550
|
const isPostroll = placement === "postroll";
|
|
23551
|
+
const noAdBegan = adParent.active;
|
|
23552
|
+
const resumeContent = (startTime) => this.setCurrentTrack(adParent, {
|
|
23553
|
+
config: __spreadProps(__spreadValues({}, adParentLoad.config), { startTime }),
|
|
23554
|
+
isAd: false,
|
|
23555
|
+
checkPreroll: false
|
|
23556
|
+
});
|
|
23555
23557
|
if (isPostroll) {
|
|
23556
23558
|
logDebug(this, "trackEnded after postroll");
|
|
23557
23559
|
this.dispatch("trackEnded", { track: adParentLoad });
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
} else {
|
|
23562
|
-
const startTime = isPreroll ? (_a3 = adParentLoad.config) == null ? void 0 : _a3.startTime : event.resumePosition;
|
|
23563
|
-
this.setCurrentTrack(adParent, {
|
|
23564
|
-
config: __spreadProps(__spreadValues({}, adParentLoad.config), {
|
|
23565
|
-
startTime
|
|
23566
|
-
}),
|
|
23567
|
-
isAd: false,
|
|
23568
|
-
checkPreroll: false
|
|
23569
|
-
});
|
|
23570
|
-
if (isPostroll) {
|
|
23571
|
-
logInfo(this, "queueEnded after postroll ad(s)");
|
|
23572
|
-
this.dispatch("queueEnded", {});
|
|
23573
|
-
} else {
|
|
23574
|
-
playbackController.play().catch(noop);
|
|
23560
|
+
if (this.hasNext()) {
|
|
23561
|
+
this.next();
|
|
23562
|
+
return;
|
|
23575
23563
|
}
|
|
23564
|
+
if (!noAdBegan) resumeContent(event.resumePosition);
|
|
23565
|
+
logInfo(this, "queueEnded after postroll");
|
|
23566
|
+
this.dispatch("queueEnded", {});
|
|
23567
|
+
return;
|
|
23576
23568
|
}
|
|
23569
|
+
if (noAdBegan) {
|
|
23570
|
+
logDebug(this, "no ads began");
|
|
23571
|
+
return;
|
|
23572
|
+
}
|
|
23573
|
+
resumeContent(
|
|
23574
|
+
isPreroll ? (_a3 = adParentLoad.config) == null ? void 0 : _a3.startTime : event.resumePosition
|
|
23575
|
+
);
|
|
23576
|
+
playbackController.play().catch(noop);
|
|
23577
23577
|
})
|
|
23578
23578
|
);
|
|
23579
23579
|
}
|
|
@@ -52136,6 +52136,42 @@ x`);
|
|
|
52136
52136
|
);
|
|
52137
52137
|
expect(trackActivated).toHaveBeenCalledBefore(queueEnded);
|
|
52138
52138
|
});
|
|
52139
|
+
it("ends the track after an empty postroll where no ad ever began", async () => {
|
|
52140
|
+
const [main] = createLoadOptionsList(1);
|
|
52141
|
+
trackController.load(main);
|
|
52142
|
+
await clock.tick();
|
|
52143
|
+
expect(trackController.activeTrack.active).toBeTrue();
|
|
52144
|
+
const trackEnded = createEventSpy(trackController, "trackEnded");
|
|
52145
|
+
const queueEnded = createEventSpy(trackController, "queueEnded");
|
|
52146
|
+
deps.adController.dispatch("adBreakCompleted", {
|
|
52147
|
+
adBreak: adBreak("postroll"),
|
|
52148
|
+
resumePosition: 0
|
|
52149
|
+
});
|
|
52150
|
+
await clock.tick();
|
|
52151
|
+
expect(trackEnded).toHaveBeenCalledWith(
|
|
52152
|
+
objectContaining24({
|
|
52153
|
+
track: objectContaining24({ uri: main.uri })
|
|
52154
|
+
})
|
|
52155
|
+
);
|
|
52156
|
+
expect(queueEnded).toHaveBeenCalled();
|
|
52157
|
+
});
|
|
52158
|
+
it("advances to the next track after an empty postroll where no ad ever began", async () => {
|
|
52159
|
+
var _a3;
|
|
52160
|
+
const list = createLoadOptionsList(2);
|
|
52161
|
+
trackController.load(...list);
|
|
52162
|
+
await clock.tick();
|
|
52163
|
+
expect(trackController.activeTrack.active).toBeTrue();
|
|
52164
|
+
const trackEnded = createEventSpy(trackController, "trackEnded");
|
|
52165
|
+
deps.adController.dispatch("adBreakCompleted", {
|
|
52166
|
+
adBreak: adBreak("postroll"),
|
|
52167
|
+
resumePosition: 0
|
|
52168
|
+
});
|
|
52169
|
+
await clock.tick();
|
|
52170
|
+
expect(trackEnded).toHaveBeenCalledWith(
|
|
52171
|
+
objectContaining24({ track: any29(Object) })
|
|
52172
|
+
);
|
|
52173
|
+
expect((_a3 = trackController.activeTrack) == null ? void 0 : _a3.uri).toBe(list[1].uri);
|
|
52174
|
+
});
|
|
52139
52175
|
it("does not treat a completed midroll ad as the track ending", async () => {
|
|
52140
52176
|
trackController.load(...createLoadOptionsList(1));
|
|
52141
52177
|
const trackEnded = createEventSpy(trackController, "trackEnded");
|
|
@@ -55699,6 +55735,62 @@ x`);
|
|
|
55699
55735
|
).toBeTrue();
|
|
55700
55736
|
expect(await poll(() => player.paused || player.ended, { timeout: 20 })).withContext("player.paused || player.ended").toBeTrue();
|
|
55701
55737
|
});
|
|
55738
|
+
const EMPTY_BREAKS_ASSET = vinylTestAssets.hls.vinyl_ad_breaks_av__empty_breaks_pre_mid_post;
|
|
55739
|
+
it("ends the track after an empty postroll (no ads) instead of hanging", async () => {
|
|
55740
|
+
const player = suite.player;
|
|
55741
|
+
player.load({ type: "hls", uri: EMPTY_BREAKS_ASSET });
|
|
55742
|
+
await poll(() => {
|
|
55743
|
+
var _a3, _b;
|
|
55744
|
+
return ((_b = (_a3 = player.currentTrackAds) == null ? void 0 : _a3.adBreaks.length) != null ? _b : 0) > 0;
|
|
55745
|
+
}, {
|
|
55746
|
+
timeout: 15
|
|
55747
|
+
});
|
|
55748
|
+
const trackEnded = nextEventAsPromise(player, "trackEnded", {
|
|
55749
|
+
filter: (e) => e.track.uri === EMPTY_BREAKS_ASSET,
|
|
55750
|
+
timeout: 40,
|
|
55751
|
+
timeoutMessage: "trackEnded not received for the empty postroll"
|
|
55752
|
+
});
|
|
55753
|
+
const queueEnded = nextEventAsPromise(player, "queueEnded", {
|
|
55754
|
+
timeout: 40,
|
|
55755
|
+
timeoutMessage: "queueEnded not received after the empty postroll"
|
|
55756
|
+
});
|
|
55757
|
+
await player.play().catch(noop);
|
|
55758
|
+
await player.seekTo(Math.max(0, player.duration - 1.5), 1).catch(() => void 0);
|
|
55759
|
+
await trackEnded;
|
|
55760
|
+
await queueEnded;
|
|
55761
|
+
expect(player.currentAd).withContext("no ad played for the empty break").toBeNull();
|
|
55762
|
+
});
|
|
55763
|
+
it("advances to the next track after an empty postroll (no ads)", async () => {
|
|
55764
|
+
var _a3;
|
|
55765
|
+
const player = suite.player;
|
|
55766
|
+
const nextAsset = vinylTestAssets.hls.live_static_video_audio_60s_4s;
|
|
55767
|
+
player.load(
|
|
55768
|
+
{ type: "hls", uri: EMPTY_BREAKS_ASSET },
|
|
55769
|
+
{ type: "hls", uri: nextAsset }
|
|
55770
|
+
);
|
|
55771
|
+
await poll(() => {
|
|
55772
|
+
var _a4, _b;
|
|
55773
|
+
return ((_b = (_a4 = player.currentTrackAds) == null ? void 0 : _a4.adBreaks.length) != null ? _b : 0) > 0;
|
|
55774
|
+
}, {
|
|
55775
|
+
timeout: 15
|
|
55776
|
+
});
|
|
55777
|
+
const firstTrackEnded = nextEventAsPromise(player, "trackEnded", {
|
|
55778
|
+
filter: (e) => e.track.uri === EMPTY_BREAKS_ASSET,
|
|
55779
|
+
timeout: 40,
|
|
55780
|
+
timeoutMessage: "trackEnded not received for the first track"
|
|
55781
|
+
});
|
|
55782
|
+
const nextActivated = nextEventAsPromise(player, "trackActivated", {
|
|
55783
|
+
filter: (e) => e.track.uri === nextAsset,
|
|
55784
|
+
timeout: 40,
|
|
55785
|
+
timeoutMessage: "the next queued track was not activated"
|
|
55786
|
+
});
|
|
55787
|
+
await player.play().catch(noop);
|
|
55788
|
+
await player.seekTo(Math.max(0, player.duration - 1.5), 1).catch(() => void 0);
|
|
55789
|
+
await firstTrackEnded;
|
|
55790
|
+
await nextActivated;
|
|
55791
|
+
expect((_a3 = player.activeTrack) == null ? void 0 : _a3.uri).withContext("advanced to the next queued track").toBe(nextAsset);
|
|
55792
|
+
expect(player.currentAd).withContext("no ad played for the empty break").toBeNull();
|
|
55793
|
+
});
|
|
55702
55794
|
it("does not replay a postroll after it finishes naturally", async () => {
|
|
55703
55795
|
var _a3;
|
|
55704
55796
|
const player = suite.player;
|