@nomercy-entertainment/nomercy-video-player 0.2.0 → 0.2.2
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 +330 -177
- package/dist/helpers.d.ts +1 -1
- package/dist/plugins/keyHandlerPlugin.d.ts +2 -1
- package/dist/plugins/keyHandlerPlugin.js +1 -2
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
- package/src/helpers.ts +1 -1
- package/src/plugins/keyHandlerPlugin.ts +3 -1
- package/src/types.ts +3 -3
package/README.md
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
\####################################################
|
|
5
|
-
\# ⚠️ WORK IN PROGRESS - USE WITH CAUTION ⚠️ #
|
|
6
|
-
\# This repository is under development and is not stable. #
|
|
7
|
-
\####################################################
|
|
8
|
-
|
|
9
1
|
# NoMercy VideoPlayer
|
|
10
2
|
|
|
11
|
-
**NoMercy VideoPlayer** is a lightweight, plugin-based, customizable HTML5 video player built with JavaScript. It is
|
|
3
|
+
**NoMercy VideoPlayer** is a lightweight, plugin-based, customizable HTML5 video player built with JavaScript. It is
|
|
4
|
+
designed to support a variety of media formats and streaming protocols while allowing developers to extend its
|
|
5
|
+
functionality through modular plugins.
|
|
12
6
|
Always feel like fighting video player UI choices? then this is the player for you.
|
|
13
7
|
|
|
14
8
|
## Features
|
|
15
9
|
|
|
16
10
|
- **HTML5 Video Support**: Compatible with popular media formats (MP4, WebM, Ogg).
|
|
17
11
|
- **Streaming Support**: Handles streaming protocols like HLS via URLs.
|
|
18
|
-
- **Plugin-Based Architecture**: UI, subtitle renderer, and key event handler are customizable plugins, enabling easy
|
|
12
|
+
- **Plugin-Based Architecture**: UI, subtitle renderer, and key event handler are customizable plugins, enabling easy
|
|
13
|
+
customization and flexibility.
|
|
19
14
|
- **Customizable Controls**: Modify buttons, layout, and styles through plugins or custom code.
|
|
20
15
|
- **Subtitles & Captions**: Full support for VTT and ASS subtitle formats.
|
|
21
16
|
- **Keyboard Shortcuts**: Extendable key event handler for custom controls.
|
|
@@ -23,165 +18,61 @@ Always feel like fighting video player UI choices? then this is the player for y
|
|
|
23
18
|
## Example
|
|
24
19
|
|
|
25
20
|
```typescript
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
image: 'https://image.tmdb.org/t/p/w780/q2bVM5z90tCGbmXYtq2J38T5hSX.jpg',
|
|
64
|
-
file: 'https://media.nomercy.tv/Films/Films/Sintel.(2010)/Sintel.(2010).NoMercy.m3u8',
|
|
65
|
-
tracks: [
|
|
66
|
-
{label: 'Dutch (Full)', file: '...NoMercy.dut.full.vtt', language: 'dut', kind: 'subtitles'},
|
|
67
|
-
{label: 'English (Full)', file: '...NoMercy.eng.full.vtt', language: 'eng', kind: 'subtitles'},
|
|
68
|
-
// Additional subtitle tracks...
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
// Additional playlist items...
|
|
72
|
-
],
|
|
73
|
-
controlsTimeout: 3000,
|
|
74
|
-
doubleClickDelay: 500,
|
|
75
|
-
playbackRates: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],
|
|
21
|
+
import nmplayer from '@nomercy-entertainment/nomercy-video-player/src/index';
|
|
22
|
+
import OctopusPlugin from '@nomercy-entertainment/nomercy-video-player/src/plugins/octopusPlugin';
|
|
23
|
+
import KeyHandlerPlugin from '@nomercy-entertainment/nomercy-video-player/src/plugins/keyHandlerPlugin';
|
|
24
|
+
import type { PlayerConfig } from '@nomercy-entertainment/nomercy-video-player/src/types';
|
|
25
|
+
|
|
26
|
+
const config: PlayerConfig = {
|
|
27
|
+
muted: false,
|
|
28
|
+
controls: false,
|
|
29
|
+
preload: 'auto',
|
|
30
|
+
debug: false,
|
|
31
|
+
playlist: [
|
|
32
|
+
{
|
|
33
|
+
title: 'Cosmos Laundromat',
|
|
34
|
+
description: 'On a desolate island, a suicidal sheep named Franck meets his fate…',
|
|
35
|
+
image: 'https://image.tmdb.org/t/p/w780/f2wABsgj2lIR2dkDEfBZX8p4Iyk.jpg',
|
|
36
|
+
file: 'https://media.nomercy.tv/Films/Films/Cosmos.Laundromat.(2015)/Cosmos.Laundromat.(2015).NoMercy.m3u8',
|
|
37
|
+
tracks: [
|
|
38
|
+
{ label: 'Dutch (Full)', file: '...NoMercy.dut.full.vtt', language: 'dut', kind: 'subtitles' },
|
|
39
|
+
{ label: 'English (Full)', file: '...NoMercy.eng.full.vtt', language: 'eng', kind: 'subtitles' },
|
|
40
|
+
// Additional subtitle tracks...
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'Sintel',
|
|
45
|
+
description: 'Sintel is an independently produced short film...',
|
|
46
|
+
image: 'https://image.tmdb.org/t/p/w780/q2bVM5z90tCGbmXYtq2J38T5hSX.jpg',
|
|
47
|
+
file: 'https://media.nomercy.tv/Films/Films/Sintel.(2010)/Sintel.(2010).NoMercy.m3u8',
|
|
48
|
+
tracks: [
|
|
49
|
+
{ label: 'Dutch (Full)', file: '...NoMercy.dut.full.vtt', language: 'dut', kind: 'subtitles' },
|
|
50
|
+
{ label: 'English (Full)', file: '...NoMercy.eng.full.vtt', language: 'eng', kind: 'subtitles' },
|
|
51
|
+
// Additional subtitle tracks...
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
// Additional playlist items...
|
|
55
|
+
],
|
|
56
|
+
playbackRates: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],
|
|
57
|
+
// Additional configuration options...
|
|
76
58
|
};
|
|
77
59
|
|
|
78
|
-
const player = nmplayer('player')
|
|
79
|
-
|
|
80
|
-
const octopusPlugin = new OctopusPlugin();
|
|
81
|
-
player.registerPlugin('octopus', octopusPlugin);
|
|
82
|
-
player.usePlugin('octopus');
|
|
60
|
+
const player = nmplayer('player') // 'player' is the ID of the div element, do not use a video tag
|
|
61
|
+
.setup(config);
|
|
83
62
|
|
|
63
|
+
// Bind VLC keyboad shortcuts
|
|
84
64
|
const keyHandlerPlugin = new KeyHandlerPlugin();
|
|
85
65
|
player.registerPlugin('keyHandler', keyHandlerPlugin);
|
|
86
66
|
player.usePlugin('keyHandler');
|
|
87
67
|
|
|
68
|
+
// ASS subtitle support
|
|
69
|
+
const octopusPlugin = new OctopusPlugin();
|
|
70
|
+
player.registerPlugin('octopus', octopusPlugin);
|
|
71
|
+
player.usePlugin('octopus');
|
|
88
72
|
|
|
89
|
-
//
|
|
90
|
-
player.
|
|
91
|
-
|
|
92
|
-
qualities.innerHTML = '';
|
|
93
|
-
|
|
94
|
-
const levelsList = player
|
|
95
|
-
.createElement('ul', 'levelTrackList', true)
|
|
96
|
-
.addClasses(['overflow-auto'])
|
|
97
|
-
.appendTo(qualities);
|
|
98
|
-
|
|
99
|
-
Object.values(data).forEach((track, index) => {
|
|
100
|
-
const levelTrack = player
|
|
101
|
-
.createElement('li', `levelTrack - ${track.name} `)
|
|
102
|
-
.addClasses([
|
|
103
|
-
'p-2',
|
|
104
|
-
'cursor-pointer',
|
|
105
|
-
'border-b',
|
|
106
|
-
])
|
|
107
|
-
.appendTo(levelsList);
|
|
108
|
-
|
|
109
|
-
levelTrack.innerHTML = track.name;
|
|
110
|
-
|
|
111
|
-
levelTrack.addEventListener('click', () => {
|
|
112
|
-
player.setCurrentQuality(index);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
player.on('levelsChanged', (data) => {
|
|
118
|
-
console.log('levelsChanged', data);
|
|
119
|
-
currentQuality.innerHTML = data.name;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Audio Tracks
|
|
123
|
-
player.on('audioTracks', (data) => {
|
|
124
|
-
console.log('audioTracks', data);
|
|
125
|
-
audioTracks.innerHTML = '';
|
|
126
|
-
|
|
127
|
-
const audioList = player
|
|
128
|
-
.createElement('ul', 'audioTrackList', true)
|
|
129
|
-
.addClasses(['overflow-auto'])
|
|
130
|
-
.appendTo(audioTracks);
|
|
131
|
-
|
|
132
|
-
Object.values(data).forEach((track, index) => {
|
|
133
|
-
const audioTrack = player
|
|
134
|
-
.createElement('li', `audioTrack - ${track.name} `)
|
|
135
|
-
.addClasses([
|
|
136
|
-
'p-2',
|
|
137
|
-
'cursor-pointer',
|
|
138
|
-
'border-b',
|
|
139
|
-
])
|
|
140
|
-
.appendTo(audioList);
|
|
141
|
-
|
|
142
|
-
audioTrack.innerHTML = track.name;
|
|
143
|
-
|
|
144
|
-
audioTrack.addEventListener('click', () => {
|
|
145
|
-
player.setCurrentAudioTrack(index);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
player.on('audioTrackChanged', (data) => {
|
|
150
|
-
console.log('audioTrackChanged', data);
|
|
151
|
-
currentAudio.innerHTML = data.name;
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Captions
|
|
155
|
-
player.on('captionsList', (data) => {
|
|
156
|
-
console.log('captionsList', data);
|
|
157
|
-
subtitleTracks.innerHTML = '';
|
|
158
|
-
|
|
159
|
-
const captionList = player
|
|
160
|
-
.createElement('ul', 'captionTrackList', true)
|
|
161
|
-
.addClasses(['overflow-auto'])
|
|
162
|
-
.appendTo(subtitleTracks);
|
|
163
|
-
|
|
164
|
-
Object.values(data).forEach((track, index) => {
|
|
165
|
-
const captionTrack = player
|
|
166
|
-
.createElement('li', `captionTrack - ${track.name} `)
|
|
167
|
-
.addClasses([
|
|
168
|
-
'p-2',
|
|
169
|
-
'cursor-pointer',
|
|
170
|
-
'border-b',
|
|
171
|
-
])
|
|
172
|
-
.appendTo(captionList);
|
|
173
|
-
|
|
174
|
-
captionTrack.innerHTML = track.label;
|
|
175
|
-
|
|
176
|
-
captionTrack.addEventListener('click', () => {
|
|
177
|
-
player.setCurrentCaption(index);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
player.on('captionsChanged', (data) => {
|
|
182
|
-
console.log('captionsChanged', data.label);
|
|
183
|
-
currentSubtitle.innerHTML = player.getCurrentCaptionsName();
|
|
184
|
-
});
|
|
73
|
+
// const customUIPlugin = new CustomUIPlugin();
|
|
74
|
+
// player.registerPlugin('customUI', customUIPlugin);
|
|
75
|
+
// player.usePlugin('customUI');
|
|
185
76
|
```
|
|
186
77
|
|
|
187
78
|
## Plugin Development
|
|
@@ -189,30 +80,292 @@ player.on('captionsChanged', (data) => {
|
|
|
189
80
|
Developers can create their own plugins by following the NoMercy VideoPlayer API. Here's a basic structure of a plugin:
|
|
190
81
|
|
|
191
82
|
```typescript
|
|
192
|
-
import Plugin from '
|
|
193
|
-
import { NMPlayer } from '
|
|
194
|
-
|
|
195
|
-
export
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
83
|
+
import Plugin from '@nomercy-entertainment/nomercy-video-player/src/plugin';
|
|
84
|
+
import { NMPlayer } from '@nomercy-entertainment/nomercy-video-player/src/types';
|
|
85
|
+
|
|
86
|
+
export interface PluginArgs {
|
|
87
|
+
// Your extra config items
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class CustomUIPlugin extends Plugin {
|
|
91
|
+
player: NMPlayer<PluginArgs> = NMPlayer < PluginArgs > {};
|
|
92
|
+
|
|
93
|
+
initialize(player: NMPlayer<PluginArgs>) {
|
|
94
|
+
this.player = player;
|
|
95
|
+
// Setup your plugin before use is called
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dispose() {
|
|
99
|
+
// clean up, called when the plugin is unmounted or the player is disposed
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
use() {
|
|
103
|
+
// plugin logic
|
|
104
|
+
}
|
|
206
105
|
}
|
|
207
106
|
|
|
208
107
|
export default CustomUIPlugin;
|
|
209
108
|
```
|
|
210
109
|
|
|
110
|
+
# Type Definitions for NoMercyVideoPlayer
|
|
111
|
+
note: type definitions and api may not be 100% correct and are subject to change.
|
|
112
|
+
|
|
113
|
+
## Interfaces
|
|
114
|
+
|
|
115
|
+
### `PlayerConfig`
|
|
116
|
+
|
|
117
|
+
Configuration options for the player.
|
|
118
|
+
|
|
119
|
+
| Property | Type | Description |
|
|
120
|
+
|-------------------|-----------------------------|----------------------------------------|
|
|
121
|
+
| `chapters` | `boolean\|undefined` | Enables or disables chapter support. |
|
|
122
|
+
| `playlist` | `string\| PlaylistItem[]` | Playlist items or URL. |
|
|
123
|
+
| `debug` | `boolean\|undefined` | Enables debug mode. |
|
|
124
|
+
| `muted` | `boolean\|undefined` | Starts playback in muted mode. |
|
|
125
|
+
| `controls` | `boolean\|undefined` | Enables or disables playback controls. |
|
|
126
|
+
| `autoPlay` | `boolean\|undefined` | Starts playback automatically. |
|
|
127
|
+
| `preload` | `AutoLoadOptons\|'none'` | Preload behavior for the media. |
|
|
128
|
+
| `stretching` | `StretchOptions\|undefined` | Video stretching options. |
|
|
129
|
+
| `playbackRates` | `number[]\|undefined` | Available playback rates. |
|
|
130
|
+
| `accessToken` | `string\|undefined` | Access token for authentication. |
|
|
131
|
+
| `basePath` | `string\|undefined` | Base path for media files. |
|
|
132
|
+
| `language` | `string\|undefined` | Language code for the UI. |
|
|
133
|
+
| `displayLanguage` | `string\|undefined` | Language for display. |
|
|
134
|
+
|
|
135
|
+
### `StretchOptions`
|
|
136
|
+
|
|
137
|
+
Options for video stretching.
|
|
138
|
+
|
|
139
|
+
| Value | Description |
|
|
140
|
+
|------------|--------------------------------|
|
|
141
|
+
| `fill` | Whether to fill the container. |
|
|
142
|
+
| `fit` | Whether to fit the container. |
|
|
143
|
+
| `none` | Whether to disable stretching. |
|
|
144
|
+
| `exactfit` | Whether to fit exactly. |
|
|
145
|
+
|
|
146
|
+
### `AutoLoadOptons`
|
|
147
|
+
|
|
148
|
+
Options for media preload behavior.
|
|
149
|
+
|
|
150
|
+
| Value | Description |
|
|
151
|
+
|------------|----------------------------------|
|
|
152
|
+
| `auto` | Automatically preload the media. |
|
|
153
|
+
| `metadata` | Preload metadata only. |
|
|
154
|
+
| `none` | Disable preload. |
|
|
155
|
+
|
|
156
|
+
### `PlaylistItem`
|
|
157
|
+
|
|
158
|
+
Represents a media playlist item.
|
|
159
|
+
|
|
160
|
+
| Property | Type | Description |
|
|
161
|
+
|---------------|---------------------------------------------|------------------------------------------|
|
|
162
|
+
| `id` | `string\| number` | Unique identifier for the playlist item. |
|
|
163
|
+
| `progress` | `{ time: number, date: string }\|undefined` | Progress information with time and date. |
|
|
164
|
+
| `duration` | `string` | Total duration of the playlist item. |
|
|
165
|
+
| `file` | `string` | URL or path to the media file. |
|
|
166
|
+
| `image` | `string` | URL or path to the thumbnail image. |
|
|
167
|
+
| `title` | `string` | Title of the playlist item. |
|
|
168
|
+
| `tracks` | `Track[]\|undefined` | List of associated tracks. |
|
|
169
|
+
| `description` | `string` | Description of the playlist item. |
|
|
170
|
+
| `season` | `number\|undefined` | Season number (if applicable). |
|
|
171
|
+
| `episode` | `number\|undefined` | Episode number (if applicable). |
|
|
172
|
+
|
|
173
|
+
### `Track`
|
|
174
|
+
|
|
175
|
+
Represents a media track.
|
|
176
|
+
|
|
177
|
+
| Property | Type | Description |
|
|
178
|
+
|------------|----------------------|--------------------------------------------|
|
|
179
|
+
| `id` | `number` | Unique identifier for the track. |
|
|
180
|
+
| `default` | `boolean\|undefined` | Whether this is the default track. |
|
|
181
|
+
| `file` | `string` | URL or path to the track file. |
|
|
182
|
+
| `kind` | `TrackType` | Type of track. |
|
|
183
|
+
| `label` | `string\|undefined` | Label for the track. |
|
|
184
|
+
| `language` | `string\|undefined` | Language of the track. |
|
|
185
|
+
| `type` | `string\|undefined` | Additional type information for the track. |
|
|
186
|
+
| `ext` | `string\|undefined` | File extension for the track. |
|
|
187
|
+
|
|
188
|
+
### `TrackType`
|
|
189
|
+
|
|
190
|
+
Type of media track.
|
|
191
|
+
|
|
192
|
+
| Value | Description |
|
|
193
|
+
|--------------|--------------------|
|
|
194
|
+
| `subtitles` | Subtitle track. |
|
|
195
|
+
| `chapters` | Chapter track. |
|
|
196
|
+
| `fonts` | Fonts track. |
|
|
197
|
+
| `thumbnails` | Description track. |
|
|
198
|
+
| `sprite` | Sprite track. |
|
|
199
|
+
|
|
200
|
+
#### Methods
|
|
201
|
+
|
|
202
|
+
##### Playback and State Control
|
|
203
|
+
|
|
204
|
+
| Method | Parameters | Return Type | Description |
|
|
205
|
+
|-------------------|----------------|--------------------------|----------------------------------------|
|
|
206
|
+
| `play` | `boolean` | `Promise<void>` | Starts or resumes playback. |
|
|
207
|
+
| `pause` | `boolean` | `void` | Pauses playback. |
|
|
208
|
+
| `stop` | None | `void` | Stops playback. |
|
|
209
|
+
| `seek` | `number` | `void` | Seeks to a specific position. |
|
|
210
|
+
| `togglePlayback` | None | `void` | Toggles between play and pause states. |
|
|
211
|
+
| `setVolume` | `number` | `void` | Sets the volume (0–1). |
|
|
212
|
+
| `setMute` | `boolean` | `void` | Mutes or unmutes the player. |
|
|
213
|
+
| `setPlaybackRate` | `number` | `void` | Sets the playback speed. |
|
|
214
|
+
| `getState` | None | `PlayState` | Gets the current playback state. |
|
|
215
|
+
| `setup` | `PlayerConfig` | `NMPlayer<PlayerConfig>` | Initializes the player with options. |
|
|
216
|
+
|
|
217
|
+
##### Quality and Track Management
|
|
218
|
+
|
|
219
|
+
| Method | Parameters | Return Type | Description |
|
|
220
|
+
|------------------------|------------|-------------------|-------------------------------------|
|
|
221
|
+
| `getQualityLevels` | None | `Level[]` | Retrieves available quality levels. |
|
|
222
|
+
| `setCurrentQuality` | `number` | `void` | Sets the current quality level. |
|
|
223
|
+
| `getAudioTracks` | None | `MediaPlaylist[]` | Retrieves available audio tracks. |
|
|
224
|
+
| `cycleAudioTracks` | None | `void` | Cycles through audio tracks. |
|
|
225
|
+
| `setCurrentAudioTrack` | `number` | `void` | Sets the current audio track. |
|
|
226
|
+
| `getCaptionsList` | None | `Track[]` | Retrieves available caption tracks. |
|
|
227
|
+
| `cycleSubtitles` | None | `void` | Cycles through subtitle tracks. |
|
|
228
|
+
| `setCurrentCaption` | `number` | `void` | Sets the current subtitle track. |
|
|
229
|
+
|
|
230
|
+
##### Player UI
|
|
231
|
+
|
|
232
|
+
| Method | Parameters | Return Type | Description |
|
|
233
|
+
|--------------------|------------|-------------|--------------------------|
|
|
234
|
+
| `enterFullscreen` | None | `void` | Enters fullscreen mode. |
|
|
235
|
+
| `exitFullscreen` | None | `void` | Exits fullscreen mode. |
|
|
236
|
+
| `toggleFullscreen` | None | `void` | Toggles fullscreen mode. |
|
|
237
|
+
|
|
238
|
+
##### Event Handling
|
|
239
|
+
|
|
240
|
+
| Method | Parameters | Return Type | Description |
|
|
241
|
+
|--------|---------------------------------------|-------------|------------------------------------------|
|
|
242
|
+
| `emit` | `(event: string, data?: any)` | `void` | Emits a custom event with optional data. |
|
|
243
|
+
| `on` | `(event: string, callback: Function)` | `void` | Adds a listener for a specific event. |
|
|
244
|
+
| `off` | `(event: string, callback: Function)` | `void` | Removes a listener for a specific event. |
|
|
245
|
+
| `once` | `(event: string, callback: Function)` | `void` | Adds a one-time listener for an event. |
|
|
246
|
+
|
|
247
|
+
#### Events
|
|
248
|
+
|
|
249
|
+
| Event Name | Data Type | Description |
|
|
250
|
+
|-----------------------|-----------------------------|---------------------------------------------------------------|
|
|
251
|
+
| `all` | - | Triggered for all events. |
|
|
252
|
+
| `audioTrackChanged` | `CurrentTrack` | Triggered when the audio track changes. |
|
|
253
|
+
| `audioTrackChanging` | `CurrentTrack` | Triggered when the audio track is in the process of changing. |
|
|
254
|
+
| `audioTracks` | `Track[]` | Triggered when the audio tracks list is updated. |
|
|
255
|
+
| `back` | `(arg?: any) => any` | Triggered when the back button is pressed. |
|
|
256
|
+
| `beforeplaylistitem` | - | Triggered before a playlist item is played. |
|
|
257
|
+
| `bufferChange` | - | Triggered when the buffer state changes. |
|
|
258
|
+
| `buffer` | - | Triggered when buffering occurs. |
|
|
259
|
+
| `bufferedEnd` | - | Triggered when the buffered end is reached. |
|
|
260
|
+
| `captionsChanged` | `CurrentTrack` | Triggered when captions change. |
|
|
261
|
+
| `captionsChanging` | `CurrentTrack` | Triggered when captions are in the process of changing. |
|
|
262
|
+
| `captionsList` | `Track[]` | Triggered when the captions list is updated. |
|
|
263
|
+
| `chapters` | `VTTData` | Triggered when the chapters data changes. |
|
|
264
|
+
| `complete` | - | Triggered when the media playback completes. |
|
|
265
|
+
| `controls` | `(showing: boolean` | Triggered when controls visibility changes. |
|
|
266
|
+
| `display-message` | `string` | Triggered when a message is displayed. |
|
|
267
|
+
| `dispose` | - | Triggered when the player is disposed of. |
|
|
268
|
+
| `duration` | `TimeData` | Triggered when the duration data changes. |
|
|
269
|
+
| `ended` | - | Triggered when playback ends. |
|
|
270
|
+
| `error` | `any` | Triggered when an error occurs. |
|
|
271
|
+
| `finished` | - | Triggered when the entire playback session finishes. |
|
|
272
|
+
| `firstFrame` | - | Triggered when the first frame is displayed. |
|
|
273
|
+
| `forward` | `number` | Triggered when fast-forwarding by a certain amount. |
|
|
274
|
+
| `fullscreen` | `(enabled: boolean` | Triggered when fullscreen state changes. |
|
|
275
|
+
| `item` | `PlaylistItem` | Triggered when a playlist item is loaded. |
|
|
276
|
+
| `lastTimeTrigger` | `TimeData` | Triggered when the last time trigger occurs. |
|
|
277
|
+
| `levelsChanged` | `CurrentTrack` | Triggered when levels change for the current track. |
|
|
278
|
+
| `levelsChanging` | `CurrentTrack` | Triggered when levels are in the process of changing. |
|
|
279
|
+
| `levels` | `Level[]` | Triggered when the levels change. See Hls.js |
|
|
280
|
+
| `meta` | - | Triggered when the metadata is updated. |
|
|
281
|
+
| `mute` | `VolumeState` | Triggered when the mute state changes. |
|
|
282
|
+
| `overlay` | - | Triggered when an overlay is displayed. |
|
|
283
|
+
| `pause` | - | Triggered when playback is paused. |
|
|
284
|
+
| `play` | - | Triggered when playback starts. |
|
|
285
|
+
| `playbackRateChanged` | - | Triggered when the playback rate changes. |
|
|
286
|
+
| `playing` | - | Triggered when playback starts or resumes. |
|
|
287
|
+
| `playlistComplete` | - | Triggered when the playlist is complete. |
|
|
288
|
+
| `playlist` | `PlaylistItem[]` | Triggered when a playlist is loaded or changed. |
|
|
289
|
+
| `playlistchange` | - | Triggered when the playlist changes. |
|
|
290
|
+
| `ready` | - | Triggered when ready to start. |
|
|
291
|
+
| `remove-message` | `string` | Triggered when a message is removed. |
|
|
292
|
+
| `remove` | - | Triggered when the player is removed. |
|
|
293
|
+
| `resize` | - | Triggered when the player is resized. |
|
|
294
|
+
| `rewind` | `number` | Triggered when rewinding by a certain amount. |
|
|
295
|
+
| `seek` | - | Triggered when seeking starts. |
|
|
296
|
+
| `seeked` | - | Triggered when seeking ends. |
|
|
297
|
+
| `setupError` | - | Triggered when a setup error occurs. |
|
|
298
|
+
| `skippers` | `Chapter[]` | Triggered when the chapter skippers list changes. |
|
|
299
|
+
| `speed` | `number` | Triggered when the playback speed is changed. |
|
|
300
|
+
| `stalled` | - | Triggered when playback stalls. |
|
|
301
|
+
| `time` | `TimeData` | Triggered when the playback time updates. |
|
|
302
|
+
| `translations` | `{ [key: string]: string }` | Triggered when translations are loaded or changed. |
|
|
303
|
+
| `volume` | `VolumeState` | Triggered when the volume changes. |
|
|
304
|
+
| `waiting` | - | Triggered when the player is waiting for something. |
|
|
305
|
+
|
|
306
|
+
### `CurrentTrack`
|
|
307
|
+
Represents the currently selected media track.
|
|
308
|
+
|
|
309
|
+
| Property | Type | Description |
|
|
310
|
+
|----------|----------|---------------------------------|
|
|
311
|
+
| `id` | `number` | Unique identifier of the track. |
|
|
312
|
+
| `name` | `string` | Name of the track. |
|
|
313
|
+
|
|
314
|
+
### `PreviewTime`
|
|
315
|
+
Describes preview thumbnail dimensions and coordinates.
|
|
316
|
+
|
|
317
|
+
| Property | Type | Description |
|
|
318
|
+
|----------|----------|-------------------------------|
|
|
319
|
+
| `start` | `number` | Start time for the preview. |
|
|
320
|
+
| `end` | `number` | End time for the preview. |
|
|
321
|
+
| `x` | `number` | X-coordinate for the preview. |
|
|
322
|
+
| `y` | `number` | Y-coordinate for the preview. |
|
|
323
|
+
| `w` | `number` | Width of the preview area. |
|
|
324
|
+
| `h` | `number` | Height of the preview area. |
|
|
325
|
+
|
|
326
|
+
### `VolumeState`
|
|
327
|
+
Represents the player's current volume state.
|
|
328
|
+
|
|
329
|
+
| Property | Type | Description |
|
|
330
|
+
|----------|-----------|------------------------------|
|
|
331
|
+
| `muted` | `boolean` | Whether the player is muted. |
|
|
332
|
+
| `volume` | `number` | Current volume level (0–1). |
|
|
333
|
+
|
|
334
|
+
### `Chapter`
|
|
335
|
+
Defines a chapter in the media.
|
|
336
|
+
|
|
337
|
+
| Property | Type | Description |
|
|
338
|
+
|-------------|----------|---------------------------------------|
|
|
339
|
+
| `endTime` | `number` | End time of the chapter in seconds. |
|
|
340
|
+
| `id` | `string` | Unique identifier for the chapter. |
|
|
341
|
+
| `left` | `number` | Left position of the chapter marker. |
|
|
342
|
+
| `startTime` | `number` | Start time of the chapter in seconds. |
|
|
343
|
+
| `time` | `number` | Duration of the chapter in seconds. |
|
|
344
|
+
| `title` | `string` | Title of the chapter. |
|
|
345
|
+
| `width` | `number` | Width of the chapter marker. |
|
|
346
|
+
|
|
347
|
+
### `TimeData`
|
|
348
|
+
Provides playback time information.
|
|
349
|
+
|
|
350
|
+
| Property | Type | Description |
|
|
351
|
+
|--------------------|----------|---------------------------------------------------|
|
|
352
|
+
| `currentTime` | `number` | Current playback time in seconds. |
|
|
353
|
+
| `duration` | `number` | Total duration of the media in seconds. |
|
|
354
|
+
| `percentage` | `number` | Percentage of media played (0–100). |
|
|
355
|
+
| `remaining` | `number` | Time remaining in seconds. |
|
|
356
|
+
| `currentTimeHuman` | `number` | Current playback time in a human-readable format. |
|
|
357
|
+
| `durationHuman` | `number` | Total duration in a human-readable format. |
|
|
358
|
+
| `remainingHuman` | `number` | Remaining time in a human-readable format. |
|
|
359
|
+
| `playbackRate` | `number` | Current playback rate (e.g., 1.0, 1.5). |
|
|
360
|
+
|
|
361
|
+
## Contributions
|
|
362
|
+
Contributions are welcome! If you encounter issues or have suggestions for improvement, feel free to open an issue or
|
|
363
|
+
submit a pull request.
|
|
364
|
+
|
|
211
365
|
## License
|
|
212
|
-
|
|
366
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
213
367
|
|
|
214
368
|
## Contact
|
|
215
|
-
|
|
216
369
|
For further information or support, visit NoMercy.tv or contact our support team.
|
|
217
370
|
|
|
218
371
|
Made with ❤️ by [NoMercy Entertainment](https://nomercy.tv)
|
package/dist/helpers.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param time - The time to convert, in seconds or string format.
|
|
4
4
|
* @returns A string representing the time in the format "DD:HH:MM:SS".
|
|
5
5
|
*/
|
|
6
|
-
export declare const humanTime: (time: string | number) =>
|
|
6
|
+
export declare const humanTime: (time: string | number) => string;
|
|
7
7
|
/**
|
|
8
8
|
* Converts a time string in the format "hh:mm:ss" to seconds.
|
|
9
9
|
* @param hms The time string to convert.
|
|
@@ -2,7 +2,7 @@ import Plugin from '../plugin';
|
|
|
2
2
|
import { NMPlayer } from '../types';
|
|
3
3
|
export interface KeyHandlerPluginArgs {
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
declare class KeyHandlerPlugin extends Plugin {
|
|
6
6
|
player: NMPlayer<KeyHandlerPluginArgs>;
|
|
7
7
|
private boundKeyHandler;
|
|
8
8
|
initialize(player: NMPlayer<KeyHandlerPluginArgs>): void;
|
|
@@ -27,3 +27,4 @@ export declare class KeyHandlerPlugin extends Plugin {
|
|
|
27
27
|
function: () => false | void;
|
|
28
28
|
})[];
|
|
29
29
|
}
|
|
30
|
+
export default KeyHandlerPlugin;
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.KeyHandlerPlugin = void 0;
|
|
7
6
|
const plugin_1 = __importDefault(require("../plugin"));
|
|
8
7
|
class KeyHandlerPlugin extends plugin_1.default {
|
|
9
8
|
constructor() {
|
|
@@ -250,4 +249,4 @@ class KeyHandlerPlugin extends plugin_1.default {
|
|
|
250
249
|
}));
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
|
-
exports.
|
|
252
|
+
exports.default = KeyHandlerPlugin;
|
package/dist/types.d.ts
CHANGED
|
@@ -130,9 +130,9 @@ export interface TimeData {
|
|
|
130
130
|
duration: number;
|
|
131
131
|
percentage: number;
|
|
132
132
|
remaining: number;
|
|
133
|
-
currentTimeHuman:
|
|
134
|
-
durationHuman:
|
|
135
|
-
remainingHuman:
|
|
133
|
+
currentTimeHuman: string;
|
|
134
|
+
durationHuman: string;
|
|
135
|
+
remainingHuman: string;
|
|
136
136
|
playbackRate: number;
|
|
137
137
|
}
|
|
138
138
|
export interface Position {
|
package/package.json
CHANGED
package/src/helpers.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param time - The time to convert, in seconds or string format.
|
|
6
6
|
* @returns A string representing the time in the format "DD:HH:MM:SS".
|
|
7
7
|
*/
|
|
8
|
-
export const humanTime = (time: string | number) => {
|
|
8
|
+
export const humanTime = (time: string | number): string => {
|
|
9
9
|
time = parseInt(time as string, 10);
|
|
10
10
|
|
|
11
11
|
let days: any = parseInt(`${(time / (3600 * 24))}`, 10);
|
|
@@ -4,7 +4,7 @@ import { NMPlayer } from '../types';
|
|
|
4
4
|
export interface KeyHandlerPluginArgs {
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class KeyHandlerPlugin extends Plugin {
|
|
8
8
|
player: NMPlayer<KeyHandlerPluginArgs> = <NMPlayer<KeyHandlerPluginArgs>>{};
|
|
9
9
|
private boundKeyHandler: (event: KeyboardEvent) => void = () => { };
|
|
10
10
|
|
|
@@ -251,3 +251,5 @@ export class KeyHandlerPlugin extends Plugin {
|
|
|
251
251
|
}));
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
export default KeyHandlerPlugin;
|
package/src/types.ts
CHANGED
|
@@ -148,9 +148,9 @@ export interface TimeData {
|
|
|
148
148
|
duration: number;
|
|
149
149
|
percentage: number;
|
|
150
150
|
remaining: number;
|
|
151
|
-
currentTimeHuman:
|
|
152
|
-
durationHuman:
|
|
153
|
-
remainingHuman:
|
|
151
|
+
currentTimeHuman: string;
|
|
152
|
+
durationHuman: string;
|
|
153
|
+
remainingHuman: string;
|
|
154
154
|
playbackRate: number;
|
|
155
155
|
}
|
|
156
156
|
|