stormcloud-video-player 0.8.44 → 0.8.46

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.
@@ -1054,16 +1054,34 @@ function createHlsAdPlayer(contentVideo, options) {
1054
1054
  }
1055
1055
  }, STALL_CHECK_INTERVAL_MS);
1056
1056
  }
1057
+ function releaseAdDecoder() {
1058
+ if (adHls) {
1059
+ adHls.destroy();
1060
+ adHls = void 0;
1061
+ }
1062
+ if (adVideoElement) {
1063
+ adVideoElement.pause();
1064
+ adVideoElement.removeAttribute("src");
1065
+ try {
1066
+ adVideoElement.load();
1067
+ } catch (error) {
1068
+ console.warn("[HlsAdPlayer] adVideoElement.load() threw after src removal:", error);
1069
+ }
1070
+ adVideoElement.remove();
1071
+ adVideoElement = void 0;
1072
+ }
1073
+ if (adContainerEl) {
1074
+ adContainerEl.style.display = "none";
1075
+ adContainerEl.style.pointerEvents = "none";
1076
+ }
1077
+ }
1057
1078
  function handleAdComplete() {
1058
1079
  console.log("[HlsAdPlayer] Handling ad completion");
1059
1080
  clearStallWatchdog();
1060
1081
  adPlaying = false;
1061
1082
  setAdPlayingFlag(false);
1062
1083
  contentVideo.muted = true;
1063
- if (adContainerEl) {
1064
- adContainerEl.style.display = "none";
1065
- adContainerEl.style.pointerEvents = "none";
1066
- }
1084
+ releaseAdDecoder();
1067
1085
  if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
1068
1086
  contentVideo.style.visibility = "visible";
1069
1087
  contentVideo.style.opacity = "1";
@@ -1071,7 +1089,9 @@ function createHlsAdPlayer(contentVideo, options) {
1071
1089
  if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
1072
1090
  if (contentVideo.paused) {
1073
1091
  console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
1074
- contentVideo.play().catch(function() {});
1092
+ contentVideo.play().catch(function(error) {
1093
+ console.error("[HlsAdPlayer] Error resuming content playback in live mode:", error);
1094
+ });
1075
1095
  } else {
1076
1096
  console.log("[HlsAdPlayer] Content video already playing in live mode");
1077
1097
  }
@@ -1084,10 +1104,7 @@ function createHlsAdPlayer(contentVideo, options) {
1084
1104
  adPlaying = false;
1085
1105
  setAdPlayingFlag(false);
1086
1106
  contentVideo.muted = true;
1087
- if (adContainerEl) {
1088
- adContainerEl.style.display = "none";
1089
- adContainerEl.style.pointerEvents = "none";
1090
- }
1107
+ releaseAdDecoder();
1091
1108
  if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
1092
1109
  contentVideo.style.visibility = "visible";
1093
1110
  contentVideo.style.opacity = "1";
@@ -1296,29 +1313,17 @@ function createHlsAdPlayer(contentVideo, options) {
1296
1313
  contentVideo.muted = originalMutedState;
1297
1314
  contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1298
1315
  console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1299
- if (adContainerEl) {
1300
- adContainerEl.style.display = "none";
1301
- adContainerEl.style.pointerEvents = "none";
1302
- }
1316
+ releaseAdDecoder();
1303
1317
  contentVideo.style.visibility = "visible";
1304
1318
  contentVideo.style.opacity = "1";
1305
1319
  if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
1306
1320
  if (contentVideo.paused) {
1307
1321
  console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback on stop");
1308
- contentVideo.play().catch(function() {});
1322
+ contentVideo.play().catch(function(error) {
1323
+ console.error("[HlsAdPlayer] Error resuming content playback in live mode on stop:", error);
1324
+ });
1309
1325
  }
1310
1326
  }
1311
- if (adHls) {
1312
- adHls.destroy();
1313
- adHls = void 0;
1314
- }
1315
- if (adVideoElement) {
1316
- adVideoElement.pause();
1317
- adVideoElement.removeAttribute("src");
1318
- try {
1319
- adVideoElement.load();
1320
- } catch (unused) {}
1321
- }
1322
1327
  currentAd = void 0;
1323
1328
  podAds = [];
1324
1329
  podIndex = 0;
@@ -1357,19 +1362,7 @@ function createHlsAdPlayer(contentVideo, options) {
1357
1362
  setAdPlayingFlag(false);
1358
1363
  contentVideo.muted = originalMutedState;
1359
1364
  contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1360
- if (adHls) {
1361
- adHls.destroy();
1362
- adHls = void 0;
1363
- }
1364
- if (adVideoElement) {
1365
- adVideoElement.pause();
1366
- adVideoElement.removeAttribute("src");
1367
- try {
1368
- adVideoElement.load();
1369
- } catch (unused) {}
1370
- adVideoElement.remove();
1371
- adVideoElement = void 0;
1372
- }
1365
+ releaseAdDecoder();
1373
1366
  if (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.parentElement) {
1374
1367
  adContainerEl.parentElement.removeChild(adContainerEl);
1375
1368
  }