cafe-video-player 3.0.8 → 3.0.10

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 (93) hide show
  1. package/README.md +325 -286
  2. package/index.js +7300 -1
  3. package/index.js.map +1 -1
  4. package/index.mjs +7285 -1
  5. package/index.mjs.map +1 -1
  6. package/package.json +51 -44
  7. package/videoPlayerStyles.css +11 -11
  8. package/VideoHighLighter-HVS4CP26.js +0 -2
  9. package/VideoHighLighter-HVS4CP26.js.map +0 -1
  10. package/VideoHighLighter-R2LX3ZCY.mjs +0 -2
  11. package/VideoHighLighter-R2LX3ZCY.mjs.map +0 -1
  12. package/backwardForward-R3CPRHJG.mjs +0 -2
  13. package/backwardForward-R3CPRHJG.mjs.map +0 -1
  14. package/backwardForward-W3FUQG26.js +0 -2
  15. package/backwardForward-W3FUQG26.js.map +0 -1
  16. package/chunk-45E54NWZ.js +0 -2
  17. package/chunk-45E54NWZ.js.map +0 -1
  18. package/chunk-47X34WNZ.js +0 -9
  19. package/chunk-47X34WNZ.js.map +0 -1
  20. package/chunk-4KRYS3HT.mjs +0 -2
  21. package/chunk-4KRYS3HT.mjs.map +0 -1
  22. package/chunk-6GZHEQTZ.mjs +0 -2
  23. package/chunk-6GZHEQTZ.mjs.map +0 -1
  24. package/chunk-7EFML44G.mjs +0 -2
  25. package/chunk-7EFML44G.mjs.map +0 -1
  26. package/chunk-D54C47WZ.js +0 -3
  27. package/chunk-D54C47WZ.js.map +0 -1
  28. package/chunk-DOW3SWLS.js +0 -2
  29. package/chunk-DOW3SWLS.js.map +0 -1
  30. package/chunk-EBOPTQAJ.mjs +0 -3
  31. package/chunk-EBOPTQAJ.mjs.map +0 -1
  32. package/chunk-G2ZC7IJK.mjs +0 -2
  33. package/chunk-G2ZC7IJK.mjs.map +0 -1
  34. package/chunk-GZLP6GZF.mjs +0 -9
  35. package/chunk-GZLP6GZF.mjs.map +0 -1
  36. package/chunk-IZP23D2I.mjs +0 -3
  37. package/chunk-IZP23D2I.mjs.map +0 -1
  38. package/chunk-MBD33X6K.js +0 -2
  39. package/chunk-MBD33X6K.js.map +0 -1
  40. package/chunk-MNUGCMYR.mjs +0 -2
  41. package/chunk-MNUGCMYR.mjs.map +0 -1
  42. package/chunk-MYPZGMHH.js +0 -2
  43. package/chunk-MYPZGMHH.js.map +0 -1
  44. package/chunk-O4Z67S4F.js +0 -2
  45. package/chunk-O4Z67S4F.js.map +0 -1
  46. package/chunk-OYNS7P5H.mjs +0 -2
  47. package/chunk-OYNS7P5H.mjs.map +0 -1
  48. package/chunk-PJ5S2UP3.js +0 -3
  49. package/chunk-PJ5S2UP3.js.map +0 -1
  50. package/chunk-QSFAQGRX.js +0 -3
  51. package/chunk-QSFAQGRX.js.map +0 -1
  52. package/chunk-S4UH5Q2F.js +0 -2
  53. package/chunk-S4UH5Q2F.js.map +0 -1
  54. package/chunk-S7SXQ5YW.js +0 -2
  55. package/chunk-S7SXQ5YW.js.map +0 -1
  56. package/chunk-SVD4N6WD.mjs +0 -2
  57. package/chunk-SVD4N6WD.mjs.map +0 -1
  58. package/chunk-TK36GS4S.mjs +0 -2
  59. package/chunk-TK36GS4S.mjs.map +0 -1
  60. package/chunk-VLK44HNO.js +0 -2
  61. package/chunk-VLK44HNO.js.map +0 -1
  62. package/chunk-X7ZT44GS.mjs +0 -3
  63. package/chunk-X7ZT44GS.mjs.map +0 -1
  64. package/chunk-YTI7MNTA.js +0 -2
  65. package/chunk-YTI7MNTA.js.map +0 -1
  66. package/chunk-ZOZPPUR2.mjs +0 -2
  67. package/chunk-ZOZPPUR2.mjs.map +0 -1
  68. package/index.d.mts +0 -64
  69. package/index.d.ts +0 -64
  70. package/nonStaticVideoTag-5TAEJK6K.js +0 -2
  71. package/nonStaticVideoTag-5TAEJK6K.js.map +0 -1
  72. package/nonStaticVideoTag-MZOIOJPM.mjs +0 -2
  73. package/nonStaticVideoTag-MZOIOJPM.mjs.map +0 -1
  74. package/notActive-6YGA2KBW.mjs +0 -2
  75. package/notActive-6YGA2KBW.mjs.map +0 -1
  76. package/notActive-OUUHLJZR.js +0 -2
  77. package/notActive-OUUHLJZR.js.map +0 -1
  78. package/staticPlayer-DTNPBH5A.mjs +0 -2
  79. package/staticPlayer-DTNPBH5A.mjs.map +0 -1
  80. package/staticPlayer-HQ7LIMJX.js +0 -2
  81. package/staticPlayer-HQ7LIMJX.js.map +0 -1
  82. package/staticVideoTag-3LXMSPQU.js +0 -2
  83. package/staticVideoTag-3LXMSPQU.js.map +0 -1
  84. package/staticVideoTag-K5KF2NBH.mjs +0 -2
  85. package/staticVideoTag-K5KF2NBH.mjs.map +0 -1
  86. package/videoArea-2TECKTYP.js +0 -2
  87. package/videoArea-2TECKTYP.js.map +0 -1
  88. package/videoArea-MX6NFDFD.mjs +0 -2
  89. package/videoArea-MX6NFDFD.mjs.map +0 -1
  90. package/vodPlayer-2CKPYYAR.js +0 -2
  91. package/vodPlayer-2CKPYYAR.js.map +0 -1
  92. package/vodPlayer-J7SNEV7Q.mjs +0 -2
  93. package/vodPlayer-J7SNEV7Q.mjs.map +0 -1
package/README.md CHANGED
@@ -1,286 +1,325 @@
1
- # cafe-video-player
2
-
3
- ✔ Playing static and vod videos
4
-
5
- ## Installation
6
-
7
- ```
8
- $ npm install --save cafe-video-player
9
- $ yarn add cafe-video-player
10
-
11
- ```
12
-
13
- ## Example
14
-
15
- ✔ To play vod, follow the example below:
16
-
17
- ```jsx
18
- import { VideoPlayerLibrary } from "cafe-video-player";
19
-
20
- export default function HomePage() {
21
- const params = {
22
- type: "vod",
23
- id: "6623",
24
- banner: "image path", // (to display cover image from external url) optional
25
- subtitleUrl: "subtitle url", // (to display subtitle from external url) optional
26
- currentTime: 100, // (jump to second 100) optional
27
- onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
28
- subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
29
- /*
30
- subtitle example
31
- subtitles = [
32
- {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
33
- {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
34
- ]
35
- */
36
- onPlay: (currentTime: number) => console.log("Video started at:", currentTime),
37
- onSpeedChange: (oldSpeed: number, newSpeed: number) => console.log(`Playback speed changed from ${oldSpeed}x to ${newSpeed}x`),
38
- onFullscreenChange:(status: boolean) => console.log(`Fullscreen status:${status}`),
39
- onSubtitleStatusChange: (subtitle, status) => console.log("Subtitle status changed:", subtitle, "Enabled:", status),
40
- };
41
-
42
- return (
43
- <div>
44
- <VideoPlayerLibrary params={params} />
45
- </div>
46
- );
47
- }
48
- ```
49
-
50
- ## Example
51
-
52
- ✔ To play static videos, follow the example below:
53
-
54
- - id corresponds to the video link, which must be base64 format
55
- - banner corresponds to the cover link, which must be base64 format
56
-
57
- ```jsx
58
- import { VideoPlayerLibrary } from "cafe-video-player";
59
-
60
- export default function HomePage() {
61
- const params = {
62
- type: "static",
63
- id: "aHR0cHM6Ly9hYnJlaGFtcmFoaS5pci9vL3RXMHFONUQwWFB2R04wdGhJQUM1UUEv",
64
- banner: "image path", // (to display cover image from external url) optional
65
- onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
66
- subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
67
- /*
68
- subtitle example
69
- subtitles = [
70
- {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
71
- {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
72
- ]
73
- */
74
- onPlay: (currentTime: number) => console.log("Video started at:", currentTime),
75
- onSpeedChange: (oldSpeed: number, newSpeed: number) => console.log(`Playback speed changed from ${oldSpeed}x to ${newSpeed}x`),
76
- onFullscreenChange:(status: boolean) => console.log(`Fullscreen status:${status}`),
77
- onSubtitleStatusChange: (subtitle, status) => console.log("Subtitle status changed:", subtitle, "Enabled:", status),
78
- };
79
-
80
- return (
81
- <div>
82
- <VideoPlayerLibrary params={params} />
83
- </div>
84
- );
85
- }
86
- ```
87
-
88
- ## Example
89
-
90
- ✔ To use the mini-player feature, follow the example below:
91
-
92
- ```jsx
93
- import { MiniPlayerLibrary } from "cafe-video-player";
94
-
95
- export default function HomePage() {
96
- const params = {
97
- type: "vod",
98
- id: "6623",
99
- onClose: () => {},
100
- };
101
-
102
- return (
103
- <div>
104
- <MiniPlayerLibrary params={params} />
105
- </div>
106
- );
107
- }
108
- ```
109
-
110
- ## Example
111
-
112
- ✔ You can use bannerAlt props to set custom alt for video banner
113
-
114
- ```jsx
115
- import { VideoPlayerLibrary } from "cafe-video-player";
116
-
117
- export default function HomePage() {
118
- const params = {
119
- id: "6623",
120
- type: "vod",
121
- bannerAlt: "alt for video banner",
122
- };
123
-
124
- return (
125
- <div>
126
- <VideoPlayerLibrary params={params} />
127
- </div>
128
- );
129
- }
130
- ```
131
-
132
- For the modals to work correctly, you need to add the following tag to the end of the body tag in the \_document file.
133
-
134
- ```jsx
135
- <div id="dialog-react-root-videoPlayer" />
136
- ```
137
-
138
- To display the player styles correctly, you must import the videoPlayerStyles.css file from the node \_module folder inside the \_app file according to the example below.
139
-
140
- ```jsx
141
- import "../node_modules/cafe-video-player/videoPlayerStyles.css";
142
- ```
143
-
144
- To display the images correctly, you must put the following configuration in the next.config.ts file.
145
-
146
- ```jsx
147
-
148
- images: {
149
- remotePatterns: [
150
- {
151
- protocol: "https",
152
- hostname: "**"
153
- }
154
- ]
155
- },
156
-
157
- ```
158
-
159
- # Video HighLighter Integration Guide
160
-
161
- This document explains how to integrate and use the **Video HighLighter** feature in a Next.js project.
162
-
163
- ## Overview
164
-
165
- The Video HighLighter enhances the video player with additional UI and state indicators during the download and preparation of video content. To enable it, several props must be passed to the player component.
166
-
167
- ## Props
168
-
169
- ### `vhl_status`
170
-
171
- Indicates the current state of the Video HighLighter process. Accepted values:
172
-
173
- - `skeleton`: Shows the skeleton loading state.
174
- - `waiting`: Indicates the waiting period before video download begins.
175
- - `download_start`: The download process has started.
176
- - `download_error`: An error occurred during the download.
177
- - `undefined`: Default value. Hides all Video HighLighter-related sections.
178
-
179
- ### `vhl_progress`
180
-
181
- A numeric value representing the percentage of the download progress.
182
-
183
- ### `vhl_duration`
184
-
185
- Total duration of the video in seconds (numeric value).
186
-
187
- ### `vhl_statusText`
188
-
189
- Text displayed under the progress bar while downloading the video.
190
- For greater flexibility (e.g., multiline messages), this prop should be passed as a JSX element.
191
-
192
- ### `vhl_onRetry`
193
-
194
- A callback function executed if a download error occurs.
195
-
196
- ### `banner`
197
-
198
- An image used as the banner for the video.
199
-
200
- ## Important Notes
201
-
202
- After the video has been successfully downloaded, make sure to:
203
-
204
- 1. Set the `vhl_status` to `undefined`.
205
- 2. Pass the video `id` using the `id` prop to the player to start playback and load video details.
206
-
207
- ---
208
-
209
- ## 🧪 Example Usage in a Next.js Component
210
-
211
- ```tsx
212
- import { VideoPlayerLibrary } from "cafe-video-player";
213
-
214
- export default function HomePage() {
215
- const params = {
216
- vhl_status="download_start"
217
- vhl_progress={42}
218
- vhl_duration={300}
219
- vhl_statusText={<p>Downloading highlights...<br />Please wait.</p>}
220
- vhl_onRetry={handleRetry}
221
- banner="/images/video-banner.jpg"
222
- id="abc123"
223
- };
224
-
225
- return (
226
- <div>
227
- <VideoPlayerLibrary params={params} />
228
- </div>
229
- );
230
- }
231
- ```
232
-
233
- # Advertisement Integration Guide
234
-
235
- This document explains how to integrate and use the **Advertisement** feature in a Next.js project with the `cafe-video-player`.
236
-
237
- ---
238
-
239
- ## Overview
240
-
241
- The Advertisement feature allows you to show video ads before playback.
242
- It supports skip functionality, clickable ads, and callback hooks for both skipping and ad completion.
243
-
244
- ---
245
-
246
- ## Props
247
-
248
- An object that must follow the `IAdvertisement` interface:
249
-
250
- ```ts
251
- export interface IAdvertisement {
252
- videoUrl: string; // The ad video source URL (static video, required)
253
- adText?: string; // Optional text for the ad button. Defaults to "اطلاعات بیشتر" if not provided
254
- skipDelay?: number; // Number of seconds before the skip button becomes clickable. If not provided or 0, the ad cannot be skipped
255
- onSkipAd?: (currentTime: number) => void; // Callback when the ad is skipped, receives the currentTime (optional)
256
- onEndAd?: (currentTime: number) => void; // Callback when the ad finishes, receives the currentTime (optional)
257
- onClickAd?: (currentTime: number) => void; // Callback when the ad button is clicked, receives the currentTime. If not defined, the ad button will not be shown (optional)
258
- }
259
- ```
260
-
261
- ## 🧪 Example Usage in a Next.js Component
262
-
263
- ```tsx
264
- import { VideoPlayerLibrary } from "cafe-video-player";
265
-
266
- export default function HomePage() {
267
- const params = {
268
- type: "vod",
269
- id: "6623",
270
- advertisement: {
271
- videoUrl: "https://example.com/ad.mp4",
272
- adText: "Visit our sponsor",
273
- skipDelay: 5,
274
- onSkipAd: (currentTime: number) => console.log("Ad skipped at:", currentTime),
275
- onEndAd: (currentTime: number) => console.log("Ad ended at:", currentTime),
276
- onClickAd: (currentTime: number) => console.log("Ad clicked at:", currentTime),
277
- },
278
- };
279
-
280
- return (
281
- <div>
282
- <VideoPlayerLibrary params={params} />
283
- </div>
284
- );
285
- }
286
- ```
1
+ # cafe-video-player
2
+
3
+ ✔ Playing static and vod videos
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ npm install --save cafe-video-player
9
+ $ yarn add cafe-video-player
10
+
11
+ ```
12
+
13
+ ## Example
14
+
15
+ ✔ To play vod, follow the example below:
16
+
17
+ ```jsx
18
+ import { VideoPlayerLibrary } from "cafe-video-player";
19
+
20
+ export default function HomePage() {
21
+ const params = {
22
+ type: "vod",
23
+ id: "6623",
24
+ banner: "image path", // (to display cover image from external url) optional
25
+ subtitleUrl: "subtitle url", // (to display subtitle from external url) optional
26
+ currentTime: 100, // (jump to second 100) optional
27
+ onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
28
+ subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
29
+ /*
30
+ subtitle example
31
+ subtitles = [
32
+ {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
33
+ {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
34
+ ]
35
+ */
36
+ onPlay: (currentTime: number) => console.log("Video started at:", currentTime),
37
+ onSpeedChange: (oldSpeed: number, newSpeed: number) => console.log(`Playback speed changed from ${oldSpeed}x to ${newSpeed}x`),
38
+ onFullscreenChange:(status: boolean) => console.log(`Fullscreen status:${status}`),
39
+ onSubtitleStatusChange: (subtitle, status) => console.log("Subtitle status changed:", subtitle, "Enabled:", status),
40
+ };
41
+
42
+ return (
43
+ <div>
44
+ <VideoPlayerLibrary params={params} />
45
+ </div>
46
+ );
47
+ }
48
+ ```
49
+
50
+ ## Example
51
+
52
+ ✔ To play a video directly using stream_link, follow the example below:
53
+
54
+ - If stream_link is provided, there is no need to pass id.
55
+ - In this mode, the player will not send any request to fetch VOD data and will directly use the provided HLS link for playback.
56
+ - If both id and stream_link are provided, id has priority.
57
+
58
+ ```jsx
59
+ import { VideoPlayerLibrary } from "cafe-video-player";
60
+
61
+ export default function HomePage() {
62
+ const params = {
63
+ type: "static",
64
+ stream_link: "https://example.com/video/playlist.m3u8", // direct HLS link
65
+ banner: "image path", // (to display cover image from external url) optional
66
+ onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
67
+ subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
68
+ /*
69
+ subtitle example
70
+ subtitles = [
71
+ {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
72
+ {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
73
+ ]
74
+ */
75
+ onPlay: (currentTime: number) => console.log("Video started at:", currentTime),
76
+ onSpeedChange: (oldSpeed: number, newSpeed: number) => console.log(`Playback speed changed from ${oldSpeed}x to ${newSpeed}x`),
77
+ onFullscreenChange:(status: boolean) => console.log(`Fullscreen status:${status}`),
78
+ onSubtitleStatusChange: (subtitle, status) => console.log("Subtitle status changed:", subtitle, "Enabled:", status),
79
+ };
80
+
81
+ return (
82
+ <div>
83
+ <VideoPlayerLibrary params={params} />
84
+ </div>
85
+ );
86
+ }
87
+ ```
88
+
89
+ ## Example
90
+
91
+ ✔ To play static videos, follow the example below:
92
+
93
+ - id corresponds to the video link, which must be base64 format
94
+ - banner corresponds to the cover link, which must be base64 format
95
+
96
+ ```jsx
97
+ import { VideoPlayerLibrary } from "cafe-video-player";
98
+
99
+ export default function HomePage() {
100
+ const params = {
101
+ type: "static",
102
+ id: "aHR0cHM6Ly9hYnJlaGFtcmFoaS5pci9vL3RXMHFONUQwWFB2R04wdGhJQUM1UUEv",
103
+ banner: "image path", // (to display cover image from external url) optional
104
+ onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
105
+ subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
106
+ /*
107
+ subtitle example
108
+ subtitles = [
109
+ {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
110
+ {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
111
+ ]
112
+ */
113
+ onPlay: (currentTime: number) => console.log("Video started at:", currentTime),
114
+ onSpeedChange: (oldSpeed: number, newSpeed: number) => console.log(`Playback speed changed from ${oldSpeed}x to ${newSpeed}x`),
115
+ onFullscreenChange:(status: boolean) => console.log(`Fullscreen status:${status}`),
116
+ onSubtitleStatusChange: (subtitle, status) => console.log("Subtitle status changed:", subtitle, "Enabled:", status),
117
+ };
118
+
119
+ return (
120
+ <div>
121
+ <VideoPlayerLibrary params={params} />
122
+ </div>
123
+ );
124
+ }
125
+ ```
126
+
127
+ ## Example
128
+
129
+ ✔ To use the mini-player feature, follow the example below:
130
+
131
+ ```jsx
132
+ import { MiniPlayerLibrary } from "cafe-video-player";
133
+
134
+ export default function HomePage() {
135
+ const params = {
136
+ type: "vod",
137
+ id: "6623",
138
+ onClose: () => {},
139
+ };
140
+
141
+ return (
142
+ <div>
143
+ <MiniPlayerLibrary params={params} />
144
+ </div>
145
+ );
146
+ }
147
+ ```
148
+
149
+ ## Example
150
+
151
+ You can use bannerAlt props to set custom alt for video banner
152
+
153
+ ```jsx
154
+ import { VideoPlayerLibrary } from "cafe-video-player";
155
+
156
+ export default function HomePage() {
157
+ const params = {
158
+ id: "6623",
159
+ type: "vod",
160
+ bannerAlt: "alt for video banner",
161
+ };
162
+
163
+ return (
164
+ <div>
165
+ <VideoPlayerLibrary params={params} />
166
+ </div>
167
+ );
168
+ }
169
+ ```
170
+
171
+ For the modals to work correctly, you need to add the following tag to the end of the body tag in the \_document file.
172
+
173
+ ```jsx
174
+ <div id="dialog-react-root-videoPlayer" />
175
+ ```
176
+
177
+ To display the player styles correctly, you must import the videoPlayerStyles.css file from the node \_module folder inside the \_app file according to the example below.
178
+
179
+ ```jsx
180
+ import "../node_modules/cafe-video-player/videoPlayerStyles.css";
181
+ ```
182
+
183
+ To display the images correctly, you must put the following configuration in the next.config.ts file.
184
+
185
+ ```jsx
186
+
187
+ images: {
188
+ remotePatterns: [
189
+ {
190
+ protocol: "https",
191
+ hostname: "**"
192
+ }
193
+ ]
194
+ },
195
+
196
+ ```
197
+
198
+ # Video HighLighter Integration Guide
199
+
200
+ This document explains how to integrate and use the **Video HighLighter** feature in a Next.js project.
201
+
202
+ ## Overview
203
+
204
+ The Video HighLighter enhances the video player with additional UI and state indicators during the download and preparation of video content. To enable it, several props must be passed to the player component.
205
+
206
+ ## Props
207
+
208
+ ### `vhl_status`
209
+
210
+ Indicates the current state of the Video HighLighter process. Accepted values:
211
+
212
+ - `skeleton`: Shows the skeleton loading state.
213
+ - `waiting`: Indicates the waiting period before video download begins.
214
+ - `download_start`: The download process has started.
215
+ - `download_error`: An error occurred during the download.
216
+ - `undefined`: Default value. Hides all Video HighLighter-related sections.
217
+
218
+ ### `vhl_progress`
219
+
220
+ A numeric value representing the percentage of the download progress.
221
+
222
+ ### `vhl_duration`
223
+
224
+ Total duration of the video in seconds (numeric value).
225
+
226
+ ### `vhl_statusText`
227
+
228
+ Text displayed under the progress bar while downloading the video.
229
+ For greater flexibility (e.g., multiline messages), this prop should be passed as a JSX element.
230
+
231
+ ### `vhl_onRetry`
232
+
233
+ A callback function executed if a download error occurs.
234
+
235
+ ### `banner`
236
+
237
+ An image used as the banner for the video.
238
+
239
+ ## Important Notes
240
+
241
+ After the video has been successfully downloaded, make sure to:
242
+
243
+ 1. Set the `vhl_status` to `undefined`.
244
+ 2. Pass the video `id` using the `id` prop to the player to start playback and load video details.
245
+
246
+ ---
247
+
248
+ ## 🧪 Example Usage in a Next.js Component
249
+
250
+ ```tsx
251
+ import { VideoPlayerLibrary } from "cafe-video-player";
252
+
253
+ export default function HomePage() {
254
+ const params = {
255
+ vhl_status="download_start"
256
+ vhl_progress={42}
257
+ vhl_duration={300}
258
+ vhl_statusText={<p>Downloading highlights...<br />Please wait.</p>}
259
+ vhl_onRetry={handleRetry}
260
+ banner="/images/video-banner.jpg"
261
+ id="abc123"
262
+ };
263
+
264
+ return (
265
+ <div>
266
+ <VideoPlayerLibrary params={params} />
267
+ </div>
268
+ );
269
+ }
270
+ ```
271
+
272
+ # Advertisement Integration Guide
273
+
274
+ This document explains how to integrate and use the **Advertisement** feature in a Next.js project with the `cafe-video-player`.
275
+
276
+ ---
277
+
278
+ ## Overview
279
+
280
+ The Advertisement feature allows you to show video ads before playback.
281
+ It supports skip functionality, clickable ads, and callback hooks for both skipping and ad completion.
282
+
283
+ ---
284
+
285
+ ## Props
286
+
287
+ An object that must follow the `IAdvertisement` interface:
288
+
289
+ ```ts
290
+ export interface IAdvertisement {
291
+ videoUrl: string; // The ad video source URL (static video, required)
292
+ adText?: string; // Optional text for the ad button. Defaults to "اطلاعات بیشتر" if not provided
293
+ skipDelay?: number; // Number of seconds before the skip button becomes clickable. If not provided or 0, the ad cannot be skipped
294
+ onSkipAd?: (currentTime: number) => void; // Callback when the ad is skipped, receives the currentTime (optional)
295
+ onEndAd?: (currentTime: number) => void; // Callback when the ad finishes, receives the currentTime (optional)
296
+ onClickAd?: (currentTime: number) => void; // Callback when the ad button is clicked, receives the currentTime. If not defined, the ad button will not be shown (optional)
297
+ }
298
+ ```
299
+
300
+ ## 🧪 Example Usage in a Next.js Component
301
+
302
+ ```tsx
303
+ import { VideoPlayerLibrary } from "cafe-video-player";
304
+
305
+ export default function HomePage() {
306
+ const params = {
307
+ type: "vod",
308
+ id: "6623",
309
+ advertisement: {
310
+ videoUrl: "https://example.com/ad.mp4",
311
+ adText: "Visit our sponsor",
312
+ skipDelay: 5,
313
+ onSkipAd: (currentTime: number) => console.log("Ad skipped at:", currentTime),
314
+ onEndAd: (currentTime: number) => console.log("Ad ended at:", currentTime),
315
+ onClickAd: (currentTime: number) => console.log("Ad clicked at:", currentTime),
316
+ },
317
+ };
318
+
319
+ return (
320
+ <div>
321
+ <VideoPlayerLibrary params={params} />
322
+ </div>
323
+ );
324
+ }
325
+ ```