stormcloud-video-player 0.8.45 → 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";
@@ -1086,10 +1104,7 @@ function createHlsAdPlayer(contentVideo, options) {
1086
1104
  adPlaying = false;
1087
1105
  setAdPlayingFlag(false);
1088
1106
  contentVideo.muted = true;
1089
- if (adContainerEl) {
1090
- adContainerEl.style.display = "none";
1091
- adContainerEl.style.pointerEvents = "none";
1092
- }
1107
+ releaseAdDecoder();
1093
1108
  if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
1094
1109
  contentVideo.style.visibility = "visible";
1095
1110
  contentVideo.style.opacity = "1";
@@ -1298,10 +1313,7 @@ function createHlsAdPlayer(contentVideo, options) {
1298
1313
  contentVideo.muted = originalMutedState;
1299
1314
  contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1300
1315
  console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1301
- if (adContainerEl) {
1302
- adContainerEl.style.display = "none";
1303
- adContainerEl.style.pointerEvents = "none";
1304
- }
1316
+ releaseAdDecoder();
1305
1317
  contentVideo.style.visibility = "visible";
1306
1318
  contentVideo.style.opacity = "1";
1307
1319
  if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
@@ -1312,17 +1324,6 @@ function createHlsAdPlayer(contentVideo, options) {
1312
1324
  });
1313
1325
  }
1314
1326
  }
1315
- if (adHls) {
1316
- adHls.destroy();
1317
- adHls = void 0;
1318
- }
1319
- if (adVideoElement) {
1320
- adVideoElement.pause();
1321
- adVideoElement.removeAttribute("src");
1322
- try {
1323
- adVideoElement.load();
1324
- } catch (unused) {}
1325
- }
1326
1327
  currentAd = void 0;
1327
1328
  podAds = [];
1328
1329
  podIndex = 0;
@@ -1361,19 +1362,7 @@ function createHlsAdPlayer(contentVideo, options) {
1361
1362
  setAdPlayingFlag(false);
1362
1363
  contentVideo.muted = originalMutedState;
1363
1364
  contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1364
- if (adHls) {
1365
- adHls.destroy();
1366
- adHls = void 0;
1367
- }
1368
- if (adVideoElement) {
1369
- adVideoElement.pause();
1370
- adVideoElement.removeAttribute("src");
1371
- try {
1372
- adVideoElement.load();
1373
- } catch (unused) {}
1374
- adVideoElement.remove();
1375
- adVideoElement = void 0;
1376
- }
1365
+ releaseAdDecoder();
1377
1366
  if (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.parentElement) {
1378
1367
  adContainerEl.parentElement.removeChild(adContainerEl);
1379
1368
  }