stormcloud-video-player 0.2.13 → 0.2.15

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/README.md CHANGED
@@ -41,6 +41,7 @@ function MyVideoApp() {
41
41
  showCustomControls={true} // Enable enhanced UI controls
42
42
  allowNativeHls={true} // Allow native HLS for better performance
43
43
  licenseKey="your_license_key_here"
44
+ vastMode="adstorm" // Use AdStorm mode with HLS ad player
44
45
  style={{ width: "100%", aspectRatio: "16/9" }}
45
46
  wrapperStyle={{ borderRadius: "12px", overflow: "hidden" }}
46
47
  onReady={(player) => {
@@ -77,6 +78,7 @@ function MyVideoApp() {
77
78
  allowNativeHls={true}
78
79
  showCustomControls={true}
79
80
  licenseKey="your_license_key_here"
81
+ vastMode="adstorm" // Use AdStorm mode (or omit for default mode)
80
82
  onReady={(player) => {
81
83
  console.log("Player is ready!", player);
82
84
  }}
@@ -266,8 +268,9 @@ interface StormcloudPlayerProps {
266
268
  adFailsafeTimeoutMs?: number;
267
269
 
268
270
  // Ad player configuration
269
- adPlayerType?: 'ima' | 'hls'; // Choose ad player (default: 'ima')
270
- vastTagUrl?: string; // Custom VAST URL for HLS ad player
271
+ vastMode?: 'adstorm' | 'default'; // VAST mode: 'adstorm' (HLS player + AdStorm VAST endpoint) or 'default' (IMA SDK + /ads/web endpoint) (default: 'default')
272
+ vastTagUrl?: string; // Custom VAST URL (used in default mode if provided; when not provided, uses /ads/web endpoint)
273
+ adPlayerType?: 'ima' | 'hls'; // Manual override for ad player type (auto-determined by vastMode if not specified)
271
274
 
272
275
  // Event handlers
273
276
  onReady?: (player: StormcloudVideoPlayer) => void;
@@ -351,8 +354,8 @@ interface StormcloudVideoPlayerConfig {
351
354
  adFailsafeTimeoutMs?: number; // Ad timeout in milliseconds (default: 10000)
352
355
 
353
356
  // Ad configuration
354
- vastMode?: 'adstorm' | 'default'; // VAST mode: 'adstorm' (uses HLS player + AdStorm backend) or 'default' (uses Google IMA SDK) (default: 'default')
355
- vastTagUrl?: string; // Custom VAST tag URL (used in default mode if provided)
357
+ vastMode?: 'adstorm' | 'default'; // VAST mode: 'adstorm' (uses HLS player + AdStorm VAST endpoint) or 'default' (uses Google IMA SDK + /ads/web endpoint) (default: 'default')
358
+ vastTagUrl?: string; // Custom VAST tag URL (used in default mode if provided; when not provided, defaults to /ads/web endpoint)
356
359
  adPlayerType?: 'ima' | 'hls'; // Manual override for ad player type (auto-determined by vastMode if not specified)
357
360
 
358
361
  onVolumeToggle?: () => void; // Callback for volume toggle
@@ -437,8 +440,17 @@ const player = new StormcloudVideoPlayer({
437
440
 
438
441
  **What happens:**
439
442
  - 🎯 Automatically uses HLS ad player (`adPlayerType: 'hls'`)
440
- - 🔗 VAST endpoint: `https://adstorm.co/api-adstorm-dev/adstorm/vast/${licenseKey}`
443
+ - 🔗 VAST endpoint: `GET https://adstorm.co/api-adstorm-dev/adstorm/vast/{licenseKey}`
444
+ - License key is passed in the URL path (no authorization header needed)
445
+ - Returns VAST XML directly with HLS media files
441
446
  - 📊 Direct tracking and analytics through AdStorm backend
447
+ - ⚠️ Gracefully handles "no ads available" scenarios (logs warnings, not errors)
448
+
449
+ **API Flow:**
450
+ 1. Player calls `/vast/{licenseKey}` endpoint
451
+ 2. Backend returns VAST XML with HLS media files
452
+ 3. Player parses VAST XML and extracts MediaFile URLs
453
+ 4. HLS ad player loads and plays the ad segments
442
454
 
443
455
  **Benefits:**
444
456
  - ✅ Zero external dependencies (no Google IMA SDK)
@@ -446,6 +458,7 @@ const player = new StormcloudVideoPlayer({
446
458
  - ✅ Native HLS playback (same format as content)
447
459
  - ✅ Better performance and reliability
448
460
  - ✅ Custom targeting and selection
461
+ - ✅ Proper error handling (distinguishes parsing errors from "no ads available")
449
462
 
450
463
  #### 2. **Default Mode**
451
464
 
@@ -455,6 +468,7 @@ Uses Google IMA SDK for traditional ad serving:
455
468
  const player = new StormcloudVideoPlayer({
456
469
  videoElement: video,
457
470
  src: "https://your-stream.com/playlist.m3u8",
471
+ licenseKey: "your-license-key",
458
472
 
459
473
  // Default mode - uses Google IMA SDK automatically
460
474
  vastMode: 'default', // or omit this property entirely
@@ -466,14 +480,26 @@ const player = new StormcloudVideoPlayer({
466
480
 
467
481
  **What happens:**
468
482
  - 🎯 Automatically uses Google IMA SDK (`adPlayerType: 'ima'`)
469
- - 🔗 VAST endpoint: Uses `vastTagUrl` if provided, otherwise `https://adstorm.co/api-adstorm-dev/adstorm/ads/web`
470
- - 📊 Standard VAST/VPAID ad serving
483
+ - 🔗 VAST endpoint resolution:
484
+ 1. If `vastTagUrl` is provided, uses that URL directly
485
+ 2. Otherwise, calls `GET https://adstorm.co/api-adstorm-dev/adstorm/ads/web`
486
+ - Requires `Authorization: Bearer {licenseKey}` header
487
+ - Returns JSON response with IMA payload: `{ response: { ima: { "publisherdesk.ima": { payload: "VAST_URL" } } } }`
488
+ - Extracts VAST tag URL from the `payload` field
489
+ - 📊 Standard VAST/VPAID ad serving through Google IMA SDK
490
+
491
+ **API Flow:**
492
+ 1. Player calls `/ads/web` endpoint with Bearer token (if no `vastTagUrl` provided)
493
+ 2. Backend returns JSON with IMA configuration
494
+ 3. Player extracts VAST tag URL from `response.ima["publisherdesk.ima"].payload`
495
+ 4. Google IMA SDK loads and plays the VAST ad
471
496
 
472
497
  **Benefits:**
473
498
  - ✅ Industry-standard ad serving
474
499
  - ✅ Wide format support (VAST, VPAID)
475
500
  - ✅ Established ecosystem
476
501
  - ✅ Backward compatible with existing VAST tags
502
+ - ✅ Supports both custom VAST URLs and AdStorm backend
477
503
 
478
504
  ### Manual Ad Player Override
479
505
 
@@ -486,12 +512,16 @@ const player = new StormcloudVideoPlayer({
486
512
 
487
513
  vastMode: 'default',
488
514
  adPlayerType: 'hls', // Manual override to use HLS player with default mode
489
- vastTagUrl: 'https://your-backend.com/vast',
515
+ vastTagUrl: 'https://your-backend.com/vast', // Will use this URL directly
490
516
 
491
517
  debugAdTiming: true,
492
518
  });
493
519
  ```
494
520
 
521
+ **Note:** When `adPlayerType` is manually set, the `vastMode` property still determines which backend endpoint is called:
522
+ - `vastMode: 'adstorm'` → Always calls `/vast/{licenseKey}` endpoint
523
+ - `vastMode: 'default'` → Calls `/ads/web` endpoint (unless `vastTagUrl` is provided)
524
+
495
525
  ### SCTE-35 Support
496
526
 
497
527
  The HlsPlayer automatically detects and responds to SCTE-35 signals embedded in HLS streams:
@@ -529,6 +559,44 @@ When viewers join during an ad break:
529
559
  />
530
560
  ```
531
561
 
562
+ ### Error Handling
563
+
564
+ The player distinguishes between different types of ad-related issues:
565
+
566
+ **"No Ads Available" (Warning):**
567
+ - When the VAST response indicates no ads are available (e.g., empty `<MediaFiles>` or `AdTitle: "No Ad Available"`)
568
+ - Logs warnings, not errors
569
+ - Content playback continues normally
570
+ - No error events are emitted
571
+
572
+ **VAST XML Parsing Errors (Error):**
573
+ - When the VAST XML is malformed or cannot be parsed
574
+ - Logs errors
575
+ - Emits `ad_error` event
576
+ - Content playback continues
577
+
578
+ **Network/Fetch Errors (Error):**
579
+ - When the VAST endpoint is unreachable or returns an error status
580
+ - Logs errors
581
+ - Emits `ad_error` event
582
+ - Content playback continues
583
+
584
+ Example with error handling:
585
+
586
+ ```javascript
587
+ const player = new StormcloudVideoPlayer({
588
+ // ... config
589
+ vastMode: 'adstorm',
590
+ debugAdTiming: true, // Enable detailed logging
591
+ });
592
+
593
+ // Monitor ad events
594
+ player.on('ad_error', (error) => {
595
+ console.error('Ad error occurred:', error);
596
+ // Handle error (e.g., show fallback, retry, etc.)
597
+ });
598
+ ```
599
+
532
600
  ## 🔐 Authentication
533
601
 
534
602
  The player supports license key authentication for enhanced features:
@@ -542,9 +610,16 @@ const player = new StormcloudVideoPlayer({
542
610
 
543
611
  Authenticated requests are sent to:
544
612
 
545
- - Ad configuration: `https://adstorm.co/api-adstorm-dev/adstorm/ads/web`
546
- - Player tracking: `https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track`
547
- - Heartbeat monitoring: `https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat`
613
+ - **AdStorm Mode** (`vastMode: 'adstorm'`):
614
+ - VAST endpoint: `GET https://adstorm.co/api-adstorm-dev/adstorm/vast/{licenseKey}` (license key in URL path)
615
+
616
+ - **Default Mode** (`vastMode: 'default'`):
617
+ - Ad configuration: `GET https://adstorm.co/api-adstorm-dev/adstorm/ads/web` (requires `Authorization: Bearer {licenseKey}` header)
618
+ - Returns JSON with IMA payload containing VAST tag URL
619
+
620
+ - **Player Tracking** (both modes):
621
+ - Player tracking: `POST https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track` (requires `Authorization: Bearer {licenseKey}` header)
622
+ - Heartbeat monitoring: `POST https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat` (requires `Authorization: Bearer {licenseKey}` header)
548
623
 
549
624
  ## 🔧 Advanced Configuration
550
625
 
@@ -805,6 +880,12 @@ Built with ❤️ by the Stormcloud team
805
880
  - 🔄 **Backward Compatible**: Existing Google IMA integration still works
806
881
  - 📦 **Zero Dependencies**: No external ad SDKs required (when using HLS ad player)
807
882
  - 🎨 **Seamless Playback**: Same player for content and ads
883
+ - 🔀 **VAST Mode System**: `vastMode` property automatically configures endpoints and ad players
884
+ - `vastMode: 'adstorm'` → Uses `/vast/{licenseKey}` endpoint with HLS ad player
885
+ - `vastMode: 'default'` → Uses `/ads/web` endpoint with Google IMA SDK
886
+ - ⚠️ **Improved Error Handling**: Distinguishes between parsing errors and "no ads available" scenarios
887
+ - Logs warnings for "no ads available" (graceful handling)
888
+ - Logs errors for actual parsing/fetch failures
808
889
 
809
890
  ### What's New in v0.2
810
891