stormcloud-video-player 0.2.15 → 0.2.16

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.
@@ -21,6 +21,8 @@ declare class StormcloudVideoPlayer {
21
21
  private totalAdsInBreak;
22
22
  private showAds;
23
23
  private isLiveStream;
24
+ private nativeHlsMode;
25
+ private videoSrcProtection;
24
26
  constructor(config: StormcloudVideoPlayerConfig);
25
27
  private createAdPlayer;
26
28
  load(): Promise<void>;
@@ -128,8 +128,19 @@ var FilePlayer = class extends import_react.Component {
128
128
  };
129
129
  };
130
130
  this.play = () => {
131
+ var _a;
131
132
  if (this.props.videoElement) {
132
- this.props.videoElement.play();
133
+ const video = this.props.videoElement;
134
+ const hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
135
+ if (hasValidSource) {
136
+ (_a = video.play()) == null ? void 0 : _a.catch((error) => {
137
+ var _a2, _b;
138
+ console.error("[FilePlayer] Failed to play:", error);
139
+ (_b = (_a2 = this.props).onError) == null ? void 0 : _b.call(_a2, error);
140
+ });
141
+ } else {
142
+ console.warn("[FilePlayer] Cannot play: video has no valid source");
143
+ }
133
144
  }
134
145
  };
135
146
  this.pause = () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/players/FilePlayer.tsx","../../src/patterns.ts"],"sourcesContent":["import { Component } from \"react\";\nimport { canPlay } from \"../patterns\";\n\nexport interface FilePlayerProps {\n src: string;\n videoElement?: HTMLVideoElement;\n onMount?: (player: any) => void;\n onReady?: () => void;\n onPlay?: () => void;\n onPause?: () => void;\n onEnded?: () => void;\n onLoaded?: () => void;\n onError?: (error: any) => void;\n autoplay?: boolean;\n muted?: boolean;\n loop?: boolean;\n controls?: boolean;\n playsInline?: boolean;\n preload?: string;\n poster?: string;\n}\n\nexport default class FilePlayer extends Component<FilePlayerProps> {\n static displayName = \"FilePlayer\";\n\n static canPlay = canPlay.file;\n\n private mounted = false;\n private ready = false;\n\n componentDidMount() {\n this.mounted = true;\n this.load();\n }\n\n componentWillUnmount() {\n this.mounted = false;\n }\n\n componentDidUpdate(prevProps: FilePlayerProps) {\n if (prevProps.src !== this.props.src) {\n this.load();\n }\n }\n\n load = () => {\n if (!this.props.videoElement || !this.props.src) return;\n\n const video = this.props.videoElement;\n\n const handleLoadedMetadata = () => {\n if (this.mounted && !this.ready) {\n this.ready = true;\n this.props.onReady?.();\n }\n };\n\n const handlePlay = () => {\n if (this.mounted) {\n this.props.onPlay?.();\n }\n };\n\n const handlePause = () => {\n if (this.mounted) {\n this.props.onPause?.();\n }\n };\n\n const handleEnded = () => {\n if (this.mounted) {\n this.props.onEnded?.();\n }\n };\n\n const handleError = (error: any) => {\n if (this.mounted) {\n this.props.onError?.(error);\n }\n };\n\n const handleLoadedData = () => {\n if (this.mounted) {\n this.props.onLoaded?.();\n }\n };\n\n video.addEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n video.addEventListener(\"ended\", handleEnded);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", handleLoadedData);\n\n video.src = this.props.src;\n if (this.props.autoplay !== undefined) video.autoplay = this.props.autoplay;\n if (this.props.muted !== undefined) video.muted = this.props.muted;\n if (this.props.loop !== undefined) video.loop = this.props.loop;\n if (this.props.controls !== undefined) video.controls = this.props.controls;\n if (this.props.playsInline !== undefined)\n video.playsInline = this.props.playsInline;\n if (this.props.preload !== undefined)\n video.preload = this.props.preload as \"\" | \"metadata\" | \"none\" | \"auto\";\n if (this.props.poster !== undefined) video.poster = this.props.poster;\n\n this.props.onMount?.(this);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n video.removeEventListener(\"ended\", handleEnded);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", handleLoadedData);\n };\n };\n\n play = () => {\n if (this.props.videoElement) {\n this.props.videoElement.play();\n }\n };\n\n pause = () => {\n if (this.props.videoElement) {\n this.props.videoElement.pause();\n }\n };\n\n stop = () => {\n this.pause();\n if (this.props.videoElement) {\n this.props.videoElement.currentTime = 0;\n }\n };\n\n seekTo = (seconds: number, keepPlaying?: boolean) => {\n if (this.props.videoElement) {\n this.props.videoElement.currentTime = seconds;\n if (!keepPlaying) {\n this.pause();\n }\n }\n };\n\n setVolume = (volume: number) => {\n if (this.props.videoElement) {\n this.props.videoElement.volume = Math.max(0, Math.min(1, volume));\n }\n };\n\n mute = () => {\n if (this.props.videoElement) {\n this.props.videoElement.muted = true;\n }\n };\n\n unmute = () => {\n if (this.props.videoElement) {\n this.props.videoElement.muted = false;\n }\n };\n\n setPlaybackRate = (rate: number) => {\n if (this.props.videoElement && rate > 0) {\n this.props.videoElement.playbackRate = rate;\n }\n };\n\n setLoop = (loop: boolean) => {\n if (this.props.videoElement) {\n this.props.videoElement.loop = loop;\n }\n };\n\n getDuration = (): number | null => {\n if (this.props.videoElement && isFinite(this.props.videoElement.duration)) {\n return this.props.videoElement.duration;\n }\n return null;\n };\n\n getCurrentTime = (): number | null => {\n if (\n this.props.videoElement &&\n isFinite(this.props.videoElement.currentTime)\n ) {\n return this.props.videoElement.currentTime;\n }\n return null;\n };\n\n getSecondsLoaded = (): number | null => {\n if (\n this.props.videoElement &&\n this.props.videoElement.buffered.length > 0\n ) {\n return this.props.videoElement.buffered.end(\n this.props.videoElement.buffered.length - 1\n );\n }\n return null;\n };\n\n getInternalPlayer = (key = \"player\") => {\n if (key === \"video\") return this.props.videoElement;\n return null;\n };\n\n enablePIP = async () => {\n if (\n this.props.videoElement &&\n \"requestPictureInPicture\" in this.props.videoElement\n ) {\n try {\n await (this.props.videoElement as any).requestPictureInPicture();\n } catch (error) {\n console.warn(\"Picture-in-Picture failed:\", error);\n }\n }\n };\n\n disablePIP = async () => {\n if (document.pictureInPictureElement) {\n try {\n await document.exitPictureInPicture();\n } catch (error) {\n console.warn(\"Exit Picture-in-Picture failed:\", error);\n }\n }\n };\n\n render() {\n return null;\n }\n}\n","export const HLS_EXTENSIONS = /\\.(m3u8)($|\\?)/i;\nexport const HLS_PATHS = /\\/hls\\//i;\nexport const DASH_EXTENSIONS = /\\.(mpd)($|\\?)/i;\nexport const VIDEO_EXTENSIONS = /\\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\\?)/i;\nexport const AUDIO_EXTENSIONS = /\\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\\?)/i;\n\nexport const canPlay = {\n hls: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);\n },\n\n dash: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return DASH_EXTENSIONS.test(url);\n },\n\n video: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return VIDEO_EXTENSIONS.test(url);\n },\n\n audio: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return AUDIO_EXTENSIONS.test(url);\n },\n\n file: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;;;ACAnB,IAAM,iBAAiB;AACvB,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AAEzB,IAAM,UAAU;AAAA,EACrB,KAAK,CAAC,QAAyB;AAC7B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,eAAe,KAAK,GAAG,KAAK,UAAU,KAAK,GAAG;AAAA,EACvD;AAAA,EAEA,MAAM,CAAC,QAAyB;AAC9B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,gBAAgB,KAAK,GAAG;AAAA,EAC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AK;AAAA,IACZ;AAAA,EACF;AAAA,EA6LA,SAAS;AACP,WAAO;AAAA,EACT;AACF;AArNqB,WACZ,cAAc;AADF,WAGZ,UAAU,QAAQ;","names":["_a","_b"]}
1
+ {"version":3,"sources":["../../src/players/FilePlayer.tsx","../../src/patterns.ts"],"sourcesContent":["import { Component } from \"react\";\nimport { canPlay } from \"../patterns\";\n\nexport interface FilePlayerProps {\n src: string;\n videoElement?: HTMLVideoElement;\n onMount?: (player: any) => void;\n onReady?: () => void;\n onPlay?: () => void;\n onPause?: () => void;\n onEnded?: () => void;\n onLoaded?: () => void;\n onError?: (error: any) => void;\n autoplay?: boolean;\n muted?: boolean;\n loop?: boolean;\n controls?: boolean;\n playsInline?: boolean;\n preload?: string;\n poster?: string;\n}\n\nexport default class FilePlayer extends Component<FilePlayerProps> {\n static displayName = \"FilePlayer\";\n\n static canPlay = canPlay.file;\n\n private mounted = false;\n private ready = false;\n\n componentDidMount() {\n this.mounted = true;\n this.load();\n }\n\n componentWillUnmount() {\n this.mounted = false;\n }\n\n componentDidUpdate(prevProps: FilePlayerProps) {\n if (prevProps.src !== this.props.src) {\n this.load();\n }\n }\n\n load = () => {\n if (!this.props.videoElement || !this.props.src) return;\n\n const video = this.props.videoElement;\n\n const handleLoadedMetadata = () => {\n if (this.mounted && !this.ready) {\n this.ready = true;\n this.props.onReady?.();\n }\n };\n\n const handlePlay = () => {\n if (this.mounted) {\n this.props.onPlay?.();\n }\n };\n\n const handlePause = () => {\n if (this.mounted) {\n this.props.onPause?.();\n }\n };\n\n const handleEnded = () => {\n if (this.mounted) {\n this.props.onEnded?.();\n }\n };\n\n const handleError = (error: any) => {\n if (this.mounted) {\n this.props.onError?.(error);\n }\n };\n\n const handleLoadedData = () => {\n if (this.mounted) {\n this.props.onLoaded?.();\n }\n };\n\n video.addEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n video.addEventListener(\"ended\", handleEnded);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", handleLoadedData);\n\n video.src = this.props.src;\n if (this.props.autoplay !== undefined) video.autoplay = this.props.autoplay;\n if (this.props.muted !== undefined) video.muted = this.props.muted;\n if (this.props.loop !== undefined) video.loop = this.props.loop;\n if (this.props.controls !== undefined) video.controls = this.props.controls;\n if (this.props.playsInline !== undefined)\n video.playsInline = this.props.playsInline;\n if (this.props.preload !== undefined)\n video.preload = this.props.preload as \"\" | \"metadata\" | \"none\" | \"auto\";\n if (this.props.poster !== undefined) video.poster = this.props.poster;\n\n this.props.onMount?.(this);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n video.removeEventListener(\"ended\", handleEnded);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", handleLoadedData);\n };\n };\n\n play = () => {\n if (this.props.videoElement) {\n const video = this.props.videoElement;\n const hasValidSource =\n video.src ||\n (video.currentSrc && video.currentSrc !== \"\") ||\n video.readyState >= 1;\n\n if (hasValidSource) {\n video.play()?.catch((error) => {\n console.error(\"[FilePlayer] Failed to play:\", error);\n this.props.onError?.(error);\n });\n } else {\n console.warn(\"[FilePlayer] Cannot play: video has no valid source\");\n }\n }\n };\n\n pause = () => {\n if (this.props.videoElement) {\n this.props.videoElement.pause();\n }\n };\n\n stop = () => {\n this.pause();\n if (this.props.videoElement) {\n this.props.videoElement.currentTime = 0;\n }\n };\n\n seekTo = (seconds: number, keepPlaying?: boolean) => {\n if (this.props.videoElement) {\n this.props.videoElement.currentTime = seconds;\n if (!keepPlaying) {\n this.pause();\n }\n }\n };\n\n setVolume = (volume: number) => {\n if (this.props.videoElement) {\n this.props.videoElement.volume = Math.max(0, Math.min(1, volume));\n }\n };\n\n mute = () => {\n if (this.props.videoElement) {\n this.props.videoElement.muted = true;\n }\n };\n\n unmute = () => {\n if (this.props.videoElement) {\n this.props.videoElement.muted = false;\n }\n };\n\n setPlaybackRate = (rate: number) => {\n if (this.props.videoElement && rate > 0) {\n this.props.videoElement.playbackRate = rate;\n }\n };\n\n setLoop = (loop: boolean) => {\n if (this.props.videoElement) {\n this.props.videoElement.loop = loop;\n }\n };\n\n getDuration = (): number | null => {\n if (this.props.videoElement && isFinite(this.props.videoElement.duration)) {\n return this.props.videoElement.duration;\n }\n return null;\n };\n\n getCurrentTime = (): number | null => {\n if (\n this.props.videoElement &&\n isFinite(this.props.videoElement.currentTime)\n ) {\n return this.props.videoElement.currentTime;\n }\n return null;\n };\n\n getSecondsLoaded = (): number | null => {\n if (\n this.props.videoElement &&\n this.props.videoElement.buffered.length > 0\n ) {\n return this.props.videoElement.buffered.end(\n this.props.videoElement.buffered.length - 1\n );\n }\n return null;\n };\n\n getInternalPlayer = (key = \"player\") => {\n if (key === \"video\") return this.props.videoElement;\n return null;\n };\n\n enablePIP = async () => {\n if (\n this.props.videoElement &&\n \"requestPictureInPicture\" in this.props.videoElement\n ) {\n try {\n await (this.props.videoElement as any).requestPictureInPicture();\n } catch (error) {\n console.warn(\"Picture-in-Picture failed:\", error);\n }\n }\n };\n\n disablePIP = async () => {\n if (document.pictureInPictureElement) {\n try {\n await document.exitPictureInPicture();\n } catch (error) {\n console.warn(\"Exit Picture-in-Picture failed:\", error);\n }\n }\n };\n\n render() {\n return null;\n }\n}\n","export const HLS_EXTENSIONS = /\\.(m3u8)($|\\?)/i;\nexport const HLS_PATHS = /\\/hls\\//i;\nexport const DASH_EXTENSIONS = /\\.(mpd)($|\\?)/i;\nexport const VIDEO_EXTENSIONS = /\\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\\?)/i;\nexport const AUDIO_EXTENSIONS = /\\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\\?)/i;\n\nexport const canPlay = {\n hls: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);\n },\n\n dash: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return DASH_EXTENSIONS.test(url);\n },\n\n video: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return VIDEO_EXTENSIONS.test(url);\n },\n\n audio: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return AUDIO_EXTENSIONS.test(url);\n },\n\n file: (url: string): boolean => {\n if (!url || typeof url !== \"string\") return false;\n return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;;;ACAnB,IAAM,iBAAiB;AACvB,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AAEzB,IAAM,UAAU;AAAA,EACrB,KAAK,CAAC,QAAyB;AAC7B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,eAAe,KAAK,GAAG,KAAK,UAAU,KAAK,GAAG;AAAA,EACvD;AAAA,EAEA,MAAM,CAAC,QAAyB;AAC9B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,gBAAgB,KAAK,GAAG;AAAA,EACjC;AAAA,EAEA,OAAO,CAAC,QAAyB;AAC/B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,iBAAiB,KAAK,GAAG;AAAA,EAClC;AAAA,EAEA,OAAO,CAAC,QAAyB;AAC/B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,iBAAiB,KAAK,GAAG;AAAA,EAClC;AAAA,EAEA,MAAM,CAAC,QAAyB;AAC9B,QAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,WAAO,iBAAiB,KAAK,GAAG,KAAK,iBAAiB,KAAK,GAAG;AAAA,EAChE;AACF;;;ADTA,IAAqB,aAArB,cAA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,QAAQ;","names":["_a","_b"]}
@@ -1739,6 +1739,8 @@ var StormcloudVideoPlayer = class {
1739
1739
  this.totalAdsInBreak = 0;
1740
1740
  this.showAds = false;
1741
1741
  this.isLiveStream = false;
1742
+ this.nativeHlsMode = false;
1743
+ this.videoSrcProtection = null;
1742
1744
  initializePolyfills();
1743
1745
  const browserOverrides = getBrowserConfigOverrides();
1744
1746
  this.config = { ...config, ...browserOverrides };
@@ -1759,7 +1761,9 @@ var StormcloudVideoPlayer = class {
1759
1761
  }
1760
1762
  if (adPlayerType === "hls") {
1761
1763
  if (this.config.debugAdTiming) {
1762
- console.log("[StormcloudVideoPlayer] Creating HLS ad player (AdStorm mode)");
1764
+ console.log(
1765
+ "[StormcloudVideoPlayer] Creating HLS ad player (AdStorm mode)"
1766
+ );
1763
1767
  }
1764
1768
  return createHlsAdPlayer(this.video, {
1765
1769
  continueLiveStreamDuringAds,
@@ -1768,7 +1772,9 @@ var StormcloudVideoPlayer = class {
1768
1772
  });
1769
1773
  } else {
1770
1774
  if (this.config.debugAdTiming) {
1771
- console.log("[StormcloudVideoPlayer] Creating Google IMA ad player (Default mode)");
1775
+ console.log(
1776
+ "[StormcloudVideoPlayer] Creating Google IMA ad player (Default mode)"
1777
+ );
1772
1778
  }
1773
1779
  return createImaController(this.video, {
1774
1780
  continueLiveStreamDuringAds
@@ -1792,11 +1798,13 @@ var StormcloudVideoPlayer = class {
1792
1798
  }
1793
1799
  this.initializeTracking();
1794
1800
  if (this.shouldUseNativeHls()) {
1801
+ this.nativeHlsMode = true;
1802
+ this.videoSrcProtection = this.config.src;
1795
1803
  this.video.src = this.config.src;
1796
1804
  this.isLiveStream = (_a = this.config.lowLatencyMode) != null ? _a : false;
1797
1805
  if (this.config.debugAdTiming) {
1798
1806
  console.log(
1799
- "[StormcloudVideoPlayer] allowNativeHls: true - VOD mode detected:",
1807
+ "[StormcloudVideoPlayer] Using native HLS playback - VOD mode:",
1800
1808
  {
1801
1809
  isLive: this.isLiveStream,
1802
1810
  allowNativeHls: this.config.allowNativeHls,
@@ -1944,7 +1952,9 @@ var StormcloudVideoPlayer = class {
1944
1952
  this.ima.initialize();
1945
1953
  this.ima.on("all_ads_completed", () => {
1946
1954
  if (this.config.debugAdTiming) {
1947
- console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received");
1955
+ console.log(
1956
+ "[StormcloudVideoPlayer] IMA all_ads_completed event received"
1957
+ );
1948
1958
  }
1949
1959
  });
1950
1960
  this.ima.on("ad_error", () => {
@@ -2009,13 +2019,31 @@ var StormcloudVideoPlayer = class {
2009
2019
  this.video.addEventListener("timeupdate", () => {
2010
2020
  this.onTimeUpdate(this.video.currentTime);
2011
2021
  });
2022
+ this.video.addEventListener("emptied", () => {
2023
+ if (this.nativeHlsMode && this.videoSrcProtection && !this.ima.isAdPlaying()) {
2024
+ if (this.config.debugAdTiming) {
2025
+ console.log(
2026
+ "[StormcloudVideoPlayer] Video src was cleared, restoring:",
2027
+ this.videoSrcProtection
2028
+ );
2029
+ }
2030
+ const currentTime = this.video.currentTime;
2031
+ const wasPaused = this.video.paused;
2032
+ this.video.src = this.videoSrcProtection;
2033
+ this.video.currentTime = currentTime;
2034
+ if (!wasPaused) {
2035
+ this.video.play().catch(() => {
2036
+ });
2037
+ }
2038
+ }
2039
+ });
2012
2040
  }
2013
2041
  shouldUseNativeHls() {
2014
2042
  const streamType = this.getStreamType();
2015
2043
  if (streamType === "other") {
2016
2044
  return true;
2017
2045
  }
2018
- const canNative = this.video.canPlayType("application/vnd.apple.mpegURL");
2046
+ const canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
2019
2047
  return !!(this.config.allowNativeHls && canNative);
2020
2048
  }
2021
2049
  onId3Tag(tag) {
@@ -2442,10 +2470,7 @@ var StormcloudVideoPlayer = class {
2442
2470
  var _a, _b, _c;
2443
2471
  const vastMode = this.config.vastMode || "default";
2444
2472
  if (this.config.debugAdTiming) {
2445
- console.log(
2446
- "[StormcloudVideoPlayer] VAST mode:",
2447
- vastMode
2448
- );
2473
+ console.log("[StormcloudVideoPlayer] VAST mode:", vastMode);
2449
2474
  }
2450
2475
  if (vastMode === "adstorm") {
2451
2476
  if (!this.config.licenseKey) {
@@ -2563,10 +2588,7 @@ var StormcloudVideoPlayer = class {
2563
2588
  this.currentAdIndex = 0;
2564
2589
  this.totalAdsInBreak = 1;
2565
2590
  if (this.config.debugAdTiming) {
2566
- console.log(
2567
- "[StormcloudVideoPlayer] Using VAST endpoint:",
2568
- vastTagUrl
2569
- );
2591
+ console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2570
2592
  }
2571
2593
  } else if (tags && tags.length > 0) {
2572
2594
  vastTagUrl = tags[0];
@@ -2718,15 +2740,21 @@ var StormcloudVideoPlayer = class {
2718
2740
  await this.ima.requestAds(vastTagUrl);
2719
2741
  try {
2720
2742
  if (this.config.debugAdTiming) {
2721
- console.log("[StormcloudVideoPlayer] Ad request completed, attempting playback");
2743
+ console.log(
2744
+ "[StormcloudVideoPlayer] Ad request completed, attempting playback"
2745
+ );
2722
2746
  }
2723
2747
  await this.ima.play();
2724
2748
  if (this.config.debugAdTiming) {
2725
- console.log("[StormcloudVideoPlayer] Ad playback started successfully");
2749
+ console.log(
2750
+ "[StormcloudVideoPlayer] Ad playback started successfully"
2751
+ );
2726
2752
  }
2727
2753
  } catch (playError) {
2728
2754
  if (this.config.debugAdTiming) {
2729
- console.log("[StormcloudVideoPlayer] No ads available, skipping playback");
2755
+ console.log(
2756
+ "[StormcloudVideoPlayer] No ads available, skipping playback"
2757
+ );
2730
2758
  }
2731
2759
  this.handleAdFailure();
2732
2760
  return;
@@ -2782,7 +2810,9 @@ var StormcloudVideoPlayer = class {
2782
2810
  });
2783
2811
  } else {
2784
2812
  if (this.config.debugAdTiming) {
2785
- console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
2813
+ console.log(
2814
+ "[StormcloudVideoPlayer] Video is already playing, no resume needed"
2815
+ );
2786
2816
  }
2787
2817
  }
2788
2818
  }
@@ -2801,7 +2831,11 @@ var StormcloudVideoPlayer = class {
2801
2831
  if (this.config.debugAdTiming) {
2802
2832
  console.warn(
2803
2833
  "[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
2804
- { paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
2834
+ {
2835
+ paused: this.video.paused,
2836
+ showAds: this.showAds,
2837
+ adPlaying: this.ima.isAdPlaying()
2838
+ }
2805
2839
  );
2806
2840
  }
2807
2841
  this.handleAdFailure();
@@ -3023,10 +3057,20 @@ var HlsPlayer = class extends import_react.Component {
3023
3057
  }
3024
3058
  };
3025
3059
  this.play = () => {
3026
- var _a, _b;
3060
+ var _a, _b, _c;
3027
3061
  if (this.props.videoElement) {
3028
- this.props.videoElement.play();
3029
- (_b = (_a = this.props).onPlay) == null ? void 0 : _b.call(_a);
3062
+ const video = this.props.videoElement;
3063
+ const hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
3064
+ if (hasValidSource) {
3065
+ (_a = video.play()) == null ? void 0 : _a.catch((error) => {
3066
+ var _a2, _b2;
3067
+ console.error("[HlsPlayer] Failed to play:", error);
3068
+ (_b2 = (_a2 = this.props).onError) == null ? void 0 : _b2.call(_a2, error);
3069
+ });
3070
+ (_c = (_b = this.props).onPlay) == null ? void 0 : _c.call(_b);
3071
+ } else {
3072
+ console.warn("[HlsPlayer] Cannot play: video has no valid source");
3073
+ }
3030
3074
  }
3031
3075
  };
3032
3076
  this.pause = () => {