@jeraldj/sunbird-video-player-web-component 2.0.0
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 +856 -0
- package/assets/video-player/package.json +18 -0
- package/assets/video-player/styles.css +13 -0
- package/assets/video-player/sunbird-video-player.js +1055 -0
- package/package.json +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
# The Video player library for Sunbird platform!
|
|
2
|
+
|
|
3
|
+
The Video player library is powered by Angular. This player is primarily designed to be used on Sunbird consumption platforms _(mobile app, web portal, offline desktop app)_ to drive reusability and maintainability, hence reducing the redundant development effort significantly, and it can be integrated with any platform irrespective of the platforms and the frontend frameworks. It is exported not only as an angular library but also as a web component.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Getting Started with different integrations steps
|
|
9
|
+
|
|
10
|
+
The video player can be integrated as a web component and also as an angular library in angular application projects and it can also be integrated into any mobile framework as a web component.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Use as web components
|
|
15
|
+
|
|
16
|
+
Any web based application can use this library as a web component. It accepts player config as input and triggers player and telemetry events back to the application.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Import this library in any web application and use the custom component.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Follow below-mentioned steps to use it in plain javascript project:
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
- Insert [library](https://github.com/Sunbird-Knowlg/sunbird-video-player/blob/release-5.5.0/web-component/sunbird-video-player.js) as below:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
|
|
32
|
+
<script type="text/javascript" src="sunbird-video-player.js"></script>
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Add JQuery library to the index.html either from cdn or from local
|
|
37
|
+
|
|
38
|
+
- Create a asset folder and copy all the files from [here](https://github.com/Sunbird-Knowlg/sunbird-video-player/tree/release-5.5.0/web-component/assets), library requires these assets internally to work well.
|
|
39
|
+
|
|
40
|
+
- Get sample playerConfig from here: [playerConfig](https://github.com/Sunbird-Knowlg/sunbird-video-player/blob/release-5.5.0/src/app/data.ts)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
- Pass the QuestionListAPI baseUrl if your content is interactive otherwise you can skip this step for eg.
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
|
|
48
|
+
window.questionListUrl = 'https://staging.sunbirded.org/api/question/v1/list';
|
|
49
|
+
|
|
50
|
+
window.questionSetBaseUrl = 'https://staging.sunbirded.org/api/questionset';
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- Create a custom html element: `sunbird-video-player`
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
|
|
58
|
+
const videoElement = document.createElement('sunbird-video-player');
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
- Pass data using `player-config`
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
|
|
68
|
+
videoElement.setAttribute('player-config', JSON.stringify(playerConfig));
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
**Note:** Attribute should be in **string** type
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
- Listen for the output events: **playerEvent** and **telemetryEvent**
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
|
|
84
|
+
videoElement.addEventListener('playerEvent', (event) => {
|
|
85
|
+
|
|
86
|
+
console.log("On playerEvent", event);
|
|
87
|
+
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
videoElement.addEventListener('telemetryEvent', (event) => {
|
|
91
|
+
|
|
92
|
+
console.log("On telemetryEvent", event);
|
|
93
|
+
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
- Append this element to existing element
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
|
|
104
|
+
const myPlayer = document.getElementById("my-player");
|
|
105
|
+
|
|
106
|
+
myPlayer.appendChild(qumlPlayerElement);
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Refer demo [example](https://github.com/Sunbird-Knowlg/sunbird-video-player/blob/release-5.5.0/web-component-demo/index.html)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# Use as Web component in the Angular app
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
- Run command
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
|
|
122
|
+
npm i @project-sunbird/sunbird-video-player-web-component
|
|
123
|
+
|
|
124
|
+
npm i reflect-metadata
|
|
125
|
+
|
|
126
|
+
npm i jquery
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
- Add these entries in angular json file inside assets, scripts and styles like below
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
|
|
137
|
+
"assets": [
|
|
138
|
+
|
|
139
|
+
"src/favicon.ico",
|
|
140
|
+
|
|
141
|
+
"src/assets",
|
|
142
|
+
|
|
143
|
+
{
|
|
144
|
+
|
|
145
|
+
"glob": "**/*.*",
|
|
146
|
+
|
|
147
|
+
"input": "./node_modules/@project-sunbird/sunbird-video-player-web-component/assets",
|
|
148
|
+
|
|
149
|
+
"output": "/assets/"
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
],
|
|
154
|
+
|
|
155
|
+
"styles": [
|
|
156
|
+
|
|
157
|
+
"src/styles.scss",
|
|
158
|
+
|
|
159
|
+
"node_modules/@project-sunbird/sunbird-video-player-web-component/styles.css"
|
|
160
|
+
|
|
161
|
+
],
|
|
162
|
+
|
|
163
|
+
"scripts": [
|
|
164
|
+
|
|
165
|
+
"node_modules/reflect-metadata/Reflect.js",
|
|
166
|
+
"node_modules/jquery/dist/jquery.min.js",
|
|
167
|
+
"node_modules/@project-sunbird/sunbird-epub-player-web-component/sunbird-video-player.js"
|
|
168
|
+
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
- Import CUSTOM_ELEMENTS_SCHEMA in app module and add it to the NgModule as part of schemas like below
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
```javascript
|
|
182
|
+
|
|
183
|
+
...
|
|
184
|
+
|
|
185
|
+
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
186
|
+
|
|
187
|
+
...
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@NgModule({
|
|
192
|
+
|
|
193
|
+
...
|
|
194
|
+
|
|
195
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
196
|
+
|
|
197
|
+
...
|
|
198
|
+
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
- Integrating sunbird-video-player web component in angular component
|
|
208
|
+
|
|
209
|
+
Create a viewChild in html template of the angular component like
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
<div #video></div>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
Refer the viewChild in ts file of the component and create the video player using document.createElement, then attach the player config and listen to the player and telemetry events like below and since we are rendering using viewChild these steps should be under ngAfterViewInit hook of the angular component.
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
....
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@ViewChild('video') video: ElementRef;
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
....
|
|
242
|
+
|
|
243
|
+
ngAfterViewInit() {
|
|
244
|
+
|
|
245
|
+
const playerConfig = <Config need be added>;
|
|
246
|
+
|
|
247
|
+
const epubElement = document.createElement('sunbird-video-player');
|
|
248
|
+
|
|
249
|
+
epubElement.setAttribute('player-config', JSON.stringify(playerConfig));
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
epubElement.addEventListener('playerEvent', (event) => {
|
|
254
|
+
|
|
255
|
+
console.log("On playerEvent", event);
|
|
256
|
+
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
epubElement.addEventListener('telemetryEvent', (event) => {
|
|
262
|
+
|
|
263
|
+
console.log("On telemetryEvent", event);
|
|
264
|
+
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
this.video.nativeElement.append(epubElement);
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
....
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
**Note:** : Click to see the mock - [playerConfig](https://github.com/Sunbird-Knowlg/sunbird-video-player/blob/release-5.5.0/src/app/data.ts) and send input config as string
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
# Use as Angular library in angular app
|
|
284
|
+
|
|
285
|
+
# Getting Started with different integrations steps
|
|
286
|
+
The Video player can be integrated as web component in plain javascript projects and as web component in angular apps and also as angular library in angular and mobile applications.
|
|
287
|
+
|
|
288
|
+
# Use as web components
|
|
289
|
+
Any web application can use this library as a web component. It accepts couple of inputs and triggers some events back to the application.
|
|
290
|
+
|
|
291
|
+
Import this library in any web application and use the custom component.
|
|
292
|
+
|
|
293
|
+
Follow below-mentioned steps to use it in plain javascript project:
|
|
294
|
+
|
|
295
|
+
- Insert [library](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/web-component/sunbird-video-player.js) as below:
|
|
296
|
+
```javascript
|
|
297
|
+
<script type="text/javascript" src="sunbird-video-player.js"></script>
|
|
298
|
+
```
|
|
299
|
+
- Create a asset folder and copy all the files from [here](https://github.com/project-sunbird/sunbird-video-player/tree/release-4.3.0/web-component/assets), library requires these assets internally to work well.
|
|
300
|
+
- Get sample playerConfig from here: [playerConfig](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/src/app/data.ts)
|
|
301
|
+
|
|
302
|
+
- Pass the QuestionListAPI baseUrl for eg.
|
|
303
|
+
```javascript
|
|
304
|
+
window.questionListUrl = 'https://staging.sunbirded.org/api/question/v1/list';
|
|
305
|
+
window.questionSetBaseUrl = 'https://staging.sunbirded.org/api/questionset';
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
- Create a custom html element: `sunbird-video-player`
|
|
309
|
+
```javascript
|
|
310
|
+
const videoElement = document.createElement('sunbird-video-player');
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
- Pass data using `player-config`
|
|
314
|
+
```javascript
|
|
315
|
+
videoElement.setAttribute('player-config', JSON.stringify(playerConfig));
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Note:** Attribute should be in **string** type
|
|
319
|
+
|
|
320
|
+
- Listen for the output events: **playerEvent** and **telemetryEvent**
|
|
321
|
+
|
|
322
|
+
```javascript
|
|
323
|
+
videoElement.addEventListener('playerEvent', (event) => {
|
|
324
|
+
console.log("On playerEvent", event);
|
|
325
|
+
});
|
|
326
|
+
videoElement.addEventListener('telemetryEvent', (event) => {
|
|
327
|
+
console.log("On telemetryEvent", event);
|
|
328
|
+
});
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
- Append this element to existing element
|
|
332
|
+
```javascript
|
|
333
|
+
const myPlayer = document.getElementById("my-player");
|
|
334
|
+
myPlayer.appendChild(qumlPlayerElement);
|
|
335
|
+
```
|
|
336
|
+
- Refer demo [example](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/web-component/index.html)
|
|
337
|
+
|
|
338
|
+
# Use as Web component in the Angular app
|
|
339
|
+
|
|
340
|
+
- Copy the assets files from web component folder
|
|
341
|
+
[assets](https://github.com/project-sunbird/sunbird-video-player/tree/release-5.3.0/web-component/assets) to assets folder
|
|
342
|
+
|
|
343
|
+
- Create libs/sunbird-video-player folder inside assets folder, and copy [sunbird-video-player.js](https://github.com/project-sunbird/sunbird-video-player/blob/release-5.3.0/web-component/sunbird-video-player.js) and [styles.css](https://github.com/project-sunbird/sunbird-video-player/blob/release-5.3.0/web-component/styles.css). and Add/import these entries in angular json file inside scripts and styles respectively.
|
|
344
|
+
|
|
345
|
+
- Add the reflect-metadata script to index.html file
|
|
346
|
+
```javascript
|
|
347
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/reflect-metadata/0.1.13/Reflect.min.js"
|
|
348
|
+
integrity="sha512-jvbPH2TH5BSZumEfOJZn9IV+5bSwwN+qG4dvthYe3KCGC3/9HmxZ4phADbt9Pfcp+XSyyfc2vGZ/RMsSUZ9tbQ=="
|
|
349
|
+
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
- Import jquery in package json file(in dependencies) and do npm i
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
"jquery": "^3.6.1",
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
- Import jquery in angular.json file inside scripts array
|
|
359
|
+
|
|
360
|
+
```javascript
|
|
361
|
+
"node_modules/jquery/dist/jquery.min.js"
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
- Import CUSTOM_ELEMENTS_SCHEMA in app module
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
- Import sunbird-video-player in component
|
|
371
|
+
```bash
|
|
372
|
+
<sunbird-video-player [playerConfig]="playerConfig" (playerEvent)="playerEvents($event)"
|
|
373
|
+
(telemetryEvent)="playerTelemetryEvents($event)"></sunbird-video-player>
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
- Provide input to render VIDEO player
|
|
377
|
+
|
|
378
|
+
Use the mock config in your component to send input to VIDEO player
|
|
379
|
+
Click to see the mock - [playerConfig](https://github.com/project-sunbird/sunbird-video-player/blob/release-5.3.0/src/app/data.ts)
|
|
380
|
+
**Note:** : Send input config as string
|
|
381
|
+
|
|
382
|
+
# Use as Angular library in angular app
|
|
383
|
+
## Step 1: Installation
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
Just run the following:
|
|
388
|
+
|
|
389
|
+
```red
|
|
390
|
+
|
|
391
|
+
ng add @project-sunbird/sunbird-video-player-v9
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
It will install sunbird-video-player for the default application specified in your `angular.json`. If you have multiple projects and you want to target a specific application, you could specify the `--project` option
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
```red
|
|
402
|
+
|
|
403
|
+
ng add @project-sunbird/sunbird-video-player-v9 --project myProject
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Manual installation
|
|
408
|
+
|
|
409
|
+
If you prefer not to use schematics or want to add `sunbird-video-player-v9` to an older project, you'll need to do the following:
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
<details>
|
|
414
|
+
|
|
415
|
+
<summary>Click here to show detailed instructions!</summary>
|
|
416
|
+
|
|
417
|
+
#### 1. Install the packages:
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
|
|
423
|
+
npm install @project-sunbird/sunbird-video-player-v9 --save
|
|
424
|
+
|
|
425
|
+
npm install @project-sunbird/sunbird-quml-player-v9 --save
|
|
426
|
+
|
|
427
|
+
npm install @project-sunbird/sb-styles --save
|
|
428
|
+
|
|
429
|
+
npm install @project-sunbird/client-services --save
|
|
430
|
+
|
|
431
|
+
npm install lodash-es --save
|
|
432
|
+
|
|
433
|
+
npm install ngx-bootstrap --save
|
|
434
|
+
|
|
435
|
+
npm install jquery --save
|
|
436
|
+
|
|
437
|
+
npm install video.js --save
|
|
438
|
+
|
|
439
|
+
npm install videojs-contrib-quality-levels --save
|
|
440
|
+
|
|
441
|
+
npm install videojs-http-source-selector --save
|
|
442
|
+
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
### 2: Include the styles, scripts and assets in angular.json
|
|
448
|
+
|
|
449
|
+
"styles": [
|
|
450
|
+
|
|
451
|
+
...
|
|
452
|
+
|
|
453
|
+
...
|
|
454
|
+
|
|
455
|
+
"src/styles.css",
|
|
456
|
+
|
|
457
|
+
"./node_modules/@project-sunbird/sb-styles/assets/_styles.scss",
|
|
458
|
+
|
|
459
|
+
"./node_modules/video.js/dist/video-js.min.css",
|
|
460
|
+
|
|
461
|
+
"./node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/videojs.markers.min.css",
|
|
462
|
+
|
|
463
|
+
"./node_modules/videojs-http-source-selector/dist/videojs-http-source-selector.css"
|
|
464
|
+
|
|
465
|
+
],
|
|
466
|
+
|
|
467
|
+
"scripts": [
|
|
468
|
+
|
|
469
|
+
...
|
|
470
|
+
|
|
471
|
+
...
|
|
472
|
+
|
|
473
|
+
"node_modules/jquery/dist/jquery.min.js",
|
|
474
|
+
|
|
475
|
+
"node_modules/video.js/dist/video.js",
|
|
476
|
+
|
|
477
|
+
"node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/videojs-markers.js",
|
|
478
|
+
|
|
479
|
+
"node_modules/videojs-contrib-quality-levels/dist/videojs-contrib-quality-levels.min.js",
|
|
480
|
+
|
|
481
|
+
"node_modules/videojs-http-source-selector/dist/videojs-http-source-selector.min.js"
|
|
482
|
+
|
|
483
|
+
]
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
Add following under architect.build.assets
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
{
|
|
492
|
+
|
|
493
|
+
...
|
|
494
|
+
|
|
495
|
+
"build": {
|
|
496
|
+
|
|
497
|
+
"builder": "@angular-devkit/build-angular:browser",
|
|
498
|
+
|
|
499
|
+
"options": {
|
|
500
|
+
|
|
501
|
+
...
|
|
502
|
+
|
|
503
|
+
...
|
|
504
|
+
|
|
505
|
+
"assets": [
|
|
506
|
+
|
|
507
|
+
...
|
|
508
|
+
|
|
509
|
+
...
|
|
510
|
+
|
|
511
|
+
{
|
|
512
|
+
|
|
513
|
+
"glob": "**/*.*",
|
|
514
|
+
|
|
515
|
+
"input": "./node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/",
|
|
516
|
+
|
|
517
|
+
"output": "/assets/"
|
|
518
|
+
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
{
|
|
522
|
+
|
|
523
|
+
"glob": "**/*",
|
|
524
|
+
|
|
525
|
+
"input": "node_modules/@project-sunbird/sunbird-quml-player-v9/lib/assets/",
|
|
526
|
+
|
|
527
|
+
"output": "/assets/"
|
|
528
|
+
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
],
|
|
532
|
+
|
|
533
|
+
"styles": [
|
|
534
|
+
|
|
535
|
+
...
|
|
536
|
+
|
|
537
|
+
"./node_modules/@project-sunbird/sb-styles/assets/_styles.scss",
|
|
538
|
+
|
|
539
|
+
"./node_modules/video.js/dist/video-js.min.css",
|
|
540
|
+
|
|
541
|
+
"./node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/videojs.markers.min.css",
|
|
542
|
+
|
|
543
|
+
"./node_modules/videojs-http-source-selector/dist/videojs-http-source-selector.css"
|
|
544
|
+
|
|
545
|
+
],
|
|
546
|
+
|
|
547
|
+
"scripts": [
|
|
548
|
+
|
|
549
|
+
...
|
|
550
|
+
|
|
551
|
+
"node_modules/jquery/dist/jquery.min.js",
|
|
552
|
+
|
|
553
|
+
"node_modules/video.js/dist/video.js",
|
|
554
|
+
|
|
555
|
+
"node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/videojs-markers.js",
|
|
556
|
+
|
|
557
|
+
"node_modules/videojs-contrib-quality-levels/dist/videojs-contrib-quality-levels.min.js",
|
|
558
|
+
|
|
559
|
+
"node_modules/videojs-http-source-selector/dist/videojs-http-source-selector.min.js",
|
|
560
|
+
|
|
561
|
+
"dist/sunbird-video-player/lib/assets/videojs-transcript-click.min.js"
|
|
562
|
+
|
|
563
|
+
]
|
|
564
|
+
|
|
565
|
+
...
|
|
566
|
+
|
|
567
|
+
...
|
|
568
|
+
|
|
569
|
+
},
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
</details>
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
## Step 2: Import the modules and components
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
Import the NgModule where you want to use. Also create a [question-cursor-implementation.service](../../src/app/question-cursor-implementation.service.ts)
|
|
582
|
+
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
import { SunbirdVideoPlayerModule } from '@project-sunbird/sunbird-video-player-v9';
|
|
586
|
+
|
|
587
|
+
import { QuestionCursor } from '@project-sunbird/sunbird-quml-player-v9';
|
|
588
|
+
|
|
589
|
+
import { QuestionCursorImplementationService } from './question-cursor-implementation.service';
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
@NgModule({
|
|
594
|
+
|
|
595
|
+
...
|
|
596
|
+
|
|
597
|
+
imports: [SunbirdVideoPlayerModule],
|
|
598
|
+
|
|
599
|
+
providers: [{ provide: QuestionCursor, useClass: QuestionCursorImplementationService }],
|
|
600
|
+
|
|
601
|
+
...
|
|
602
|
+
|
|
603
|
+
})
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
export class TestAppModule { }
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
## Step 3: Send input to render VIDEO player
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
Use the mock config in your component to send input to VIDEO player
|
|
620
|
+
|
|
621
|
+
Click to see the mock - [playerConfig](https://github.com/Sunbird-Knowlg/sunbird-video-player/blob/release-5.1.0/src/app/data.ts)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
## Player config
|
|
626
|
+
|
|
627
|
+
```js
|
|
628
|
+
|
|
629
|
+
var playerConfig = {
|
|
630
|
+
|
|
631
|
+
"context": {
|
|
632
|
+
|
|
633
|
+
"mode": "play", // To identify preview used by the user to play/edit/preview
|
|
634
|
+
|
|
635
|
+
"authToken": "", // Auth key to make api calls
|
|
636
|
+
|
|
637
|
+
"sid": "7283cf2e-d215-9944-b0c5-269489c6fa56", // User sessionid on portal or mobile
|
|
638
|
+
|
|
639
|
+
"did": "3c0a3724311fe944dec5df559cc4e006", // Unique id to identify the device or browser
|
|
640
|
+
|
|
641
|
+
"uid": "anonymous", // Current logged in user id
|
|
642
|
+
|
|
643
|
+
"channel": "505c7c48ac6dc1edc9b08f21db5a571d", // Unique id of the channel(Channel ID)
|
|
644
|
+
|
|
645
|
+
"pdata": {
|
|
646
|
+
|
|
647
|
+
"id": "sunbird.portal", // Producer ID. For ex: For sunbird it would be "portal" or "genie"
|
|
648
|
+
|
|
649
|
+
"ver": "3.2.12", // Version of the App
|
|
650
|
+
|
|
651
|
+
"pid": "sunbird-portal.contentplayer" // Optional. In case the component is distributed, then which instance of that component
|
|
652
|
+
|
|
653
|
+
},
|
|
654
|
+
|
|
655
|
+
"contextRollup": { // Defines the content roll up data
|
|
656
|
+
|
|
657
|
+
"l1": "505c7c48ac6dc1edc9b08f21db5a571d"
|
|
658
|
+
|
|
659
|
+
},
|
|
660
|
+
|
|
661
|
+
"tags": [ // Defines the tags data
|
|
662
|
+
|
|
663
|
+
""
|
|
664
|
+
|
|
665
|
+
],
|
|
666
|
+
|
|
667
|
+
"cdata": [], // Defines correlation data
|
|
668
|
+
|
|
669
|
+
"timeDiff": 0, // Defines the time difference
|
|
670
|
+
|
|
671
|
+
"objectRollup": {}, // Defines the object roll up data
|
|
672
|
+
|
|
673
|
+
"host": "", // Defines the from which domain content should be load
|
|
674
|
+
|
|
675
|
+
"endpoint": "", // Defines the end point
|
|
676
|
+
|
|
677
|
+
"userData": { // Defines the user data firstname & lastname
|
|
678
|
+
|
|
679
|
+
"firstName": "",
|
|
680
|
+
|
|
681
|
+
"lastName": ""
|
|
682
|
+
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
"config": {
|
|
688
|
+
|
|
689
|
+
"traceId": "afhjgh", // Defines trace id
|
|
690
|
+
|
|
691
|
+
"sideMenu": {
|
|
692
|
+
|
|
693
|
+
"showShare": true, // show/hide share button in side menu. default value is true
|
|
694
|
+
|
|
695
|
+
"showDownload": true, // show/hide download button in side menu. default value is true
|
|
696
|
+
|
|
697
|
+
"showReplay": true, // show/hide replay button in side menu. default value is true
|
|
698
|
+
|
|
699
|
+
"showExit": true, // show/hide exit button in side menu. default value is true
|
|
700
|
+
|
|
701
|
+
},
|
|
702
|
+
|
|
703
|
+
// tslint:disable-next-line:max-line-length
|
|
704
|
+
|
|
705
|
+
"transcripts": [] // for default selection we need this , ex: ['kn', 'en'] the last element in the array will be used for default selection and no need of default selection than no need send this in config or send empty array [] or ['off']
|
|
706
|
+
|
|
707
|
+
},
|
|
708
|
+
|
|
709
|
+
"metadata": { // Content metadata json object (from API response take -> response.result.content)
|
|
710
|
+
|
|
711
|
+
"transcripts": [] // Defines the details of the transcripts data array and each object in array conatins details of language,languageCode, identifier, artifactUrl of each transcript
|
|
712
|
+
|
|
713
|
+
},
|
|
714
|
+
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
## Telemetry property description
|
|
720
|
+
|
|
721
|
+
|Property Name| Description| Default Value
|
|
722
|
+
|
|
723
|
+
|--|----------------------|--|
|
|
724
|
+
|
|
725
|
+
| `context` | It is an `object` it contains the `uid`,`did`,`sid`,`mode` etc., these will be logged inside the telemetry | ```{}``` |
|
|
726
|
+
|
|
727
|
+
| `mode` | It is `string` to identify preview used by the user to play/edit/preview | ```play```|
|
|
728
|
+
|
|
729
|
+
| `authToken` | It is `string` and Auth key to make api calls | ```''```|
|
|
730
|
+
|
|
731
|
+
| `sid` | It is `string` and User sessionid on portal or mobile | ```''```|
|
|
732
|
+
|
|
733
|
+
| `did` | It is `string` and Unique id to identify the device or browser| ```''```|
|
|
734
|
+
|
|
735
|
+
| `uid` | It is `string` and Current logged in user id| ```''```|
|
|
736
|
+
|
|
737
|
+
| `channel` | It is `string` which defines channel identifier to know which channel is currently using.| `in.sunbird` |
|
|
738
|
+
|
|
739
|
+
| `pdata` | It is an `object` which defines the producer information it should have identifier and version and canvas will log in the telemetry| ```{'id':'in.sunbird', 'ver':'1.0'}```|
|
|
740
|
+
|
|
741
|
+
| `contextRollup` | It is an `object` which defines content roll up data | ```{}```|
|
|
742
|
+
|
|
743
|
+
| `tags` | It is an `array` which defines the tag data | ```[]```|
|
|
744
|
+
|
|
745
|
+
| `objectRollup` | It is an `object` which defines object rollup data | ```{}```|
|
|
746
|
+
|
|
747
|
+
| `host` | It is `string` which defines the from which domain content should be load|```window.location.origin``` |
|
|
748
|
+
|
|
749
|
+
| `userData` | It is an `object` which defines user data | ```{}```|
|
|
750
|
+
|
|
751
|
+
| `cdata` | It is an `array` which defines the correlation data | ```[]```|
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
## Config property description
|
|
756
|
+
|
|
757
|
+
|Property Name| Description| Default Value
|
|
758
|
+
|
|
759
|
+
|--|----------------------|--|
|
|
760
|
+
|
|
761
|
+
| `config` | It is an `object` it contains the `sideMenu`, these will be used to configure the canvas | ```{ traceId: "12345", sideMenu: {"showShare": true, "showDownload": true, "showReplay": true, "showExit": true}}``` |
|
|
762
|
+
|
|
763
|
+
| `config.traceId` | It is `string` which defines the trace id | ```''```|
|
|
764
|
+
|
|
765
|
+
| `config.sideMenu.showShare` | It is `boolean` to show/hide share button in side menu| ```true```|
|
|
766
|
+
|
|
767
|
+
| `config.sideMenu.showDownload` | It is `boolean` to show/hide download button in side menu| ```true```|
|
|
768
|
+
|
|
769
|
+
| `config.sideMenu.showReplay` | It is `boolean` to show/hide replay button in side menu| ```true```|
|
|
770
|
+
|
|
771
|
+
| `config.sideMenu.showExit` | It is `boolean` to show/hide exit button in side menu| ```true```|
|
|
772
|
+
|
|
773
|
+
| `config.transcripts` | It is `Array` which defines the transcripts default selection details| ```[]```|
|
|
774
|
+
|
|
775
|
+
| `metadata` | It is an `object` which defines content metadata json object (from API response take -> response.result.content) | ```{}```|
|
|
776
|
+
|
|
777
|
+
| `metadata.transcripts` | It is `Array` which is having the details of the transcripts data | ```[]```|
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
## Available components
|
|
782
|
+
|
|
783
|
+
|Feature| Notes| Selector|Code|Input|Output
|
|
784
|
+
|
|
785
|
+
|--|--|--|------------------------------------------------------------------------------------------|---|--|
|
|
786
|
+
|
|
787
|
+
| Video Player | Can be used to render videos | sunbird-video-player| *`<sunbird-video-player [playerConfig]="playerConfig"><sunbird-video-player>`*|playerConfig,action|playerEvent, telemetryEvent|
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
<br /><br />
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
# Use as Web component in Mobile app
|
|
796
|
+
|
|
797
|
+
For existing apps, follow these steps [steps](README.md#use-as-web-component--in-the-angular-app) to begin using.
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
# Use as Angular library in Mobile app
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
For existing apps, follow these steps to begin using.
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
## Step 1: Install the packages
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
Click to see the steps - [InstallPackages](README.md#step-1-install-the-packages)
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
## Step 2: Include the sb-styles and assets in angular.json
|
|
817
|
+
|
|
818
|
+
Click to see the steps - [IncludeStyles](README.md#step-2-include-the-styles-scripts-and-assets-in-angularjson) , but use
|
|
819
|
+
|
|
820
|
+
`src/global.scss` instead of `src/styles.css` in styles.
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
## Step 3: Import the modules and components
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
Click to see the steps - [Import](README.md#step-3-import-the-modules-and-components)
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
## Step 4: Import in component
|
|
834
|
+
|
|
835
|
+
<sunbird-video-player [playerConfig]="playerConfig" (playerEvent)="playerEvents($event)"
|
|
836
|
+
|
|
837
|
+
(telemetryEvent)="playerTelemetryEvents($event)"></sunbird-video-player>
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
> Note : An additional property named `action` can be added to the above statement to implement pause and play functionality for the video player.
|
|
842
|
+
|
|
843
|
+
## Step 5: Send input to render VIDEO player
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
Click to see the input data - [playerConfig](README.md#step-4-send-input-to-render-video-player)
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
## Sample code
|
|
853
|
+
|
|
854
|
+
Click to see the sample code - [sampleCode](https://github.com/Sunbird-Ed/SunbirdEd-mobile-app/blob/release-4.8.0/src/app/player/player.page.html)
|
|
855
|
+
|
|
856
|
+
<br /><br />
|