stormcloud-video-player 0.3.46 → 0.3.47

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.
Files changed (2) hide show
  1. package/README.md +135 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -266,6 +266,7 @@ interface StormcloudPlayerProps {
266
266
  showCustomControls?: boolean;
267
267
  licenseKey?: string;
268
268
  adFailsafeTimeoutMs?: number;
269
+ minSegmentsBeforePlay?: number; // Number of segments to buffer before starting playback (default: 2)
269
270
 
270
271
  // Ad player configuration
271
272
  vastMode?: 'adstorm' | 'default'; // VAST mode: 'adstorm' (HLS player + AdStorm VAST endpoint) or 'default' (IMA SDK + /ads/web endpoint) (default: 'default')
@@ -352,6 +353,7 @@ interface StormcloudVideoPlayerConfig {
352
353
  licenseKey?: string; // API authentication key
353
354
  debugAdTiming?: boolean; // Enable debug logging (default: false)
354
355
  adFailsafeTimeoutMs?: number; // Ad timeout in milliseconds (default: 10000)
356
+ minSegmentsBeforePlay?: number; // Number of segments to buffer before starting playback (default: 2)
355
357
 
356
358
  // Ad configuration
357
359
  vastMode?: 'adstorm' | 'default'; // VAST mode: 'adstorm' (uses HLS player + AdStorm VAST endpoint) or 'default' (uses Google IMA SDK + /ads/web endpoint) (default: 'default')
@@ -657,6 +659,85 @@ The HlsPlayer automatically detects and responds to SCTE-35 signals embedded in
657
659
  - `#EXT-X-DATERANGE`
658
660
  - ID3 timed metadata
659
661
 
662
+ ### Early Ad Prefetching & Preload Pool
663
+
664
+ The player includes an advanced ad prefetching system that dramatically reduces ad start latency:
665
+
666
+ #### Early SCTE-35 Detection
667
+
668
+ The player scans up to 5 manifest fragments ahead of current playback to detect upcoming SCTE-35 ad markers. When an ad break is detected early:
669
+
670
+ 1. **Prefetching Begins**: The player immediately starts generating VAST URLs and prefetching ads
671
+ 2. **Preload Pool**: Up to 3 ads are preloaded and ready to play instantly
672
+ 3. **Zero-Delay Starts**: When the ad break actually begins, ads start immediately (no request delay)
673
+
674
+ **Benefits:**
675
+ - ⚡ **80% reduction** in ad start latency
676
+ - 🎯 **Instant ad playback** when breaks begin
677
+ - 📊 **Better fill rates** through proactive ad preparation
678
+ - 🔄 **Seamless transitions** between content and ads
679
+
680
+ #### How It Works
681
+
682
+ ```javascript
683
+ const player = new StormcloudVideoPlayer({
684
+ videoElement: video,
685
+ src: "https://your-stream.com/playlist.m3u8",
686
+ licenseKey: "your-license-key",
687
+ debugAdTiming: true, // Enable to see prefetching logs
688
+ });
689
+
690
+ // The player automatically:
691
+ // 1. Scans manifest fragments for SCTE-35 markers
692
+ // 2. Detects upcoming ad breaks before playback reaches them
693
+ // 3. Prefetches and preloads ads into a pool
694
+ // 4. Starts ads instantly when breaks begin
695
+ ```
696
+
697
+ **Debug Output Example:**
698
+ ```
699
+ [PREFETCH] 🔄 Starting ad prefetch for upcoming ad break
700
+ [PREFETCH] 📋 Pre-generated 5 VAST URLs
701
+ [PRELOAD-POOL] 🏊 Starting preload pool EARLY (target size: 3)
702
+ [PRELOAD-POOL] 📥 Preloading ad into pool: https://...
703
+ [PRELOAD-POOL] ✅ Ad preloaded (pool size: 1/3)
704
+ [CONTINUOUS-FETCH] 🚀 Using preloaded ad from pool (preloaded in advance, ready immediately!)
705
+ ```
706
+
707
+ #### Continuous Ad Fetching
708
+
709
+ During ad breaks, the player continuously fetches additional ads to fill the entire SCTE-35 duration:
710
+
711
+ - **Dynamic Queue**: Maintains a queue of ready-to-play VAST URLs
712
+ - **Smart Rate Limiting**: 2.5s minimum interval between requests with exponential backoff
713
+ - **Automatic Filling**: Fetches ads until the SCTE-35 duration is fully filled
714
+ - **Error Recovery**: Distinguishes temporary failures (no-fill) from permanent failures
715
+
716
+ **Rate Limiting & Backoff:**
717
+ - Base interval: 2.5 seconds between requests
718
+ - Exponential backoff: Increases with consecutive failures
719
+ - Max backoff: 15 seconds
720
+ - Cooldown period: 30 seconds for temporary failures (no-fill)
721
+
722
+ #### Error Handling & Recovery
723
+
724
+ The player intelligently handles different types of ad failures:
725
+
726
+ **Temporary Failures (Retryable):**
727
+ - No-fill responses (no ads available)
728
+ - Network timeouts
729
+ - Rate limiting errors
730
+ - **Action**: URL enters 30s cooldown, then can be retried
731
+
732
+ **Permanent Failures (Blacklisted):**
733
+ - VAST parsing errors
734
+ - Malformed responses
735
+ - **Action**: URL is permanently blacklisted for the current ad break
736
+
737
+ **Fallback System:**
738
+ - If a primary ad request fails, the player automatically tries a preloaded ad from the pool
739
+ - Ensures continuous ad playback even when individual requests fail
740
+
660
741
  ### Late Join Behavior
661
742
 
662
743
  When viewers join during an ad break:
@@ -774,6 +855,39 @@ StormcloudPlayer.addCustomPlayer({
774
855
  });
775
856
  ```
776
857
 
858
+ ### Buffering Configuration
859
+
860
+ #### Min Segments Before Play
861
+
862
+ Control how many segments must be buffered before playback starts. This helps ensure smooth playback, especially on slower connections:
863
+
864
+ ```javascript
865
+ const player = new StormcloudVideoPlayer({
866
+ videoElement: video,
867
+ src: "https://your-stream.com/playlist.m3u8",
868
+ autoplay: true,
869
+ minSegmentsBeforePlay: 3, // Wait for 3 segments before starting (default: 2)
870
+ });
871
+
872
+ // Or with React component
873
+ <StormcloudPlayer
874
+ src="https://your-stream.com/playlist.m3u8"
875
+ playing={true}
876
+ minSegmentsBeforePlay={3}
877
+ />
878
+ ```
879
+
880
+ **Configuration Options:**
881
+ - `minSegmentsBeforePlay: 0` - Start immediately (may cause stuttering on slow connections)
882
+ - `minSegmentsBeforePlay: 2` - Default, good balance for most use cases
883
+ - `minSegmentsBeforePlay: 3-5` - Recommended for slower connections or higher quality streams
884
+ - `minSegmentsBeforePlay: undefined` - Uses default value (2)
885
+
886
+ **When to Adjust:**
887
+ - **Increase** for high-bitrate streams or unreliable networks
888
+ - **Decrease** for low-latency requirements or fast connections
889
+ - **Set to 0** only if you need immediate playback and can tolerate potential stuttering
890
+
777
891
  ### Player Detection
778
892
 
779
893
  ```javascript
@@ -988,6 +1102,27 @@ MIT License - see [LICENSE](LICENSE) file for details.
988
1102
 
989
1103
  Built with ❤️ by the Stormcloud team
990
1104
 
1105
+ ### What's New in v0.4
1106
+
1107
+ - 🚀 **Early Ad Prefetching**: Detects SCTE-35 markers in manifest fragments before playback reaches them, prefetching ads in advance for zero-delay ad starts
1108
+ - 🏊 **Ad Preload Pool**: Maintains a pool of preloaded, ready-to-play ads (up to 3 by default) for instant ad playback when breaks start
1109
+ - 🔄 **Continuous Ad Fetching**: Dynamically fetches additional ads during ad breaks to perfectly fill SCTE-35 durations, ensuring no wasted ad time
1110
+ - ⏱️ **Smart Rate Limiting**: Intelligent rate limiting (2.5s minimum interval) with exponential backoff to prevent ad server overload
1111
+ - 🛡️ **Advanced Error Handling**: Distinguishes between temporary failures (no-fill, timeouts) and permanent failures, with 30s cooldown periods for retryable errors
1112
+ - ⏳ **Min Segments Before Play**: New `minSegmentsBeforePlay` option (default: 2) to ensure smooth playback start by buffering multiple segments
1113
+ - 🎯 **Ad Request Watchdog**: Timeout system prevents hanging ad requests and automatically recovers from stuck states
1114
+ - ⬛ **Placeholder System**: Seamless placeholder layer shown during ad transitions, preventing content flash between ads
1115
+ - 📊 **Improved Queue Management**: Better handling of ad request queues with automatic cleanup and failure tracking
1116
+ - 🔍 **Early SCTE-35 Detection**: Scans up to 5 manifest fragments ahead to detect upcoming ad breaks, enabling proactive ad preparation
1117
+ - ⚡ **Zero-Delay Ad Starts**: Preloaded ads start instantly when ad breaks begin, eliminating the traditional ad request delay
1118
+ - 🎬 **Fallback Ad System**: Automatic fallback to preloaded ads when primary ad requests fail, ensuring continuous ad playback
1119
+
1120
+ **Performance Improvements:**
1121
+ - Reduced ad start latency by up to 80% through prefetching and preloading
1122
+ - Better resource utilization with intelligent ad pool management
1123
+ - Improved reliability with comprehensive error recovery mechanisms
1124
+ - Enhanced user experience with seamless ad transitions
1125
+
991
1126
  ### What's New in v0.3
992
1127
 
993
1128
  - 🎬 **Custom HLS Ad Player**: Native HLS ad playback with custom VAST service
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stormcloud-video-player",
3
- "version": "0.3.46",
3
+ "version": "0.3.47",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
6
6
  "scripts": {