|
1 | 1 | # Video player library for Sunbird platform! |
2 | 2 | Contains Video player library components powered by angular. These components are designed to be used in sunbird consumption platforms *(mobile app, web portal, offline desktop app)* to drive reusability, maintainability hence reducing the redundant development effort significantly. |
3 | 3 |
|
4 | | -# Getting Started |
5 | | -For help getting started with a new Angular app, check out the [Angular CLI](https://angular.io/cli). |
6 | | -If you have an Angular ≥ 9 CLI project, you could simply use our schematics to add sunbird-video-player library to it. |
7 | 4 |
|
| 5 | +# Getting Started with different integrations steps |
| 6 | + 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. |
| 7 | + |
| 8 | +# Use as web components |
| 9 | +Any web application can use this library as a web component. It accepts couple of inputs and triggers some events back to the application. |
| 10 | + |
| 11 | +Import this library in any web application and use the custom component. |
| 12 | + |
| 13 | +Follow below-mentioned steps to use it in plain javascript project: |
| 14 | + |
| 15 | +- Insert [library](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/web-component/sunbird-video-player.js) as below: |
| 16 | + ```javascript |
| 17 | + <script type="text/javascript" src="sunbird-video-player.js"></script> |
| 18 | + ``` |
| 19 | +- 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. |
| 20 | +- Get sample playerConfig from here: [playerConfig](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/src/app/data.ts) |
| 21 | + |
| 22 | +- Pass the QuestionListAPI baseUrl for eg. |
| 23 | + ```javascript |
| 24 | + window.questionListUrl = 'https://staging.sunbirded.org/api/question/v1/list'; |
| 25 | + window.questionSetBaseUrl = 'https://staging.sunbirded.org/api/questionset'; |
| 26 | + ``` |
| 27 | + |
| 28 | +- Create a custom html element: `sunbird-video-player` |
| 29 | + ```javascript |
| 30 | + const videoElement = document.createElement('sunbird-video-player'); |
| 31 | + ``` |
| 32 | +
|
| 33 | +- Pass data using `player-config` |
| 34 | + ```javascript |
| 35 | + videoElement.setAttribute('player-config', JSON.stringify(playerConfig)); |
| 36 | + ``` |
| 37 | +
|
| 38 | + **Note:** Attribute should be in **string** type |
| 39 | +
|
| 40 | +- Listen for the output events: **playerEvent** and **telemetryEvent** |
| 41 | +
|
| 42 | + ```javascript |
| 43 | + videoElement.addEventListener('playerEvent', (event) => { |
| 44 | + console.log("On playerEvent", event); |
| 45 | + }); |
| 46 | + videoElement.addEventListener('telemetryEvent', (event) => { |
| 47 | + console.log("On telemetryEvent", event); |
| 48 | + }); |
| 49 | + ``` |
| 50 | +
|
| 51 | +- Append this element to existing element |
| 52 | + ```javascript |
| 53 | + const myPlayer = document.getElementById("my-player"); |
| 54 | + myPlayer.appendChild(qumlPlayerElement); |
| 55 | + ``` |
| 56 | +- Refer demo [example](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/web-component/index.html) |
| 57 | +
|
| 58 | +# Use as Web component in the Angular app |
| 59 | +
|
| 60 | +- Copy the assets files from web component folder |
| 61 | + [assets](https://github.com/project-sunbird/sunbird-video-player/tree/release-5.3.0/web-component/assets) to assets folder |
| 62 | +
|
| 63 | +- 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. |
| 64 | +
|
| 65 | +- Add the reflect-metadata script to index.html file |
| 66 | + ```javascript |
| 67 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/reflect-metadata/0.1.13/Reflect.min.js" |
| 68 | + integrity="sha512-jvbPH2TH5BSZumEfOJZn9IV+5bSwwN+qG4dvthYe3KCGC3/9HmxZ4phADbt9Pfcp+XSyyfc2vGZ/RMsSUZ9tbQ==" |
| 69 | + crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
| 70 | + ``` |
| 71 | +
|
| 72 | +- Import jquery in package json file(in dependencies) and do npm i |
| 73 | +
|
| 74 | + ```javascript |
| 75 | + "jquery": "^3.6.1", |
| 76 | + ``` |
| 77 | + |
| 78 | +- Import jquery in angular.json file inside scripts array |
| 79 | +
|
| 80 | + ```javascript |
| 81 | + "node_modules/jquery/dist/jquery.min.js" |
| 82 | + ``` |
| 83 | +
|
| 84 | +- Import CUSTOM_ELEMENTS_SCHEMA in app module |
| 85 | +
|
| 86 | + ```javascript |
| 87 | + import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; |
| 88 | + ``` |
| 89 | +
|
| 90 | +- Import sunbird-video-player in component |
| 91 | + ```bash |
| 92 | + <sunbird-video-player [playerConfig]="playerConfig" (playerEvent)="playerEvents($event)" |
| 93 | + (telemetryEvent)="playerTelemetryEvents($event)"></sunbird-video-player> |
| 94 | + ``` |
| 95 | +
|
| 96 | +- Provide input to render VIDEO player |
| 97 | +
|
| 98 | +Use the mock config in your component to send input to VIDEO player |
| 99 | +Click to see the mock - [playerConfig](https://github.com/project-sunbird/sunbird-video-player/blob/release-5.3.0/src/app/data.ts) |
| 100 | +**Note:** : Send input config as string |
| 101 | +
|
| 102 | +# Use as Angular library in angular app |
8 | 103 | ## Step 1: Installation |
9 | 104 |
|
10 | 105 | Just run the following: |
@@ -227,7 +322,10 @@ var playerConfig = { |
227 | 322 |
|
228 | 323 | <br /><br /> |
229 | 324 |
|
230 | | -# Mobile app integration steps |
| 325 | +# Use as Web component in Mobile app |
| 326 | +For existing apps, follow these steps [steps](README.md#use-as-web-component--in-the-angular-app) to begin using. |
| 327 | + |
| 328 | +# Use as Angular library in Mobile app |
231 | 329 | For existing apps, follow these steps to begin using. |
232 | 330 |
|
233 | 331 | ## Step 1: Install the packages |
@@ -257,50 +355,4 @@ Click to see the input data - [playerConfig](README.md#step-4-send-input-to-rend |
257 | 355 | 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) |
258 | 356 | <br /><br /> |
259 | 357 |
|
260 | | -# Use as web components |
261 | | - |
262 | | -Import this library in any web application and use the custom component. |
263 | | - |
264 | | -Follow below-mentioned steps to use it in plain javascript project: |
265 | | - |
266 | | -- Insert [library](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/web-component/sunbird-video-player.js) as below: |
267 | | - ```javascript |
268 | | - <script type="text/javascript" src="sunbird-video-player.js"></script> |
269 | | - ``` |
270 | | -- 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. |
271 | | -- Get sample playerConfig from here: [playerConfig](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/src/app/data.ts) |
272 | | - |
273 | | -- Pass the QuestionListAPI baseUrl for eg. |
274 | | - ```javascript |
275 | | - window.questionListUrl = 'https://staging.sunbirded.org/api/question/v1/list'; |
276 | | - window.questionSetBaseUrl = 'https://staging.sunbirded.org/api/questionset'; |
277 | | - ``` |
278 | | - |
279 | | -- Create a custom html element: `sunbird-video-player` |
280 | | - ```javascript |
281 | | - const videoElement = document.createElement('sunbird-video-player'); |
282 | | - ``` |
283 | | -
|
284 | | -- Pass data using `player-config` |
285 | | - ```javascript |
286 | | - videoElement.setAttribute('player-config', JSON.stringify(playerConfig)); |
287 | | - ``` |
288 | | -
|
289 | | - **Note:** Attribute should be in **string** type |
290 | | -
|
291 | | -- Listen for the output events: **playerEvent** and **telemetryEvent** |
292 | 358 |
|
293 | | - ```javascript |
294 | | - videoElement.addEventListener('playerEvent', (event) => { |
295 | | - console.log("On playerEvent", event); |
296 | | - }); |
297 | | - videoElement.addEventListener('telemetryEvent', (event) => { |
298 | | - console.log("On telemetryEvent", event); |
299 | | - }); |
300 | | - ``` |
301 | | -- Append this element to existing element |
302 | | - ```javascript |
303 | | - const myPlayer = document.getElementById("my-player"); |
304 | | - myPlayer.appendChild(qumlPlayerElement); |
305 | | - ``` |
306 | | -- Refer demo [example](https://github.com/project-sunbird/sunbird-video-player/blob/release-4.3.0/web-component/index.html) |
|
0 commit comments