stormcloud-video-player 0.6.1 → 0.6.2
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/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +88 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +88 -17
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +88 -17
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +88 -17
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +88 -17
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.cjs +28 -5
- package/lib/sdk/vastAdLayer.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.d.cts +2 -1
- package/lib/sdk/vastManager.d.cts +1 -1
- package/lib/{types-CwDRIvJm.d.cts → types-BYwfSJb5.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +88 -17
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -974,7 +974,7 @@ function resolveBidToVastAd(winner, logPrefix) {
|
|
|
974
974
|
return Promise.resolve(null);
|
|
975
975
|
}
|
|
976
976
|
function createVastAdLayer(contentVideo, options) {
|
|
977
|
-
var _ref, _ref1, _ref2, _ref3;
|
|
977
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
978
978
|
var adPlaying = false;
|
|
979
979
|
var originalMutedState = false;
|
|
980
980
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -983,7 +983,8 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
983
983
|
var continueLiveStreamDuringAds = (_ref = options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) !== null && _ref !== void 0 ? _ref : false;
|
|
984
984
|
var smartTVMode = (_ref1 = options === null || options === void 0 ? void 0 : options.smartTVMode) !== null && _ref1 !== void 0 ? _ref1 : false;
|
|
985
985
|
var singleElementMode = (_ref2 = options === null || options === void 0 ? void 0 : options.singleElementMode) !== null && _ref2 !== void 0 ? _ref2 : false;
|
|
986
|
-
var
|
|
986
|
+
var forceMP4Ads = (_ref3 = options === null || options === void 0 ? void 0 : options.forceMP4Ads) !== null && _ref3 !== void 0 ? _ref3 : smartTVMode || singleElementMode;
|
|
987
|
+
var debug = (_ref4 = options === null || options === void 0 ? void 0 : options.debug) !== null && _ref4 !== void 0 ? _ref4 : false;
|
|
987
988
|
var adVideoElement;
|
|
988
989
|
var adHls;
|
|
989
990
|
var adContainerEl;
|
|
@@ -1054,14 +1055,26 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1054
1055
|
var _ref;
|
|
1055
1056
|
var _scoredFiles_;
|
|
1056
1057
|
if (mediaFiles.length === 0) throw new Error("No media files available");
|
|
1057
|
-
var
|
|
1058
|
-
if (
|
|
1058
|
+
var candidates = mediaFiles;
|
|
1059
|
+
if (forceMP4Ads) {
|
|
1060
|
+
var mp4Only = candidates.filter(function(f) {
|
|
1061
|
+
return !isHlsMediaFile(f);
|
|
1062
|
+
});
|
|
1063
|
+
if (mp4Only.length > 0) {
|
|
1064
|
+
candidates = mp4Only;
|
|
1065
|
+
if (debug) console.log("".concat(LOG, " forceMP4Ads: filtered to ").concat(mp4Only.length, " MP4-only file(s)"));
|
|
1066
|
+
} else if (debug) {
|
|
1067
|
+
console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
var firstFile = candidates[0];
|
|
1071
|
+
if (candidates.length === 1) return firstFile;
|
|
1059
1072
|
var mainQuality = getMainStreamQuality();
|
|
1060
1073
|
if (!mainQuality) {
|
|
1061
1074
|
if (debug) console.log("".concat(LOG, " No main stream quality info, using first media file"));
|
|
1062
1075
|
return firstFile;
|
|
1063
1076
|
}
|
|
1064
|
-
var scoredFiles =
|
|
1077
|
+
var scoredFiles = candidates.map(function(file) {
|
|
1065
1078
|
var widthDiff = Math.abs(file.width - mainQuality.width);
|
|
1066
1079
|
var heightDiff = Math.abs(file.height - mainQuality.height);
|
|
1067
1080
|
var resolutionDiff = widthDiff + heightDiff;
|
|
@@ -1278,6 +1291,16 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1278
1291
|
}
|
|
1279
1292
|
function startPlayback(mediaFile) {
|
|
1280
1293
|
if (!adVideoElement) return;
|
|
1294
|
+
if (singleElementMode && isHlsMediaFile(mediaFile)) {
|
|
1295
|
+
var mp4Fallback = currentAd === null || currentAd === void 0 ? void 0 : currentAd.mediaFiles.find(function(f) {
|
|
1296
|
+
return !isHlsMediaFile(f);
|
|
1297
|
+
});
|
|
1298
|
+
if (mp4Fallback) {
|
|
1299
|
+
if (debug) console.log("".concat(LOG, " singleElementMode: HLS ad blocked, using MP4 fallback"));
|
|
1300
|
+
startNativePlayback(mp4Fallback);
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1281
1304
|
if (isHlsMediaFile(mediaFile)) {
|
|
1282
1305
|
startHlsPlayback(mediaFile);
|
|
1283
1306
|
} else {
|
|
@@ -2948,10 +2971,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2948
2971
|
debug: !!config.debugAdTiming
|
|
2949
2972
|
} : {});
|
|
2950
2973
|
var browserForAdLayer = detectBrowser();
|
|
2974
|
+
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
2951
2975
|
this.adLayer = createVastAdLayer(this.video, {
|
|
2952
2976
|
continueLiveStreamDuringAds: false,
|
|
2953
|
-
smartTVMode:
|
|
2954
|
-
singleElementMode:
|
|
2977
|
+
smartTVMode: isSinglePipeline,
|
|
2978
|
+
singleElementMode: isSinglePipeline,
|
|
2979
|
+
forceMP4Ads: isSinglePipeline,
|
|
2955
2980
|
debug: !!config.debugAdTiming
|
|
2956
2981
|
});
|
|
2957
2982
|
}
|
|
@@ -3597,6 +3622,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3597
3622
|
if (_this.fillerVideo) {
|
|
3598
3623
|
_this.fillerVideo.style.display = "none";
|
|
3599
3624
|
}
|
|
3625
|
+
if (!_this.adLayer.isAdPlaying()) {
|
|
3626
|
+
if (_this.config.debugAdTiming) {
|
|
3627
|
+
console.log("[StormcloudVideoPlayer] Filler video failed \u2014 restoring main video");
|
|
3628
|
+
}
|
|
3629
|
+
_this.adLayer.hidePlaceholder();
|
|
3630
|
+
if (_this.video.paused && _this.video.readyState >= 2) {
|
|
3631
|
+
var _this_video_play;
|
|
3632
|
+
(_this_video_play = _this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3600
3635
|
});
|
|
3601
3636
|
if (this.config.debugAdTiming) {
|
|
3602
3637
|
console.log("[StormcloudVideoPlayer] Showing filler video layer");
|
|
@@ -4313,6 +4348,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4313
4348
|
if (!this.isLiveStream) {
|
|
4314
4349
|
return false;
|
|
4315
4350
|
}
|
|
4351
|
+
if (this.config.singlePipelineMode) {
|
|
4352
|
+
return false;
|
|
4353
|
+
}
|
|
4316
4354
|
var browser = detectBrowser();
|
|
4317
4355
|
if (browser.isSmartTV) {
|
|
4318
4356
|
return false;
|
|
@@ -5463,32 +5501,56 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5463
5501
|
this.video.volume = restoredVolume;
|
|
5464
5502
|
}
|
|
5465
5503
|
var browser = detectBrowser();
|
|
5466
|
-
var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0;
|
|
5504
|
+
var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0 || !!this.config.singlePipelineMode;
|
|
5467
5505
|
if (isSmartTV && this.hls) {
|
|
5468
5506
|
var hlsRef = this.hls;
|
|
5469
5507
|
var savedMuted = restoredMuted;
|
|
5470
5508
|
var savedVolume = restoredVolume;
|
|
5509
|
+
var videoRef = this.video;
|
|
5510
|
+
var debugEnabled = this.config.debugAdTiming;
|
|
5511
|
+
var tryPlay = function tryPlay1(attempt) {
|
|
5512
|
+
var _videoRef_play;
|
|
5513
|
+
if (_this.inAdBreak || _this.adLayer.isAdPlaying()) return;
|
|
5514
|
+
(_videoRef_play = videoRef.play()) === null || _videoRef_play === void 0 ? void 0 : _videoRef_play.catch(function() {
|
|
5515
|
+
if (attempt < 3) {
|
|
5516
|
+
if (debugEnabled) {
|
|
5517
|
+
console.log("[StormcloudVideoPlayer] Smart TV: play() retry ".concat(attempt + 1, "/3 in ").concat(500 * (attempt + 1), "ms"));
|
|
5518
|
+
}
|
|
5519
|
+
setTimeout(function() {
|
|
5520
|
+
return tryPlay(attempt + 1);
|
|
5521
|
+
}, 500 * (attempt + 1));
|
|
5522
|
+
}
|
|
5523
|
+
});
|
|
5524
|
+
};
|
|
5471
5525
|
var onManifestParsedRestore = function onManifestParsedRestore1() {
|
|
5472
5526
|
hlsRef.off(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
|
|
5473
5527
|
if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
|
|
5474
|
-
|
|
5475
|
-
if (
|
|
5476
|
-
if (
|
|
5477
|
-
if (_this.config.debugAdTiming) {
|
|
5528
|
+
if (videoRef.muted !== savedMuted) videoRef.muted = savedMuted;
|
|
5529
|
+
if (Math.abs(videoRef.volume - savedVolume) > 0.01) videoRef.volume = savedVolume;
|
|
5530
|
+
if (debugEnabled) {
|
|
5478
5531
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5479
5532
|
}
|
|
5480
5533
|
hlsRef.startLoad(-1);
|
|
5481
|
-
(
|
|
5482
|
-
if (
|
|
5534
|
+
tryPlay(0);
|
|
5535
|
+
if (debugEnabled) {
|
|
5483
5536
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5484
5537
|
}
|
|
5485
5538
|
}
|
|
5486
5539
|
};
|
|
5487
5540
|
hlsRef.on(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
|
|
5488
|
-
|
|
5489
|
-
if (
|
|
5490
|
-
console.log("[StormcloudVideoPlayer] Smart TV:
|
|
5541
|
+
var pipelineDelayMs = 300;
|
|
5542
|
+
if (debugEnabled) {
|
|
5543
|
+
console.log("[StormcloudVideoPlayer] Smart TV: waiting ".concat(pipelineDelayMs, "ms for hardware pipeline release before re-attach"));
|
|
5491
5544
|
}
|
|
5545
|
+
setTimeout(function() {
|
|
5546
|
+
if (_this.inAdBreak || _this.adLayer.isAdPlaying()) return;
|
|
5547
|
+
if (_this.hls) {
|
|
5548
|
+
_this.hls.attachMedia(_this.video);
|
|
5549
|
+
if (debugEnabled) {
|
|
5550
|
+
console.log("[StormcloudVideoPlayer] Smart TV: re-attached HLS to video element after ad break to restore media pipeline");
|
|
5551
|
+
}
|
|
5552
|
+
}
|
|
5553
|
+
}, pipelineDelayMs);
|
|
5492
5554
|
} else {
|
|
5493
5555
|
if (this.shouldContinueLiveStreamDuringAds()) {
|
|
5494
5556
|
var _this_video_play;
|
|
@@ -5562,6 +5624,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5562
5624
|
}
|
|
5563
5625
|
this.showPlaceholderLayer();
|
|
5564
5626
|
this.adLayer.showPlaceholder();
|
|
5627
|
+
} else if (this.inAdBreak) {
|
|
5628
|
+
if (this.config.debugAdTiming) {
|
|
5629
|
+
console.log("[CONTINUOUS-FETCH] Ad failure with no filler \u2014 restoring main video temporarily");
|
|
5630
|
+
}
|
|
5631
|
+
this.adLayer.hidePlaceholder();
|
|
5632
|
+
if (!this.adLayer.isAdPlaying() && this.video.paused && this.video.readyState >= 2) {
|
|
5633
|
+
var _this_video_play;
|
|
5634
|
+
(_this_video_play = this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
|
|
5635
|
+
}
|
|
5565
5636
|
}
|
|
5566
5637
|
}
|
|
5567
5638
|
},
|