@viewlift/player-backup 0.0.98 → 1.0.0-lighteningjs
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/.babelrc +8 -0
- package/.browserslistrc +2 -0
- package/README.md +29 -0
- package/babel.config.json +8 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.esm.js +1 -0
- package/dist/utility.d.ts +6 -0
- package/package.json +30 -15
- package/rollup.config.mjs +31 -0
- package/src/index.ts +261 -0
- package/src/utility.ts +109 -0
- package/tsconfig.json +13 -0
- package/cjs/autoNextVideo-823821e8.js +0 -1
- package/cjs/bundle.css +0 -657
- package/cjs/caption-settings-67212c17.js +0 -1
- package/cjs/caption-settings-d42c056e.js +0 -1
- package/cjs/debugSelection-cbfdabb7.js +0 -1
- package/cjs/dvr_skin-f7f770ae.js +0 -1
- package/cjs/error-26d5a3c3.js +0 -1
- package/cjs/features-164c3cc6.js +0 -1
- package/cjs/generic-8b99b151.js +0 -1
- package/cjs/icons-7afb9c13.js +0 -1
- package/cjs/index-3dfe6459.js +0 -1
- package/cjs/index.js +0 -1
- package/cjs/keyboardShortcuts-cfd998c2.js +0 -1
- package/cjs/loader-393b838a.js +0 -1
- package/cjs/multicam-21c9a90b.js +0 -1
- package/cjs/multicam-a41fe4a6.js +0 -1
- package/cjs/multicamv2-76d8530b.js +0 -1
- package/cjs/multicamv2-c148fa24.js +0 -1
- package/cjs/mwebPotrait-3c11d7cf.js +0 -1
- package/cjs/mwebPotraitTray-b9d5d45a.js +0 -1
- package/cjs/nextEpisodeButton-300afadc.js +0 -1
- package/cjs/nextEpisodeButton-b6e6586f.js +0 -1
- package/cjs/nondvr_skin-ef2cb3b2.js +0 -1
- package/cjs/playlist-925f808b.js +0 -1
- package/cjs/playlist-df87ca90.js +0 -1
- package/cjs/renditions-bc841552.js +0 -1
- package/cjs/resolution-6a9adf54.js +0 -1
- package/cjs/series-82ec79d3.js +0 -1
- package/cjs/series-9c237975.js +0 -1
- package/cjs/series-v2-24855152.js +0 -1
- package/cjs/series-v2-70137d8c.js +0 -1
- package/cjs/settings-icon-a63f46fc.js +0 -1
- package/cjs/settings-icon-e6a8feee.js +0 -1
- package/cjs/skin-225252ff.js +0 -1
- package/cjs/skin-39ab30e2.js +0 -1
- package/cjs/skin-83edff36.js +0 -1
- package/cjs/skin-84083352.js +0 -1
- package/cjs/skin-93a3e5ae.js +0 -1
- package/cjs/skin-983a2ea7.js +0 -1
- package/cjs/skin-afbec6d7.js +0 -1
- package/cjs/skin-ec49b877.js +0 -1
- package/cjs/skin-f225a42e.js +0 -1
- package/cjs/skin-fb394911.js +0 -1
- package/cjs/util-fa21734a.js +0 -1
- package/cjs/videoSelector-01a9ef43.js +0 -1
- package/cjs/videoSelector-fcdf11eb.js +0 -1
- package/esm/autoNextVideo-1672740e.js +0 -1
- package/esm/bundle.css +0 -657
- package/esm/caption-settings-2e47813b.js +0 -1
- package/esm/caption-settings-3eacf3a0.js +0 -1
- package/esm/debugSelection-2601b8b3.js +0 -1
- package/esm/dvr_skin-9cc1b144.js +0 -1
- package/esm/error-2395864b.js +0 -1
- package/esm/features-f86404ce.js +0 -1
- package/esm/generic-7c43020f.js +0 -1
- package/esm/icons-c18c70b7.js +0 -1
- package/esm/index-9f022e82.js +0 -1
- package/esm/index.js +0 -1
- package/esm/keyboardShortcuts-c06f3c7b.js +0 -1
- package/esm/loader-580278fe.js +0 -1
- package/esm/multicam-94da3759.js +0 -1
- package/esm/multicam-de741974.js +0 -1
- package/esm/multicamv2-0105c40f.js +0 -1
- package/esm/multicamv2-d006cffa.js +0 -1
- package/esm/mwebPotrait-3c1805d8.js +0 -1
- package/esm/mwebPotraitTray-5ab39989.js +0 -1
- package/esm/nextEpisodeButton-2ea69b56.js +0 -1
- package/esm/nextEpisodeButton-a1556cdf.js +0 -1
- package/esm/nondvr_skin-64be70e5.js +0 -1
- package/esm/playlist-032fbbf3.js +0 -1
- package/esm/playlist-7ecf432a.js +0 -1
- package/esm/renditions-97276745.js +0 -1
- package/esm/resolution-38cd4f5c.js +0 -1
- package/esm/series-041152aa.js +0 -1
- package/esm/series-977edced.js +0 -1
- package/esm/series-v2-0727ee8c.js +0 -1
- package/esm/series-v2-516c91c2.js +0 -1
- package/esm/settings-icon-0125bffd.js +0 -1
- package/esm/settings-icon-2b713fbf.js +0 -1
- package/esm/skin-2c638dc1.js +0 -1
- package/esm/skin-42c2f81d.js +0 -1
- package/esm/skin-5e2fa9d4.js +0 -1
- package/esm/skin-6093bfb3.js +0 -1
- package/esm/skin-665ec17e.js +0 -1
- package/esm/skin-93e320fc.js +0 -1
- package/esm/skin-b939c35e.js +0 -1
- package/esm/skin-cd537931.js +0 -1
- package/esm/skin-d5510f70.js +0 -1
- package/esm/skin-d6b00653.js +0 -1
- package/esm/util-d9f5a7be.js +0 -1
- package/esm/videoSelector-8889c58e.js +0 -1
- package/esm/videoSelector-8e258d45.js +0 -1
package/.babelrc
ADDED
package/.browserslistrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @viewlift/ligheningjs-video-player
|
|
2
|
+
|
|
3
|
+
A LightningJS video player component for Smart TV app development.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Video player component for LightningJS
|
|
7
|
+
- TypeScript support
|
|
8
|
+
- Easy to use in LightningJS-based projects
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
```bash
|
|
12
|
+
npm install @viewlift/ligheningjs-video-player
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
```ts
|
|
17
|
+
import { LightningVideoPlayer } from '@viewlift/ligheningjs-video-player';
|
|
18
|
+
|
|
19
|
+
const player = new LightningVideoPlayer();
|
|
20
|
+
player.play();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Build
|
|
24
|
+
```bash
|
|
25
|
+
npm run build
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
ISC
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("@viewlift/player-backup/esm/bundle.css");var t,e=function(t){return"lgTv"==t?"lg":"vizioTv"==t?"vizio":"xfinityX1"==t?"xfinityX1":"xbox"==t?"xBox":"samsung"};!function(t){t.LG="lgTv",t.Vizio="vizioTv",t.XfinityX1="xfinityX1",t.Xbox="xbox",t.Samsung="samsungTv"}(t||(t={}));var n=function(){function t(t){var e=this;this.listeners={},this.boundEmitters={},this.boundHandlerMap={},this.options=t,this.videoElement=document.createElement("video"),this.videoElement.id=t.playerId,this.videoElement.autoplay=!!t.autoplay,t.width&&(this.videoElement.width=t.width),t.height&&(this.videoElement.height=t.height),this.videoElement.style.display="block",this.videoElement.style.background="black";var n={play:this.onPlay,pause:this.onPause,ended:this.onEnded,timeupdate:this.onTimeupdate,error:this.onError,loadedmetadata:this.onLoadedmetadata,seeking:this.onSeeking,seeked:this.onSeeked,volumechange:this.onVolumechange};Object.keys(n).forEach(function(t){var i=n[t].bind(e);e.boundHandlerMap[t]=i,e.videoElement.addEventListener(t,i)})}return t.prototype.initialize=function(){return window.appMainConfig.apiBaseUrl,this.options.playerId,this.options.contentId,this.options.authToken,this.options.autoplay,this.options.profileId,this.options.deviceName,e(this.options.deviceName),window.appSettings.device,window.appMainConfig.internalName,!0},t.prototype.attachTo=function(t){t.appendChild(this.videoElement)},t.prototype.play=function(){this.videoElement.play()},t.prototype.pause=function(){this.videoElement.pause()},t.prototype.stop=function(){this.videoElement.pause(),this.videoElement.currentTime=0},t.prototype.destroy=function(){var t=this;this.videoElement.parentNode&&this.videoElement.parentNode.removeChild(this.videoElement),this.removeAllListeners(),Object.keys(this.boundHandlerMap).forEach(function(e){t.boundHandlerMap[e]&&(t.videoElement.removeEventListener(e,t.boundHandlerMap[e]),delete t.boundHandlerMap[e])})},Object.defineProperty(t.prototype,"element",{get:function(){return this.videoElement},enumerable:!1,configurable:!0}),t.prototype.onPlay=function(t){"function"==typeof this.options.onPlaybackSuccess&&this.options.onPlaybackSuccess()},t.prototype.onPause=function(t){},t.prototype.onEnded=function(t){"function"==typeof this.options.onPlaybackEnded&&this.options.onPlaybackEnded()},t.prototype.onTimeupdate=function(t){},t.prototype.onError=function(t){"function"==typeof this.options.onPlaybackError&&this.options.onPlaybackError(t)},t.prototype.onLoadedmetadata=function(t){},t.prototype.onSeeking=function(t){},t.prototype.onSeeked=function(t){},t.prototype.onVolumechange=function(t){},t.prototype.on=function(t,e){this.listeners[t]||(this.listeners[t]=[],this.boundEmitters[t]||(this.boundEmitters[t]=this.emitEvent(t),this.videoElement.addEventListener(t,this.boundEmitters[t]))),this.listeners[t].push(e)},t.prototype.off=function(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(function(t){return t!==e}),0===this.listeners[t].length&&(this.boundEmitters[t]&&(this.videoElement.removeEventListener(t,this.boundEmitters[t]),delete this.boundEmitters[t]),delete this.listeners[t]))},t.prototype.once=function(t,e){var n=this,i=function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];e.apply(void 0,o),n.off(t,i)};this.on(t,i)},t.prototype.emitEvent=function(t){var e=this;return function(n){e.listeners[t]&&e.listeners[t].forEach(function(t){return t(n)})}},t.prototype.removeAllListeners=function(){var t=this;Object.keys(this.listeners).forEach(function(e){t.boundEmitters[e]&&(t.videoElement.removeEventListener(e,t.boundEmitters[e]),delete t.boundEmitters[e])}),this.listeners={}},t}();exports.LightningVideoPlayer=n;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import '@viewlift/player-backup/esm/bundle.css';
|
|
2
|
+
export interface VideoPlayerOptions {
|
|
3
|
+
onPlaybackSuccess?: () => void;
|
|
4
|
+
onPlaybackEnded?: () => void;
|
|
5
|
+
onPlaybackError?: (error?: any) => void;
|
|
6
|
+
playerId: string;
|
|
7
|
+
contentId: string;
|
|
8
|
+
profileId: string;
|
|
9
|
+
deviceId: string;
|
|
10
|
+
authToken: string;
|
|
11
|
+
autoplay?: boolean;
|
|
12
|
+
controls?: boolean;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
deviceName: DeviceType;
|
|
16
|
+
}
|
|
17
|
+
declare enum DeviceType {
|
|
18
|
+
LG = "lgTv",
|
|
19
|
+
Vizio = "vizioTv",
|
|
20
|
+
XfinityX1 = "xfinityX1",
|
|
21
|
+
Xbox = "xbox",
|
|
22
|
+
Samsung = "samsungTv"
|
|
23
|
+
}
|
|
24
|
+
type EventHandler = (...args: any[]) => void;
|
|
25
|
+
type VideoPlayerEvent = 'play' | 'pause' | 'ended' | 'timeupdate' | 'error' | 'loadedmetadata' | 'seeking' | 'seeked' | 'volumechange';
|
|
26
|
+
export declare class LightningVideoPlayer {
|
|
27
|
+
/**
|
|
28
|
+
* Reinitialize the current videoElement with a new set of options and handle autoplay.
|
|
29
|
+
*/
|
|
30
|
+
private videoElement;
|
|
31
|
+
private options;
|
|
32
|
+
private listeners;
|
|
33
|
+
private boundEmitters;
|
|
34
|
+
private boundHandlerMap;
|
|
35
|
+
constructor(options: VideoPlayerOptions);
|
|
36
|
+
initialize(): boolean;
|
|
37
|
+
attachTo(container: HTMLElement): void;
|
|
38
|
+
play(): void;
|
|
39
|
+
pause(): void;
|
|
40
|
+
stop(): void;
|
|
41
|
+
destroy(): void;
|
|
42
|
+
get element(): HTMLVideoElement;
|
|
43
|
+
onPlay(e: Event): void;
|
|
44
|
+
onPause(e: Event): void;
|
|
45
|
+
onEnded(e: Event): void;
|
|
46
|
+
onTimeupdate(e: Event): void;
|
|
47
|
+
onError(e: Event): void;
|
|
48
|
+
onLoadedmetadata(e: Event): void;
|
|
49
|
+
onSeeking(e: Event): void;
|
|
50
|
+
onSeeked(e: Event): void;
|
|
51
|
+
onVolumechange(e: Event): void;
|
|
52
|
+
on(event: VideoPlayerEvent, handler: EventHandler): void;
|
|
53
|
+
off(event: VideoPlayerEvent, handler: EventHandler): void;
|
|
54
|
+
once(event: VideoPlayerEvent, handler: EventHandler): void;
|
|
55
|
+
private emitEvent;
|
|
56
|
+
private removeAllListeners;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"@viewlift/player-backup/esm/bundle.css";var t,e=function(t){return"lgTv"==t?"lg":"vizioTv"==t?"vizio":"xfinityX1"==t?"xfinityX1":"xbox"==t?"xBox":"samsung"};!function(t){t.LG="lgTv",t.Vizio="vizioTv",t.XfinityX1="xfinityX1",t.Xbox="xbox",t.Samsung="samsungTv"}(t||(t={}));var n=function(){function t(t){var e=this;this.listeners={},this.boundEmitters={},this.boundHandlerMap={},this.options=t,this.videoElement=document.createElement("video"),this.videoElement.id=t.playerId,this.videoElement.autoplay=!!t.autoplay,t.width&&(this.videoElement.width=t.width),t.height&&(this.videoElement.height=t.height),this.videoElement.style.display="block",this.videoElement.style.background="black";var n={play:this.onPlay,pause:this.onPause,ended:this.onEnded,timeupdate:this.onTimeupdate,error:this.onError,loadedmetadata:this.onLoadedmetadata,seeking:this.onSeeking,seeked:this.onSeeked,volumechange:this.onVolumechange};Object.keys(n).forEach(function(t){var i=n[t].bind(e);e.boundHandlerMap[t]=i,e.videoElement.addEventListener(t,i)})}return t.prototype.initialize=function(){return window.appMainConfig.apiBaseUrl,this.options.playerId,this.options.contentId,this.options.authToken,this.options.autoplay,this.options.profileId,this.options.deviceName,e(this.options.deviceName),window.appSettings.device,window.appMainConfig.internalName,!0},t.prototype.attachTo=function(t){t.appendChild(this.videoElement)},t.prototype.play=function(){this.videoElement.play()},t.prototype.pause=function(){this.videoElement.pause()},t.prototype.stop=function(){this.videoElement.pause(),this.videoElement.currentTime=0},t.prototype.destroy=function(){var t=this;this.videoElement.parentNode&&this.videoElement.parentNode.removeChild(this.videoElement),this.removeAllListeners(),Object.keys(this.boundHandlerMap).forEach(function(e){t.boundHandlerMap[e]&&(t.videoElement.removeEventListener(e,t.boundHandlerMap[e]),delete t.boundHandlerMap[e])})},Object.defineProperty(t.prototype,"element",{get:function(){return this.videoElement},enumerable:!1,configurable:!0}),t.prototype.onPlay=function(t){"function"==typeof this.options.onPlaybackSuccess&&this.options.onPlaybackSuccess()},t.prototype.onPause=function(t){},t.prototype.onEnded=function(t){"function"==typeof this.options.onPlaybackEnded&&this.options.onPlaybackEnded()},t.prototype.onTimeupdate=function(t){},t.prototype.onError=function(t){"function"==typeof this.options.onPlaybackError&&this.options.onPlaybackError(t)},t.prototype.onLoadedmetadata=function(t){},t.prototype.onSeeking=function(t){},t.prototype.onSeeked=function(t){},t.prototype.onVolumechange=function(t){},t.prototype.on=function(t,e){this.listeners[t]||(this.listeners[t]=[],this.boundEmitters[t]||(this.boundEmitters[t]=this.emitEvent(t),this.videoElement.addEventListener(t,this.boundEmitters[t]))),this.listeners[t].push(e)},t.prototype.off=function(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(function(t){return t!==e}),0===this.listeners[t].length&&(this.boundEmitters[t]&&(this.videoElement.removeEventListener(t,this.boundEmitters[t]),delete this.boundEmitters[t]),delete this.listeners[t]))},t.prototype.once=function(t,e){var n=this,i=function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];e.apply(void 0,o),n.off(t,i)};this.on(t,i)},t.prototype.emitEvent=function(t){var e=this;return function(n){e.listeners[t]&&e.listeners[t].forEach(function(t){return t(n)})}},t.prototype.removeAllListeners=function(){var t=this;Object.keys(this.listeners).forEach(function(e){t.boundEmitters[e]&&(t.videoElement.removeEventListener(e,t.boundEmitters[e]),delete t.boundEmitters[e])}),this.listeners={}},t}();export{n as LightningVideoPlayer};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getDeviceMaker: (deviceName: string) => "LG" | "Vizio" | "xfinityX1" | "Microsoft" | "Samsung";
|
|
2
|
+
export declare const getUserAgent: (deviceName: string) => "xfinityX1" | "SmartTV_LG_WebOS" | "SmartTV_Vizio_SmartCast" | "xboxOne" | "SmartTV_Samsung_Tizen";
|
|
3
|
+
export declare const getOSName: (deviceName: string) => "xfinityX1" | "WebOS" | "SmartCast" | "Windows" | "Tizen";
|
|
4
|
+
export declare const getDeviceShortName: (deviceName: string) => "xfinityX1" | "lg" | "vizio" | "xBox" | "samsung";
|
|
5
|
+
export declare const getDeviceFullName: (deviceName: string) => "xfinityX1" | "vizioTv" | "smart_tv_lg" | "windows_xbox" | "smart_tv_samsung";
|
|
6
|
+
export declare const getMacros: (width: any, height: any, deviceName: any, deviceId: any) => {};
|
package/package.json
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"name": "@viewlift/player-backup",
|
|
3
|
+
"version": "1.0.0-lighteningjs",
|
|
4
|
+
"description": "A LightningJS video player component for Smart TV apps.",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rollup -c",
|
|
10
|
+
"dev": "rollup -c -w",
|
|
11
|
+
"test": "echo \"No tests specified\" && exit 0"
|
|
12
|
+
},
|
|
13
|
+
"author": "ViewLift",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"LightningJS",
|
|
17
|
+
"SmartTV",
|
|
18
|
+
"video-player"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/core": "^7.24.4",
|
|
22
|
+
"@babel/preset-env": "^7.24.4",
|
|
23
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
24
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
25
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
26
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
27
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
28
|
+
"rollup": "^4.16.4",
|
|
29
|
+
"tslib": "^2.6.2",
|
|
30
|
+
"typescript": "^5.4.5"
|
|
31
|
+
}
|
|
17
32
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import terser from '@rollup/plugin-terser';
|
|
4
|
+
import typescript from '@rollup/plugin-typescript';
|
|
5
|
+
import babel from '@rollup/plugin-babel';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
input: 'src/index.ts',
|
|
9
|
+
output: [
|
|
10
|
+
{
|
|
11
|
+
file: 'dist/index.cjs.js',
|
|
12
|
+
format: 'cjs',
|
|
13
|
+
exports: 'auto',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
file: 'dist/index.esm.js',
|
|
17
|
+
format: 'esm',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
plugins: [
|
|
21
|
+
resolve(),
|
|
22
|
+
commonjs(),
|
|
23
|
+
typescript({ tsconfig: './tsconfig.json' }),
|
|
24
|
+
babel({
|
|
25
|
+
babelHelpers: 'bundled',
|
|
26
|
+
extensions: ['.js', '.ts'],
|
|
27
|
+
exclude: 'node_modules/**',
|
|
28
|
+
}),
|
|
29
|
+
terser(),
|
|
30
|
+
],
|
|
31
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// LightningJS-compatible Video Player Component (ES5 compatible)
|
|
2
|
+
|
|
3
|
+
import '@viewlift/player-backup/esm/bundle.css'
|
|
4
|
+
import { getDeviceFullName, getDeviceShortName,getMacros } from './utility';
|
|
5
|
+
export interface VideoPlayerOptions {
|
|
6
|
+
// Optional playback callbacks
|
|
7
|
+
onPlaybackSuccess?: () => void;
|
|
8
|
+
onPlaybackEnded?: () => void;
|
|
9
|
+
onPlaybackError?: (error?: any) => void;
|
|
10
|
+
playerId: string;
|
|
11
|
+
contentId: string;
|
|
12
|
+
profileId: string;
|
|
13
|
+
deviceId:string;
|
|
14
|
+
authToken: string
|
|
15
|
+
autoplay?: boolean;
|
|
16
|
+
controls?: boolean;
|
|
17
|
+
width?: number;
|
|
18
|
+
|
|
19
|
+
height?: number;
|
|
20
|
+
deviceName: DeviceType
|
|
21
|
+
// Event callbacks
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enum DeviceType {
|
|
25
|
+
LG = 'lgTv',
|
|
26
|
+
Vizio = 'vizioTv',
|
|
27
|
+
XfinityX1 = 'xfinityX1',
|
|
28
|
+
Xbox = 'xbox',
|
|
29
|
+
Samsung = 'samsungTv'
|
|
30
|
+
}
|
|
31
|
+
type EventHandler = (...args: any[]) => void;
|
|
32
|
+
|
|
33
|
+
type VideoPlayerEvent =
|
|
34
|
+
| 'play'
|
|
35
|
+
| 'pause'
|
|
36
|
+
| 'ended'
|
|
37
|
+
| 'timeupdate'
|
|
38
|
+
| 'error'
|
|
39
|
+
| 'loadedmetadata'
|
|
40
|
+
| 'seeking'
|
|
41
|
+
| 'seeked'
|
|
42
|
+
| 'volumechange';
|
|
43
|
+
|
|
44
|
+
export class LightningVideoPlayer {
|
|
45
|
+
/**
|
|
46
|
+
* Reinitialize the current videoElement with a new set of options and handle autoplay.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
private videoElement: HTMLVideoElement;
|
|
50
|
+
private options: VideoPlayerOptions;
|
|
51
|
+
private listeners: { [event: string]: EventHandler[] } = {};
|
|
52
|
+
private boundEmitters: { [event: string]: EventListener } = {};
|
|
53
|
+
private boundHandlerMap: { [K in VideoPlayerEvent]?: (e: Event) => void } = {};
|
|
54
|
+
|
|
55
|
+
constructor(options: VideoPlayerOptions) {
|
|
56
|
+
this.options = options;
|
|
57
|
+
this.videoElement = document.createElement('video');
|
|
58
|
+
this.videoElement.id = options.playerId;
|
|
59
|
+
this.videoElement.autoplay = !!options.autoplay;
|
|
60
|
+
if (options.width) this.videoElement.width = options.width;
|
|
61
|
+
if (options.height) this.videoElement.height = options.height;
|
|
62
|
+
this.videoElement.style.display = 'block';
|
|
63
|
+
this.videoElement.style.background = 'black';
|
|
64
|
+
|
|
65
|
+
// Attach class event handlers for all player events
|
|
66
|
+
const handlerMap: { [K in VideoPlayerEvent]: (e: Event) => void } = {
|
|
67
|
+
play: this.onPlay,
|
|
68
|
+
pause: this.onPause,
|
|
69
|
+
ended: this.onEnded,
|
|
70
|
+
timeupdate: this.onTimeupdate,
|
|
71
|
+
error: this.onError,
|
|
72
|
+
loadedmetadata: this.onLoadedmetadata,
|
|
73
|
+
seeking: this.onSeeking,
|
|
74
|
+
seeked: this.onSeeked,
|
|
75
|
+
volumechange: this.onVolumechange,
|
|
76
|
+
};
|
|
77
|
+
(Object.keys(handlerMap) as VideoPlayerEvent[]).forEach(event => {
|
|
78
|
+
const boundHandler = handlerMap[event].bind(this);
|
|
79
|
+
this.boundHandlerMap[event] = boundHandler;
|
|
80
|
+
this.videoElement.addEventListener(event, boundHandler);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
initialize() {
|
|
85
|
+
let configurationObject = {
|
|
86
|
+
apiBaseUrl: (window as any).appMainConfig.apiBaseUrl,
|
|
87
|
+
playerId: this.options.playerId,
|
|
88
|
+
videoId: this.options.contentId,
|
|
89
|
+
token: this.options.authToken,
|
|
90
|
+
disableControls: true,
|
|
91
|
+
autoplay:this.options.autoplay,
|
|
92
|
+
watchHistory:{
|
|
93
|
+
enable:false,
|
|
94
|
+
interval:30,
|
|
95
|
+
profileId:this.options.profileId,
|
|
96
|
+
apiVersion:'v2'
|
|
97
|
+
},
|
|
98
|
+
customData: {
|
|
99
|
+
entitlement: {
|
|
100
|
+
deviceType: getDeviceFullName(this.options.deviceName),
|
|
101
|
+
contentConsumption: getDeviceShortName(this.options.deviceName),
|
|
102
|
+
// hba_status: localStorage?.getItem("hba_status")?JSON.stringify(localStorage?.getItem("hba_status")):false,
|
|
103
|
+
// householdID: localStorage?.getItem(window?.appMainConfig?.internalName + "_householdID"),
|
|
104
|
+
},
|
|
105
|
+
beacon: {
|
|
106
|
+
params: {
|
|
107
|
+
pfm: (window as any).appSettings.device
|
|
108
|
+
},
|
|
109
|
+
url: (window as any).appMainConfig.internalName,
|
|
110
|
+
},
|
|
111
|
+
// macros:getMacros(videoPlayBackObject,1920,1080,this.options.deviceName,this.options.deviceId),
|
|
112
|
+
overrideNative:true,
|
|
113
|
+
nativeAudioTracks:false,
|
|
114
|
+
nativeVideoTracks:false,
|
|
115
|
+
onlyPlayReadyDRM:true,
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return true
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
attachTo(container: HTMLElement) {
|
|
122
|
+
container.appendChild(this.videoElement);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
play() {
|
|
126
|
+
this.videoElement.play();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
pause() {
|
|
130
|
+
this.videoElement.pause();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
stop() {
|
|
134
|
+
this.videoElement.pause();
|
|
135
|
+
this.videoElement.currentTime = 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
destroy() {
|
|
139
|
+
if (this.videoElement.parentNode) {
|
|
140
|
+
this.videoElement.parentNode.removeChild(this.videoElement);
|
|
141
|
+
}
|
|
142
|
+
this.removeAllListeners();
|
|
143
|
+
// Remove class event handlers
|
|
144
|
+
(Object.keys(this.boundHandlerMap) as VideoPlayerEvent[]).forEach(event => {
|
|
145
|
+
if (this.boundHandlerMap[event]) {
|
|
146
|
+
this.videoElement.removeEventListener(event, this.boundHandlerMap[event]!);
|
|
147
|
+
delete this.boundHandlerMap[event];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get element(): HTMLVideoElement {
|
|
153
|
+
return this.videoElement;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Event callback function definitions
|
|
157
|
+
onPlay(e: Event) {
|
|
158
|
+
// Called when playback starts
|
|
159
|
+
if (typeof this.options.onPlaybackSuccess === 'function') {
|
|
160
|
+
this.options.onPlaybackSuccess();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
onPause(e: Event) {
|
|
165
|
+
// Called when playback is paused
|
|
166
|
+
// Override or pass as option
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
onEnded(e: Event) {
|
|
170
|
+
// Called when playback ends
|
|
171
|
+
if (typeof this.options.onPlaybackEnded === 'function') {
|
|
172
|
+
this.options.onPlaybackEnded();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
onTimeupdate(e: Event) {
|
|
177
|
+
// Called when playback position changes
|
|
178
|
+
// Override or pass as option
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
onError(e: Event) {
|
|
182
|
+
// Called on playback error
|
|
183
|
+
if (typeof this.options.onPlaybackError === 'function') {
|
|
184
|
+
this.options.onPlaybackError(e);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
onLoadedmetadata(e: Event) {
|
|
189
|
+
// Called when metadata is loaded
|
|
190
|
+
// Override or pass as option
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
onSeeking(e: Event) {
|
|
194
|
+
// Called when seeking starts
|
|
195
|
+
// Override or pass as option
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
onSeeked(e: Event) {
|
|
199
|
+
// Called when seeking ends
|
|
200
|
+
// Override or pass as option
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
onVolumechange(e: Event) {
|
|
204
|
+
// Called when volume changes
|
|
205
|
+
// Override or pass as option
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Event system
|
|
209
|
+
on(event: VideoPlayerEvent, handler: EventHandler) {
|
|
210
|
+
if (!this.listeners[event]) {
|
|
211
|
+
this.listeners[event] = [];
|
|
212
|
+
if (!this.boundEmitters[event]) {
|
|
213
|
+
this.boundEmitters[event] = this.emitEvent(event);
|
|
214
|
+
this.videoElement.addEventListener(event, this.boundEmitters[event]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this.listeners[event].push(handler);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
off(event: VideoPlayerEvent, handler: EventHandler) {
|
|
221
|
+
if (!this.listeners[event]) return;
|
|
222
|
+
this.listeners[event] = this.listeners[event].filter(h => h !== handler);
|
|
223
|
+
if (this.listeners[event].length === 0) {
|
|
224
|
+
if (this.boundEmitters[event]) {
|
|
225
|
+
this.videoElement.removeEventListener(event, this.boundEmitters[event]);
|
|
226
|
+
delete this.boundEmitters[event];
|
|
227
|
+
}
|
|
228
|
+
delete this.listeners[event];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
once(event: VideoPlayerEvent, handler: EventHandler) {
|
|
233
|
+
const onceHandler: EventHandler = (...args) => {
|
|
234
|
+
handler(...args);
|
|
235
|
+
this.off(event, onceHandler);
|
|
236
|
+
};
|
|
237
|
+
this.on(event, onceHandler);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private emitEvent(event: VideoPlayerEvent) {
|
|
241
|
+
return (e: Event) => {
|
|
242
|
+
if (this.listeners[event]) {
|
|
243
|
+
this.listeners[event].forEach(handler => handler(e));
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private removeAllListeners() {
|
|
249
|
+
(Object.keys(this.listeners) as VideoPlayerEvent[]).forEach(event => {
|
|
250
|
+
if (this.boundEmitters[event]) {
|
|
251
|
+
this.videoElement.removeEventListener(event, this.boundEmitters[event]);
|
|
252
|
+
delete this.boundEmitters[event];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
this.listeners = {};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function getHandlerMethodName(event: string): string {
|
|
260
|
+
return 'on' + event.charAt(0).toUpperCase() + event.slice(1);
|
|
261
|
+
}
|
package/src/utility.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export const getDeviceMaker = (deviceName:string) => {
|
|
2
|
+
if (deviceName == "lgTv") {
|
|
3
|
+
return "LG";
|
|
4
|
+
} else if (deviceName == "vizioTv") {
|
|
5
|
+
return "Vizio";
|
|
6
|
+
} else if(deviceName == "xfinityX1"){
|
|
7
|
+
return "xfinityX1"
|
|
8
|
+
}else if(deviceName == "xbox"){
|
|
9
|
+
return "Microsoft"
|
|
10
|
+
}else {
|
|
11
|
+
return "Samsung";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export const getUserAgent = (deviceName:string) => {
|
|
17
|
+
if (deviceName == "lgTv") {
|
|
18
|
+
return "SmartTV_LG_WebOS";
|
|
19
|
+
} else if (deviceName == "vizioTv") {
|
|
20
|
+
return "SmartTV_Vizio_SmartCast";
|
|
21
|
+
} else if(deviceName == "xfinityX1"){
|
|
22
|
+
return "xfinityX1"
|
|
23
|
+
}else if(deviceName == "xbox"){
|
|
24
|
+
return "xboxOne"
|
|
25
|
+
}else {
|
|
26
|
+
return "SmartTV_Samsung_Tizen";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const getOSName = (deviceName:string) => {
|
|
30
|
+
if (deviceName == "lgTv") {
|
|
31
|
+
return "WebOS";
|
|
32
|
+
} else if (deviceName == "vizioTv") {
|
|
33
|
+
return "SmartCast";
|
|
34
|
+
} else if(deviceName == "xfinityX1"){
|
|
35
|
+
return "xfinityX1"
|
|
36
|
+
}else if(deviceName == "xbox"){
|
|
37
|
+
return "Windows"
|
|
38
|
+
}else {
|
|
39
|
+
return "Tizen";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export const getDeviceShortName = (deviceName:string) => {
|
|
43
|
+
if (deviceName == "lgTv") {
|
|
44
|
+
return "lg";
|
|
45
|
+
} else if (deviceName == "vizioTv") {
|
|
46
|
+
return "vizio";
|
|
47
|
+
} else if(deviceName == "xfinityX1"){
|
|
48
|
+
return "xfinityX1"
|
|
49
|
+
}else if(deviceName == "xbox"){
|
|
50
|
+
return "xBox"
|
|
51
|
+
}else {
|
|
52
|
+
return "samsung";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export const getDeviceFullName = (deviceName:string) => {
|
|
56
|
+
if (deviceName == "lgTv") {
|
|
57
|
+
return "smart_tv_lg";
|
|
58
|
+
} else if (deviceName == "vizioTv") {
|
|
59
|
+
return "vizioTv";
|
|
60
|
+
} else if(deviceName == "xfinityX1"){
|
|
61
|
+
return "xfinityX1"
|
|
62
|
+
}else if(deviceName == "xbox"){
|
|
63
|
+
return "windows_xbox"
|
|
64
|
+
}else {
|
|
65
|
+
return "smart_tv_samsung";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const getMacros=(width, height,deviceName,deviceId)=>{
|
|
70
|
+
let objMacros = {};
|
|
71
|
+
try{
|
|
72
|
+
objMacros["VIEWLIFT_WIDTH"] = width;
|
|
73
|
+
objMacros["VIEWLIFT_HEIGHT"] = height;
|
|
74
|
+
objMacros["VIEWLIFT_SIZE"] = width + "x" + height;
|
|
75
|
+
objMacros["VIEWLIFT_DOMAIN"] = (window as any).appMainConfig.domainName;
|
|
76
|
+
|
|
77
|
+
objMacros["VIEWLIFT_CACHEBUSTER"] = (new Date()).getTime();
|
|
78
|
+
objMacros["VIEWLIFT_TIMESTAMP"] = Math.floor((new Date()).getTime() % 1000);
|
|
79
|
+
objMacros["VIEWLIFT_TIMESTAMP_MS"] = (new Date()).getTime();
|
|
80
|
+
objMacros["VIEWLIFT_USER_AGENT"] = window.navigator.userAgent;
|
|
81
|
+
|
|
82
|
+
// objMacros["VIEWLIFT_DURATION"] = time;
|
|
83
|
+
objMacros["VIEWLIFT_MIN_DURATION"] = "0";
|
|
84
|
+
|
|
85
|
+
objMacros["VIEWLIFT_AUTOPLAY"] = "1";
|
|
86
|
+
objMacros["VIEWLIFT_DNT"] = "0";
|
|
87
|
+
objMacros["VIEWLIFT_AD_POS"] = "1";
|
|
88
|
+
objMacros["VIEWLIFT_MUTE"] = "0";
|
|
89
|
+
objMacros["VIEWLIFT_DEVICE_MAKE"] = getDeviceMaker(deviceName);
|
|
90
|
+
objMacros["VIEWLIFT_OS"] = getOSName(deviceName);
|
|
91
|
+
objMacros["VIEWLIFT_LAT"] = (window as any).geoLocation?.latitude;
|
|
92
|
+
objMacros["VIEWLIFT_LON"] = (window as any).geoLocation?.longitude;
|
|
93
|
+
objMacros["VIEWLIFT_KEYWORDS"] = "720";
|
|
94
|
+
objMacros["VIEWLIFT_CONSENT"] = "0";
|
|
95
|
+
objMacros["VIEWLIFT_US_PRIVACY"] = "1";
|
|
96
|
+
objMacros["VIEWLIFT_COPPA"] = "0";
|
|
97
|
+
objMacros["VIEWLIFT_BRAND_NAME"] = getDeviceMaker(deviceName);
|
|
98
|
+
objMacros["VIEWLIFT_IP"] = (window as any).geoLocation?.origip;
|
|
99
|
+
objMacros["VIEWLIFT_MAX_POD_DURATION"] = "120";
|
|
100
|
+
objMacros["VIEWLIFT_MAX_POD_DURATION_MS"] = "120000";
|
|
101
|
+
|
|
102
|
+
// objMacros["VIEWLIFT_APP_ID"] = "";
|
|
103
|
+
objMacros["VIEWLIFT_DEVICE_ID"] = deviceId;
|
|
104
|
+
objMacros["VIEWLIFT_DID"] = deviceId;
|
|
105
|
+
//objMacros["VIEWLIFT_APP_NAME"] = "";
|
|
106
|
+
objMacros["VIEWLIFT_GDPR"] = "0";
|
|
107
|
+
}catch(e){}
|
|
108
|
+
return objMacros;
|
|
109
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e,t=require("./generic-8b99b151.js"),i=require("./util-fa21734a.js"),o=require("./skin-84083352.js"),n=0,d=0,u=function e(i,n,u,s,c){d=i,i>u.length-1||t.load(n,u[i].id,s).then((function(e){o.highlightVideo(d),d++,t.setVideoIdx(d),r(e)})).catch((function(i){r(i),setTimeout((function(){o.highlightVideo(d),d++,t.setVideoIdx(d),e(d,n,u,s)}),5e3)}))},r=function(t){e&&e(t)};exports.autoPlayNext=function(s){clearTimeout(n);var c=null==s?void 0:s.content;e=null==s?void 0:s.cb;var h=s.playerId,l=sessionStorage.getItem("token");i.onVideoEnded(h,(function(){var e=t.getPlayer(h);0!==(null==e?void 0:e.currentTime())&&((d=t.getVideoIdx())>c.length-1||t.load(h,c[d].id,l).then((function(e){o.highlightVideo(d),t.setCurrentVideo(e.response),d++,t.setVideoIdx(d),r(e)})).catch((function(e){r(e),o.highlightVideo(d),d++,t.setVideoIdx(d),n=setTimeout((function(){t.isPaused(h)&&u(d,h,c,l)}),5e3)})))}))},exports.switchToNext=u;
|