@codenkay/video-nsgplayer-angular 0.1.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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/nsg-video-player.component.d.ts +32 -0
- package/dist/lib/nsg-video-player.component.d.ts.map +1 -0
- package/dist/lib/nsg-video-player.component.js +121 -0
- package/package.json +35 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) NSG Player
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @codenkay/video-nsgplayer-angular
|
|
2
|
+
|
|
3
|
+
Angular standalone component for `@codenkay/video-nsgplayer-core`.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<nsg-video-player
|
|
7
|
+
[videoId]="videoId"
|
|
8
|
+
[auth]="authConfig"
|
|
9
|
+
[playback]="playbackConfig"
|
|
10
|
+
[config]="playerConfig"
|
|
11
|
+
(ready)="onReady()"
|
|
12
|
+
(error)="onError($event)"
|
|
13
|
+
(autherror)="onAuthError($event)">
|
|
14
|
+
</nsg-video-player>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { NsgVideoPlayerComponent } from "@codenkay/video-nsgplayer-angular";
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
imports: [NsgVideoPlayerComponent],
|
|
22
|
+
// ...
|
|
23
|
+
})
|
|
24
|
+
export class MyPage {}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires Angular 17+. Same `PlayerConfig` shape as the React package.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NsgVideoPlayerComponent } from "./lib/nsg-video-player.component";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AfterViewInit, ElementRef, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
|
|
2
|
+
import { mergePlayerConfig, type AuthConfig, type PlaybackCredentialConfig, type VideoPlayer } from "@codenkay/video-nsgplayer-core";
|
|
3
|
+
export declare class NsgVideoPlayerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|
4
|
+
videoRef: ElementRef<HTMLVideoElement>;
|
|
5
|
+
containerRef: ElementRef<HTMLDivElement>;
|
|
6
|
+
videoId?: string;
|
|
7
|
+
auth?: AuthConfig;
|
|
8
|
+
playback?: PlaybackCredentialConfig;
|
|
9
|
+
sourceUrl?: string;
|
|
10
|
+
config?: Parameters<typeof mergePlayerConfig>[0];
|
|
11
|
+
readonly ready: import("@angular/core").OutputEmitterRef<void>;
|
|
12
|
+
readonly error: import("@angular/core").OutputEmitterRef<{
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
fatal: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
readonly play: import("@angular/core").OutputEmitterRef<void>;
|
|
18
|
+
readonly pause: import("@angular/core").OutputEmitterRef<void>;
|
|
19
|
+
readonly autherror: import("@angular/core").OutputEmitterRef<{
|
|
20
|
+
message: string;
|
|
21
|
+
retryable: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
private player;
|
|
24
|
+
private viewReady;
|
|
25
|
+
ngAfterViewInit(): void;
|
|
26
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
27
|
+
ngOnDestroy(): void;
|
|
28
|
+
getPlayer(): VideoPlayer | null;
|
|
29
|
+
private recreate;
|
|
30
|
+
private applyTheme;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=nsg-video-player.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nsg-video-player.component.d.ts","sourceRoot":"","sources":["../../src/lib/nsg-video-player.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EAEV,SAAS,EACT,SAAS,EACT,aAAa,EAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,iBAAiB,EAEjB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AAExC,qBAea,uBACX,YAAW,aAAa,EAAE,SAAS,EAAE,SAAS;IAG9C,QAAQ,EAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAGxC,YAAY,EAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAEjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1D,QAAQ,CAAC,KAAK,iDAAkB;IAChC,QAAQ,CAAC,KAAK;cAAkB,MAAM;iBAAW,MAAM;eAAS,OAAO;OAAM;IAC7E,QAAQ,CAAC,IAAI,iDAAkB;IAC/B,QAAQ,CAAC,KAAK,iDAAkB;IAChC,QAAQ,CAAC,SAAS;iBAAqB,MAAM;mBAAa,OAAO;OAAM;IAEvE,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,SAAS,CAAS;IAE1B,eAAe,IAAI,IAAI;IAKvB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAezC,WAAW,IAAI,IAAI;IAKnB,SAAS,IAAI,WAAW,GAAG,IAAI;IAI/B,OAAO,CAAC,QAAQ;IA8BhB,OAAO,CAAC,UAAU;CASnB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Component, Input, ViewChild, output, } from "@angular/core";
|
|
8
|
+
import { createVideoPlayer, mergePlayerConfig, themeToCssVars, } from "@codenkay/video-nsgplayer-core";
|
|
9
|
+
let NsgVideoPlayerComponent = class NsgVideoPlayerComponent {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.ready = output();
|
|
12
|
+
this.error = output();
|
|
13
|
+
this.play = output();
|
|
14
|
+
this.pause = output();
|
|
15
|
+
this.autherror = output();
|
|
16
|
+
this.player = null;
|
|
17
|
+
this.viewReady = false;
|
|
18
|
+
}
|
|
19
|
+
ngAfterViewInit() {
|
|
20
|
+
this.viewReady = true;
|
|
21
|
+
this.recreate();
|
|
22
|
+
}
|
|
23
|
+
ngOnChanges(changes) {
|
|
24
|
+
if (!this.viewReady)
|
|
25
|
+
return;
|
|
26
|
+
if (changes["videoId"] ||
|
|
27
|
+
changes["sourceUrl"] ||
|
|
28
|
+
changes["auth"] ||
|
|
29
|
+
changes["playback"]) {
|
|
30
|
+
this.recreate();
|
|
31
|
+
}
|
|
32
|
+
else if (changes["config"] && this.player) {
|
|
33
|
+
this.player.updateConfig(this.config);
|
|
34
|
+
this.applyTheme();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
ngOnDestroy() {
|
|
38
|
+
this.player?.destroy();
|
|
39
|
+
this.player = null;
|
|
40
|
+
}
|
|
41
|
+
getPlayer() {
|
|
42
|
+
return this.player;
|
|
43
|
+
}
|
|
44
|
+
recreate() {
|
|
45
|
+
this.player?.destroy();
|
|
46
|
+
const video = this.videoRef?.nativeElement;
|
|
47
|
+
if (!video)
|
|
48
|
+
return;
|
|
49
|
+
const resolved = mergePlayerConfig(this.config);
|
|
50
|
+
this.player = createVideoPlayer({
|
|
51
|
+
videoId: this.videoId,
|
|
52
|
+
mount: video,
|
|
53
|
+
auth: this.auth,
|
|
54
|
+
playback: this.playback,
|
|
55
|
+
sourceUrl: this.sourceUrl,
|
|
56
|
+
player: resolved.player,
|
|
57
|
+
controls: resolved.controls,
|
|
58
|
+
theme: resolved.theme,
|
|
59
|
+
watermark: resolved.watermark,
|
|
60
|
+
streaming: resolved.streaming,
|
|
61
|
+
logging: resolved.logging,
|
|
62
|
+
debug: resolved.debug,
|
|
63
|
+
accessibility: resolved.accessibility,
|
|
64
|
+
});
|
|
65
|
+
this.player.on("ready", () => this.ready.emit());
|
|
66
|
+
this.player.on("error", (e) => this.error.emit(e));
|
|
67
|
+
this.player.on("play", () => this.play.emit());
|
|
68
|
+
this.player.on("pause", () => this.pause.emit());
|
|
69
|
+
this.player.on("autherror", (e) => this.autherror.emit(e));
|
|
70
|
+
this.applyTheme();
|
|
71
|
+
}
|
|
72
|
+
applyTheme() {
|
|
73
|
+
const resolved = mergePlayerConfig(this.config);
|
|
74
|
+
const vars = themeToCssVars(resolved.theme);
|
|
75
|
+
const el = this.containerRef?.nativeElement;
|
|
76
|
+
if (!el)
|
|
77
|
+
return;
|
|
78
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
79
|
+
el.style.setProperty(key, value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
__decorate([
|
|
84
|
+
ViewChild("video", { static: true })
|
|
85
|
+
], NsgVideoPlayerComponent.prototype, "videoRef", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
ViewChild("container", { static: true })
|
|
88
|
+
], NsgVideoPlayerComponent.prototype, "containerRef", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
Input()
|
|
91
|
+
], NsgVideoPlayerComponent.prototype, "videoId", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
Input()
|
|
94
|
+
], NsgVideoPlayerComponent.prototype, "auth", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Input()
|
|
97
|
+
], NsgVideoPlayerComponent.prototype, "playback", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
Input()
|
|
100
|
+
], NsgVideoPlayerComponent.prototype, "sourceUrl", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
Input()
|
|
103
|
+
], NsgVideoPlayerComponent.prototype, "config", void 0);
|
|
104
|
+
NsgVideoPlayerComponent = __decorate([
|
|
105
|
+
Component({
|
|
106
|
+
selector: "nsg-video-player",
|
|
107
|
+
standalone: true,
|
|
108
|
+
template: `
|
|
109
|
+
<div
|
|
110
|
+
#container
|
|
111
|
+
data-player-theme
|
|
112
|
+
[style.width]="'100%'"
|
|
113
|
+
[style.position]="'relative'"
|
|
114
|
+
[style.background]="'#000'"
|
|
115
|
+
>
|
|
116
|
+
<video #video playsinline style="width:100%;display:block"></video>
|
|
117
|
+
</div>
|
|
118
|
+
`,
|
|
119
|
+
})
|
|
120
|
+
], NsgVideoPlayerComponent);
|
|
121
|
+
export { NsgVideoPlayerComponent };
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codenkay/video-nsgplayer-angular",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Angular bindings for NSG video player",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "NSG Player",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist", "README.md", "LICENSE", "CHANGELOG.md"],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@codenkay/video-nsgplayer-core": "^0.1.0",
|
|
21
|
+
"@angular/core": ">=17",
|
|
22
|
+
"@angular/common": ">=17"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@codenkay/video-nsgplayer-core": "*",
|
|
30
|
+
"@angular/common": "^19.2.0",
|
|
31
|
+
"@angular/core": "^19.2.0",
|
|
32
|
+
"rxjs": "^7.8.0",
|
|
33
|
+
"typescript": "^5"
|
|
34
|
+
}
|
|
35
|
+
}
|