@devix-technologies/react-gjirafa-vp-player 1.0.22 → 1.0.23

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
@@ -6,7 +6,41 @@ It supports multiple ways to configure and play videos, including single files,
6
6
 
7
7
  ## Overview
8
8
 
9
- The `VPPlayer` component dynamically loads the VP Player script (`vpplayer.js`) and initializes it with a configuration object. The configuration is built based on the provided props, which determine the source and type of video data to play.
9
+ The `VPPlayer` component dynamically loads the VP Player script (`vpplayer.js`) and initializes it with a configuration object. The configuration is built based on the provided props, which determine the source and type of video data to play. It supports **Horizontal (Standard)** and **Vertical (Reels)** modes, along with comprehensive analytics tracking.
10
+
11
+ ## Installation
12
+
13
+ To install the package, run:
14
+
15
+ ```bash
16
+ npm install @devix-technologies/react-gjirafa-vp-player
17
+ # or
18
+ yarn add @devix-technologies/react-gjirafa-vp-player
19
+ # or
20
+ pnpm add @devix-technologies/react-gjirafa-vp-player
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ Here is a basic example of how to use the `VPPlayer` component in your React application:
26
+
27
+ ```tsx
28
+ import { VPPlayer } from "@devix-technologies/react-gjirafa-vp-player";
29
+
30
+ const App = () => {
31
+ return (
32
+ <div style={{ maxWidth: "800px", margin: "0 auto" }}>
33
+ <VPPlayer
34
+ playerId="my-unique-player-id"
35
+ videoUrl="https://example.com/video.mp4"
36
+ version="latest"
37
+ />
38
+ </div>
39
+ );
40
+ };
41
+
42
+ export default App;
43
+ ```
10
44
 
11
45
  ## Source Files Structure
12
46
 
@@ -41,6 +75,7 @@ The `VPPlayer` component dynamically loads the VP Player script (`vpplayer.js`)
41
75
  │ │ ├── playlist.ts
42
76
  │ ├── hooks/
43
77
  │ │ ├── index.ts
78
+ │ │ ├── useVPPlayerEvents.ts
44
79
  │ │ ├── useVPPlayerLogic.ts
45
80
  │ │ ├── useVPPlayerScript.ts
46
81
  │ │ ├── useVideoData.ts
@@ -52,6 +87,7 @@ The `VPPlayer` component dynamically loads the VP Player script (`vpplayer.js`)
52
87
  │ │ ├── styles.ts
53
88
  │ ├── types/
54
89
  │ │ ├── api.types.ts
90
+ │ │ ├── playerEvents.types.ts
55
91
  │ │ ├── index.ts
56
92
  │ ├── utils/
57
93
  │ │ ├── index.ts
@@ -87,6 +123,21 @@ interface VPPlayerProps {
87
123
  isPlayerVisible, // Flag indicating whether the player is currently visible.
88
124
  onPlaylistData?: (videos: PlaylistItem[]) => void; // Optional callback that fires when playlist data is loaded
89
125
  onVideoStarted?: (videoData: CurrentVideoData) => void; // Optional callback that fires when a video starts playing
126
+
127
+ // Analytics & Event Callbacks
128
+ onPlayerStart?: (event: string) => void; // Fires when playback starts for the first time
129
+ onPlayerPlay?: (event: string) => void; // Fires on subsequent play actions
130
+ onPlayerPause?: (event: string) => void; // Fires when playback is paused
131
+ onPlayerResume?: (event: string) => void; // Fires when playback is resumed
132
+ onPlayerNext?: (event: string) => void; // Fires on next video click
133
+ onPlayerPrevious?: (event: string) => void; // Fires on previous video click
134
+ onPlayerEnd?: (event: string) => void; // Fires when video ends
135
+ onPlayerProgressEvery10Seconds?: (event: string, currentPosition: number) => void; // Fires every 10s
136
+ onPlayerProgressAt20Seconds?: (event: string, currentPosition: number) => void; // Fires specifically at 20s
137
+ onPlayerQuartile25?: (event: string, currentPosition: number) => void; // Fires at 25% progress
138
+ onPlayerQuartile50?: (event: string, currentPosition: number) => void; // Fires at 50% progress
139
+ onPlayerQuartile75?: (event: string, currentPosition: number) => void; // Fires at 75% progress
140
+ onPlayerEvent?: (event: string, currentPosition?: number) => void; // Universal callback for all events
90
141
  }
91
142
  ```
92
143
 
@@ -209,7 +260,7 @@ interface VPPlayerProps {
209
260
  - `premium` - Whether video is locked/premium
210
261
  - `author` - Video author name
211
262
  - `tags` - Array of video tags
212
-
263
+
213
264
  - **Use cases:**
214
265
  - **Analytics tracking**: Track video views, engagement, navigation patterns
215
266
  - **Custom UI updates**: Display current video info, progress indicators
@@ -569,7 +620,158 @@ const AdvancedPlayerComponent = () => {
569
620
  );
570
621
  };
571
622
  ```
572
- <!-- Release notes WIP -->
573
- <!-- v. 1.0.0 -->
574
- <!-- Single video file, Playlist with files, Single Api video, Playlist Api-->
575
- <!-- -->
623
+
624
+ ### Playback Event Tracking (Analytics)
625
+
626
+ Besides tracking playlist and video changes, `VPPlayer` offers granular callbacks for tracking player state and progress. This is ideal for sending data to analytics services (e.g., Google Analytics, Segment).
627
+
628
+ You can use **specific callbacks** for each event type or a single **universal callback**.
629
+
630
+ #### 1. Available Events
631
+ The following events are tracked:
632
+ - **State Events:** `player_start`, `player_play`, `player_pause`, `player_resume`, `player_end`, `player_next`, `player_previous`
633
+ - **Progress Events:** `player_progress_every_10_seconds`, `player_progress_at_20_seconds`
634
+ - **Quartile Events:** `player_quartile_25`, `player_quartile_50`, `player_quartile_75`
635
+
636
+ *Note: Progress and Quartile events allow you to access the `currentPosition` (in seconds).*
637
+
638
+ #### 2. Using Specific Callbacks
639
+ Use this approach if you want to handle only specific events.
640
+
641
+ ```typescript
642
+ <VPPlayer
643
+ // ... other props
644
+ onPlayerStart={(event) => console.log("Started:", event)}
645
+ onPlayerPause={(event) => console.log("Paused:", event)}
646
+ onPlayerQuartile50={(event, time) => console.log("50% watched at:", time)}
647
+ onPlayerEnd={(event) => console.log("Finished:", event)}
648
+ />
649
+ ```
650
+
651
+ #### 3. Using Universal Callback (`onPlayerEvent`)
652
+ Use this approach to route all events through a single function, which simplifies integration with analytics providers.
653
+
654
+ ```typescript
655
+ const handleAnalytics = (eventName: string, currentPosition?: number) => {
656
+ // Example: Send to analytics layer
657
+ analytics.track(eventName, {
658
+ video_id: "12345",
659
+ timestamp: currentPosition || 0,
660
+ device: "desktop"
661
+ });
662
+
663
+ console.log(`[Analytics] ${eventName}`, currentPosition ? `Time: ${currentPosition}` : "");
664
+ };
665
+
666
+ <VPPlayer
667
+ playerId="analytics-player"
668
+ // ... other props
669
+ onPlayerEvent={handleAnalytics}
670
+ />
671
+ ```
672
+
673
+ ## Release Notes
674
+
675
+ ### v1.0.22
676
+ - **New Features:**
677
+ - Added comprehensive **Analytics Event Callbacks** (`onPlayerStart`, `onPlayerPlay`, `onPlayerPause`, `onPlayerEnd`, etc.).
678
+ - Added **Universal `onPlayerEvent` callback** for simplified event tracking.
679
+ - Added support for **Vertical Player analytics** including `player_next`/`player_previous` on scroll/swipe.
680
+ - Added **Progress & Quartile events** (10s, 20s, 25%, 50%, 75%) with `currentPosition` data.
681
+ - **Fixes:**
682
+ - Fixed `videoId` configuration issue in VP Player tracking causing 400 errors.
683
+ - Refined event logic to prevent duplicate events (e.g., `player_pause` during scroll/click).
684
+
685
+ ### v1.0.21
686
+ - **Fixes:**
687
+ - Fixed vertical fullscreen video layout to rely on `aspect-ratio`.
688
+ - Cleaned up unused variables in Storybook examples.
689
+
690
+ ### v1.0.20
691
+ - **Features:**
692
+ - Added full metadata API fetch for **Vertical Player** (`onVideoStarted` now returns more comprehensive data).
693
+
694
+ ### v1.0.19
695
+ - **Features:**
696
+ - Added full metadata support for **Horizontal Player**.
697
+ - Introduced `onVideoStarted` callback for tracking video changes and retrieving metadata (title, author, tags, premium status, etc.).
698
+ - **Documentation:**
699
+ - Updated documentation to reflect new metadata capabilities.
700
+
701
+ ### v1.0.18
702
+ - **Features:**
703
+ - Added `onPlaylistData` callback prop to access the full playlist structure (videos, backup status, etc.).
704
+
705
+ ### v1.0.17
706
+ - **Styles:**
707
+ - Adjusted vertical player wrapper sizing for better layout consistency.
708
+
709
+ ### v1.0.16
710
+ - **Styles:**
711
+ - Adjusted player container border radius overrides.
712
+
713
+ ### v1.0.15
714
+ - **Styles:**
715
+ - Removed default rounded corners and borders from VP Player to allow easier custom styling.
716
+
717
+ ### v1.0.14
718
+ - **Features:**
719
+ - Added support for **backup playlist videos** handling.
720
+
721
+ ### v1.0.13
722
+ - **Fixes:**
723
+ - Fixed video ID indexing issue in sliced playlists for vertical player.
724
+
725
+ ### v1.0.12
726
+ - **Refactor:**
727
+ - Reverted to original playlist configuration logic for better stability.
728
+
729
+ ### v1.0.11
730
+ - **Fixes:**
731
+ - Fixed logic regarding the removal of the first video from the playlist.
732
+
733
+ ### v1.0.10
734
+ - **Features:**
735
+ - Added TypeScript interfaces for tracks and `showCaptions`.
736
+ - **Fixes:**
737
+ - Fixed video indexing and thumbnail display issues in vertical player.
738
+
739
+ ### v1.0.9
740
+ - **Fixes:**
741
+ - Ensure title and thumbnail are correctly applied to the first video in the playlist configuration.
742
+
743
+ ### v1.0.8
744
+ - **Features:**
745
+ - Improved player configuration builder.
746
+ - **Fixes:**
747
+ - Fixed playlist video index bug.
748
+ - Added functionality to start playlist from a specific index.
749
+
750
+ ### v1.0.7
751
+ - **Fixes:**
752
+ - Handled timeout issues in vertical player.
753
+ - Resolved all linting and TypeScript errors.
754
+
755
+ ### v1.0.6
756
+ - **Fixes:**
757
+ - Fixed TypeScript build errors.
758
+
759
+ ### v1.0.5
760
+ - **Fixes:**
761
+ - Fixed vertical player issue on page refresh.
762
+ - Removed unnecessary type assertions.
763
+
764
+ ### v1.0.4
765
+ - **Fixes:**
766
+ - Improved handling of vertical player video changes.
767
+
768
+ ### v1.0.0 - v1.0.3
769
+ - **Initial Release:**
770
+ - Core `VPPlayer` component with support for:
771
+ - Single video file playback.
772
+ - Playlist playback (file-based and API-based).
773
+ - Single video API fetching.
774
+ - Reels/Vertical mode.
775
+ - Added `useVPPlayerScript` and `useVideoData` hooks with retry and caching logic.
776
+ - Unified error handling and configuration building.
777
+ - Added Storybook examples and comprehensive documentation.