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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { S as StormcloudVideoPlayerConfig } from '../types-
|
|
2
|
+
import { S as StormcloudVideoPlayerConfig } from '../types-BYwfSJb5.cjs';
|
|
3
3
|
|
|
4
4
|
interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
|
|
5
5
|
onMount?: (player: any) => void;
|
package/lib/players/index.cjs
CHANGED
|
@@ -1010,7 +1010,7 @@ function resolveBidToVastAd(winner, logPrefix) {
|
|
|
1010
1010
|
return Promise.resolve(null);
|
|
1011
1011
|
}
|
|
1012
1012
|
function createVastAdLayer(contentVideo, options) {
|
|
1013
|
-
var _ref, _ref1, _ref2, _ref3;
|
|
1013
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
1014
1014
|
var adPlaying = false;
|
|
1015
1015
|
var originalMutedState = false;
|
|
1016
1016
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -1019,7 +1019,8 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1019
1019
|
var continueLiveStreamDuringAds = (_ref = options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) !== null && _ref !== void 0 ? _ref : false;
|
|
1020
1020
|
var smartTVMode = (_ref1 = options === null || options === void 0 ? void 0 : options.smartTVMode) !== null && _ref1 !== void 0 ? _ref1 : false;
|
|
1021
1021
|
var singleElementMode = (_ref2 = options === null || options === void 0 ? void 0 : options.singleElementMode) !== null && _ref2 !== void 0 ? _ref2 : false;
|
|
1022
|
-
var
|
|
1022
|
+
var forceMP4Ads = (_ref3 = options === null || options === void 0 ? void 0 : options.forceMP4Ads) !== null && _ref3 !== void 0 ? _ref3 : smartTVMode || singleElementMode;
|
|
1023
|
+
var debug = (_ref4 = options === null || options === void 0 ? void 0 : options.debug) !== null && _ref4 !== void 0 ? _ref4 : false;
|
|
1023
1024
|
var adVideoElement;
|
|
1024
1025
|
var adHls;
|
|
1025
1026
|
var adContainerEl;
|
|
@@ -1090,14 +1091,26 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1090
1091
|
var _ref;
|
|
1091
1092
|
var _scoredFiles_;
|
|
1092
1093
|
if (mediaFiles.length === 0) throw new Error("No media files available");
|
|
1093
|
-
var
|
|
1094
|
-
if (
|
|
1094
|
+
var candidates = mediaFiles;
|
|
1095
|
+
if (forceMP4Ads) {
|
|
1096
|
+
var mp4Only = candidates.filter(function(f) {
|
|
1097
|
+
return !isHlsMediaFile(f);
|
|
1098
|
+
});
|
|
1099
|
+
if (mp4Only.length > 0) {
|
|
1100
|
+
candidates = mp4Only;
|
|
1101
|
+
if (debug) console.log("".concat(LOG, " forceMP4Ads: filtered to ").concat(mp4Only.length, " MP4-only file(s)"));
|
|
1102
|
+
} else if (debug) {
|
|
1103
|
+
console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
var firstFile = candidates[0];
|
|
1107
|
+
if (candidates.length === 1) return firstFile;
|
|
1095
1108
|
var mainQuality = getMainStreamQuality();
|
|
1096
1109
|
if (!mainQuality) {
|
|
1097
1110
|
if (debug) console.log("".concat(LOG, " No main stream quality info, using first media file"));
|
|
1098
1111
|
return firstFile;
|
|
1099
1112
|
}
|
|
1100
|
-
var scoredFiles =
|
|
1113
|
+
var scoredFiles = candidates.map(function(file) {
|
|
1101
1114
|
var widthDiff = Math.abs(file.width - mainQuality.width);
|
|
1102
1115
|
var heightDiff = Math.abs(file.height - mainQuality.height);
|
|
1103
1116
|
var resolutionDiff = widthDiff + heightDiff;
|
|
@@ -1314,6 +1327,16 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1314
1327
|
}
|
|
1315
1328
|
function startPlayback(mediaFile) {
|
|
1316
1329
|
if (!adVideoElement) return;
|
|
1330
|
+
if (singleElementMode && isHlsMediaFile(mediaFile)) {
|
|
1331
|
+
var mp4Fallback = currentAd === null || currentAd === void 0 ? void 0 : currentAd.mediaFiles.find(function(f) {
|
|
1332
|
+
return !isHlsMediaFile(f);
|
|
1333
|
+
});
|
|
1334
|
+
if (mp4Fallback) {
|
|
1335
|
+
if (debug) console.log("".concat(LOG, " singleElementMode: HLS ad blocked, using MP4 fallback"));
|
|
1336
|
+
startNativePlayback(mp4Fallback);
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1317
1340
|
if (isHlsMediaFile(mediaFile)) {
|
|
1318
1341
|
startHlsPlayback(mediaFile);
|
|
1319
1342
|
} else {
|
|
@@ -2984,10 +3007,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2984
3007
|
debug: !!config.debugAdTiming
|
|
2985
3008
|
} : {});
|
|
2986
3009
|
var browserForAdLayer = detectBrowser();
|
|
3010
|
+
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
2987
3011
|
this.adLayer = createVastAdLayer(this.video, {
|
|
2988
3012
|
continueLiveStreamDuringAds: false,
|
|
2989
|
-
smartTVMode:
|
|
2990
|
-
singleElementMode:
|
|
3013
|
+
smartTVMode: isSinglePipeline,
|
|
3014
|
+
singleElementMode: isSinglePipeline,
|
|
3015
|
+
forceMP4Ads: isSinglePipeline,
|
|
2991
3016
|
debug: !!config.debugAdTiming
|
|
2992
3017
|
});
|
|
2993
3018
|
}
|
|
@@ -3633,6 +3658,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3633
3658
|
if (_this.fillerVideo) {
|
|
3634
3659
|
_this.fillerVideo.style.display = "none";
|
|
3635
3660
|
}
|
|
3661
|
+
if (!_this.adLayer.isAdPlaying()) {
|
|
3662
|
+
if (_this.config.debugAdTiming) {
|
|
3663
|
+
console.log("[StormcloudVideoPlayer] Filler video failed \u2014 restoring main video");
|
|
3664
|
+
}
|
|
3665
|
+
_this.adLayer.hidePlaceholder();
|
|
3666
|
+
if (_this.video.paused && _this.video.readyState >= 2) {
|
|
3667
|
+
var _this_video_play;
|
|
3668
|
+
(_this_video_play = _this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3636
3671
|
});
|
|
3637
3672
|
if (this.config.debugAdTiming) {
|
|
3638
3673
|
console.log("[StormcloudVideoPlayer] Showing filler video layer");
|
|
@@ -4349,6 +4384,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4349
4384
|
if (!this.isLiveStream) {
|
|
4350
4385
|
return false;
|
|
4351
4386
|
}
|
|
4387
|
+
if (this.config.singlePipelineMode) {
|
|
4388
|
+
return false;
|
|
4389
|
+
}
|
|
4352
4390
|
var browser = detectBrowser();
|
|
4353
4391
|
if (browser.isSmartTV) {
|
|
4354
4392
|
return false;
|
|
@@ -5499,32 +5537,56 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5499
5537
|
this.video.volume = restoredVolume;
|
|
5500
5538
|
}
|
|
5501
5539
|
var browser = detectBrowser();
|
|
5502
|
-
var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0;
|
|
5540
|
+
var isSmartTV = browser.tizenVersion !== void 0 || browser.webOSVersion !== void 0 || !!this.config.singlePipelineMode;
|
|
5503
5541
|
if (isSmartTV && this.hls) {
|
|
5504
5542
|
var hlsRef = this.hls;
|
|
5505
5543
|
var savedMuted = restoredMuted;
|
|
5506
5544
|
var savedVolume = restoredVolume;
|
|
5545
|
+
var videoRef = this.video;
|
|
5546
|
+
var debugEnabled = this.config.debugAdTiming;
|
|
5547
|
+
var tryPlay = function tryPlay1(attempt) {
|
|
5548
|
+
var _videoRef_play;
|
|
5549
|
+
if (_this.inAdBreak || _this.adLayer.isAdPlaying()) return;
|
|
5550
|
+
(_videoRef_play = videoRef.play()) === null || _videoRef_play === void 0 ? void 0 : _videoRef_play.catch(function() {
|
|
5551
|
+
if (attempt < 3) {
|
|
5552
|
+
if (debugEnabled) {
|
|
5553
|
+
console.log("[StormcloudVideoPlayer] Smart TV: play() retry ".concat(attempt + 1, "/3 in ").concat(500 * (attempt + 1), "ms"));
|
|
5554
|
+
}
|
|
5555
|
+
setTimeout(function() {
|
|
5556
|
+
return tryPlay(attempt + 1);
|
|
5557
|
+
}, 500 * (attempt + 1));
|
|
5558
|
+
}
|
|
5559
|
+
});
|
|
5560
|
+
};
|
|
5507
5561
|
var onManifestParsedRestore = function onManifestParsedRestore1() {
|
|
5508
5562
|
hlsRef.off(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
|
|
5509
5563
|
if (!_this.inAdBreak && !_this.adLayer.isAdPlaying()) {
|
|
5510
|
-
|
|
5511
|
-
if (
|
|
5512
|
-
if (
|
|
5513
|
-
if (_this.config.debugAdTiming) {
|
|
5564
|
+
if (videoRef.muted !== savedMuted) videoRef.muted = savedMuted;
|
|
5565
|
+
if (Math.abs(videoRef.volume - savedVolume) > 0.01) videoRef.volume = savedVolume;
|
|
5566
|
+
if (debugEnabled) {
|
|
5514
5567
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5515
5568
|
}
|
|
5516
5569
|
hlsRef.startLoad(-1);
|
|
5517
|
-
(
|
|
5518
|
-
if (
|
|
5570
|
+
tryPlay(0);
|
|
5571
|
+
if (debugEnabled) {
|
|
5519
5572
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5520
5573
|
}
|
|
5521
5574
|
}
|
|
5522
5575
|
};
|
|
5523
5576
|
hlsRef.on(import_hls2.default.Events.MANIFEST_PARSED, onManifestParsedRestore);
|
|
5524
|
-
|
|
5525
|
-
if (
|
|
5526
|
-
console.log("[StormcloudVideoPlayer] Smart TV:
|
|
5577
|
+
var pipelineDelayMs = 300;
|
|
5578
|
+
if (debugEnabled) {
|
|
5579
|
+
console.log("[StormcloudVideoPlayer] Smart TV: waiting ".concat(pipelineDelayMs, "ms for hardware pipeline release before re-attach"));
|
|
5527
5580
|
}
|
|
5581
|
+
setTimeout(function() {
|
|
5582
|
+
if (_this.inAdBreak || _this.adLayer.isAdPlaying()) return;
|
|
5583
|
+
if (_this.hls) {
|
|
5584
|
+
_this.hls.attachMedia(_this.video);
|
|
5585
|
+
if (debugEnabled) {
|
|
5586
|
+
console.log("[StormcloudVideoPlayer] Smart TV: re-attached HLS to video element after ad break to restore media pipeline");
|
|
5587
|
+
}
|
|
5588
|
+
}
|
|
5589
|
+
}, pipelineDelayMs);
|
|
5528
5590
|
} else {
|
|
5529
5591
|
if (this.shouldContinueLiveStreamDuringAds()) {
|
|
5530
5592
|
var _this_video_play;
|
|
@@ -5598,6 +5660,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5598
5660
|
}
|
|
5599
5661
|
this.showPlaceholderLayer();
|
|
5600
5662
|
this.adLayer.showPlaceholder();
|
|
5663
|
+
} else if (this.inAdBreak) {
|
|
5664
|
+
if (this.config.debugAdTiming) {
|
|
5665
|
+
console.log("[CONTINUOUS-FETCH] Ad failure with no filler \u2014 restoring main video temporarily");
|
|
5666
|
+
}
|
|
5667
|
+
this.adLayer.hidePlaceholder();
|
|
5668
|
+
if (!this.adLayer.isAdPlaying() && this.video.paused && this.video.readyState >= 2) {
|
|
5669
|
+
var _this_video_play;
|
|
5670
|
+
(_this_video_play = this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
|
|
5671
|
+
}
|
|
5601
5672
|
}
|
|
5602
5673
|
}
|
|
5603
5674
|
},
|