neoplayer 1.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.
@@ -0,0 +1,3 @@
1
+ import { ApiBackend } from './types';
2
+ declare const defaultApiBackend: ApiBackend;
3
+ export default defaultApiBackend;
@@ -0,0 +1,16 @@
1
+ import { BarType, BarDirection } from './types';
2
+ import Template from './template';
3
+ declare class Bar {
4
+ private elements;
5
+ constructor(template: Template);
6
+ /**
7
+ * Update a progress bar
8
+ *
9
+ * @param type - Which bar to update
10
+ * @param percentage - Value between 0 and 1
11
+ * @param direction - 'width' or 'height'
12
+ */
13
+ set(type: BarType, percentage: number, direction: BarDirection): void;
14
+ get(type: BarType): number;
15
+ }
16
+ export default Bar;
@@ -0,0 +1,6 @@
1
+ declare class Bezel {
2
+ private container;
3
+ constructor(container: HTMLElement);
4
+ switch(icon: string): void;
5
+ }
6
+ export default Bezel;
@@ -0,0 +1,12 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ declare class Comment {
3
+ private player;
4
+ constructor(player: NeoPlayerInstance);
5
+ show(): void;
6
+ hide(): void;
7
+ showSetting(): void;
8
+ hideSetting(): void;
9
+ toggleSetting(): void;
10
+ send(): void;
11
+ }
12
+ export default Comment;
@@ -0,0 +1,11 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ declare class ContextMenu {
3
+ private player;
4
+ shown: boolean;
5
+ private contextmenuHandler;
6
+ constructor(player: NeoPlayerInstance);
7
+ show(x: number, y: number): void;
8
+ hide(): void;
9
+ destroy(): void;
10
+ }
11
+ export default ContextMenu;
@@ -0,0 +1,34 @@
1
+ import Thumbnails from './thumbnails';
2
+ import { NeoPlayerInstance } from './types';
3
+ declare class Controller {
4
+ private player;
5
+ private autoHideTimer;
6
+ private setAutoHideHandler?;
7
+ private pendingTap?;
8
+ thumbnails?: Thumbnails;
9
+ disableAutoHide: boolean;
10
+ private session?;
11
+ private currentMedia?;
12
+ constructor(player: NeoPlayerInstance);
13
+ initPlayButton(): void;
14
+ private clearPendingTap;
15
+ private handleMobileTap;
16
+ initHighlights(): void;
17
+ initThumbnails(): void;
18
+ initPlayedBar(): void;
19
+ initFullButton(): void;
20
+ initVolumeButton(): void;
21
+ initQualityButton(): void;
22
+ initScreenshotButton(): void;
23
+ initAirplayButton(): void;
24
+ private initChromecast;
25
+ initChromecastButton(): void;
26
+ initSubtitleButton(): void;
27
+ setAutoHide(): void;
28
+ show(): void;
29
+ hide(): void;
30
+ isShow(): boolean;
31
+ toggle(): void;
32
+ destroy(): void;
33
+ }
34
+ export default Controller;
@@ -0,0 +1,47 @@
1
+ import { DanmakuConstructorOptions, DanmakuItem, DanmakuAPIOptions } from './types';
2
+ interface DrawDanmakuItem {
3
+ text: string;
4
+ color: number;
5
+ type: number | string;
6
+ border?: string;
7
+ time?: number;
8
+ }
9
+ declare class Danmaku {
10
+ private options;
11
+ readonly player: DanmakuConstructorOptions['player'];
12
+ private container;
13
+ private danTunnel;
14
+ danIndex: number;
15
+ dan: DanmakuItem[];
16
+ private showing;
17
+ private _opacity;
18
+ private events;
19
+ unlimited: boolean;
20
+ private paused;
21
+ private context;
22
+ constructor(options: DanmakuConstructorOptions);
23
+ load(): void;
24
+ reload(newAPI: DanmakuAPIOptions): void;
25
+ private _readAllEndpoints;
26
+ send(dan: {
27
+ text: string;
28
+ color: number;
29
+ type: number;
30
+ }, callback: () => void): void;
31
+ frame(): void;
32
+ opacity(percentage?: number): number;
33
+ draw(dan: DrawDanmakuItem | DrawDanmakuItem[]): DocumentFragment | undefined;
34
+ play(): void;
35
+ pause(): void;
36
+ private _measure;
37
+ seek(): void;
38
+ clear(): void;
39
+ private htmlEncode;
40
+ resize(): void;
41
+ hide(): void;
42
+ show(): void;
43
+ unlimit(boolean: boolean): void;
44
+ speed(rate: number): void;
45
+ private _danAnimation;
46
+ }
47
+ export default Danmaku;
@@ -0,0 +1,11 @@
1
+ import { AllEventName, VideoEventName, PlayerEventName, EventCallback } from './types';
2
+ declare class Events {
3
+ events: Partial<Record<AllEventName, EventCallback[]>>;
4
+ readonly videoEvents: VideoEventName[];
5
+ readonly playerEvents: PlayerEventName[];
6
+ constructor();
7
+ on(name: AllEventName, callback: EventCallback): void;
8
+ trigger(name: AllEventName, info?: unknown): void;
9
+ type(name: AllEventName): 'player' | 'video' | null;
10
+ }
11
+ export default Events;
@@ -0,0 +1,14 @@
1
+ import { NeoPlayerInstance, FullScreenType } from './types';
2
+ declare class FullScreen {
3
+ private player;
4
+ private lastScrollPosition;
5
+ private fullscreenchange;
6
+ private docfullscreenchange;
7
+ constructor(player: NeoPlayerInstance);
8
+ isFullScreen(type?: FullScreenType): boolean | Element | null;
9
+ request(type?: FullScreenType): void;
10
+ cancel(type?: FullScreenType): void;
11
+ toggle(type?: FullScreenType): void;
12
+ destroy(): void;
13
+ }
14
+ export default FullScreen;
@@ -0,0 +1,22 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ declare class HotKey {
3
+ private player;
4
+ private doHotKeyHandler;
5
+ private cancelFullScreenHandler;
6
+ constructor(player: NeoPlayerInstance);
7
+ /** Take a screenshot of the current video frame and download it */
8
+ takeScreenshot(): void;
9
+ /**
10
+ * Change playback speed by a delta, clamped to [0.25, 2.0]
11
+ */
12
+ changeSpeed(delta: number): void;
13
+ /** Reset playback speed to 1× */
14
+ resetSpeed(): void;
15
+ /** Seek to a percentage of the total duration */
16
+ seekToPercent(percent: number): void;
17
+ private doHotKey;
18
+ private handleLetterKeys;
19
+ private cancelFullScreen;
20
+ destroy(): void;
21
+ }
22
+ export default HotKey;
@@ -0,0 +1,7 @@
1
+ export type TranslationKey = 'danmaku-loading' | 'top' | 'bottom' | 'rolling' | 'input-danmaku-enter' | 'about-author' | 'dplayer-feedback' | 'about-dplayer' | 'loop' | 'speed' | 'opacity-danmaku' | 'normal' | 'please-input-danmaku' | 'set-danmaku-color' | 'set-danmaku-type' | 'show-danmaku' | 'video-failed' | 'danmaku-failed' | 'danmaku-send-failed' | 'switching-quality' | 'switched-quality' | 'ff' | 'rew' | 'unlimited-danmaku' | 'send-danmaku' | 'setting' | 'fullscreen' | 'web-fullscreen' | 'send' | 'screenshot' | 'airplay' | 'chromecast' | 'subtitle' | 'off' | 'show-subs' | 'hide-subs' | 'volume' | 'live' | 'video-info';
2
+ export declare class i18n {
3
+ private lang;
4
+ private fallbackLang;
5
+ constructor(lang: string);
6
+ tran: (key: string) => string;
7
+ }
@@ -0,0 +1,22 @@
1
+ export interface IconsMap {
2
+ play: string;
3
+ pause: string;
4
+ volumeUp: string;
5
+ volumeDown: string;
6
+ volumeOff: string;
7
+ full: string;
8
+ fullWeb: string;
9
+ setting: string;
10
+ right: string;
11
+ comment: string;
12
+ commentOff: string;
13
+ send: string;
14
+ pallette: string;
15
+ camera: string;
16
+ subtitle: string;
17
+ loading: string;
18
+ airplay: string;
19
+ chromecast: string;
20
+ }
21
+ declare const Icons: IconsMap;
22
+ export default Icons;
@@ -0,0 +1,3 @@
1
+ import '../css/index.less';
2
+ import NeoPlayer from './player';
3
+ export default NeoPlayer;
@@ -0,0 +1,15 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ declare class InfoPanel {
3
+ private container;
4
+ private template;
5
+ private video;
6
+ private player;
7
+ private beginTime;
8
+ constructor(player: NeoPlayerInstance);
9
+ show(): void;
10
+ hide(): void;
11
+ triggle(): void;
12
+ update(): void;
13
+ fps(value: number): void;
14
+ }
15
+ export default InfoPanel;
@@ -0,0 +1,4 @@
1
+ import { NeoPlayerOptions } from './types';
2
+ export default function handleOption(options: Partial<NeoPlayerOptions> & {
3
+ video: NeoPlayerOptions['video'];
4
+ }): NeoPlayerOptions;
@@ -0,0 +1,87 @@
1
+ import Template from './template';
2
+ import Danmaku from './danmaku';
3
+ import Events from './events';
4
+ import FullScreen from './fullscreen';
5
+ import User from './user';
6
+ import Subtitle from './subtitle';
7
+ import Subtitles from './subtitles';
8
+ import Bar from './bar';
9
+ import Timer from './timer';
10
+ import Bezel from './bezel';
11
+ import Controller from './controller';
12
+ import Setting from './setting';
13
+ import Comment from './comment';
14
+ import HotKey from './hotkey';
15
+ import ContextMenu from './contextmenu';
16
+ import InfoPanel from './info-panel';
17
+ import { NeoPlayerOptions, VideoOptions, VideoQualityOption, DanmakuOptions, AllEventName, EventCallback } from './types';
18
+ declare class NeoPlayer {
19
+ options: NeoPlayerOptions;
20
+ video: HTMLVideoElement;
21
+ prevVideo: HTMLVideoElement | null;
22
+ container: HTMLElement;
23
+ paused: boolean;
24
+ focus: boolean;
25
+ moveBar: boolean;
26
+ type: string;
27
+ qualityIndex: number;
28
+ prevIndex: number;
29
+ quality: VideoQualityOption | undefined;
30
+ switchingQuality: boolean;
31
+ arrow: boolean;
32
+ noticeList: Record<string, ReturnType<typeof setTimeout> | null>;
33
+ _savedPlaybackRate: number;
34
+ plugins: Record<string, unknown>;
35
+ docClickFun: (() => void) | null;
36
+ containerClickFun: (() => void) | null;
37
+ visibilityChangeFun: (() => void) | null;
38
+ private _tabHidden;
39
+ private _pausedAt;
40
+ tran: (key: string) => string;
41
+ events: Events;
42
+ user: User;
43
+ template: Template;
44
+ bar: Bar;
45
+ bezel: Bezel;
46
+ fullScreen: FullScreen;
47
+ controller: Controller;
48
+ danmaku?: Danmaku;
49
+ comment?: Comment;
50
+ setting: Setting;
51
+ hotkey: HotKey;
52
+ contextmenu: ContextMenu;
53
+ infoPanel: InfoPanel;
54
+ timer: Timer;
55
+ subtitle?: Subtitle;
56
+ subtitles?: Subtitles;
57
+ constructor(options: Partial<NeoPlayerOptions> & {
58
+ video: VideoOptions;
59
+ });
60
+ /** Seek to a time (in seconds) */
61
+ seek(time: number, nonotice?: boolean): void;
62
+ /** Start playback */
63
+ play(fromNative?: boolean): void;
64
+ /** Pause playback */
65
+ pause(fromNative?: boolean): void;
66
+ switchVolumeIcon(): void;
67
+ /**
68
+ * Get or set volume.
69
+ * Called with no argument it returns the current volume.
70
+ */
71
+ volume(percentage?: number, nostorage?: boolean, nonotice?: boolean): number;
72
+ /** Toggle play / pause */
73
+ toggle(): void;
74
+ /** Attach an event listener */
75
+ on(name: AllEventName, callback: EventCallback): void;
76
+ /** Switch to a different video source */
77
+ switchVideo(video: VideoOptions, danmakuAPI?: DanmakuOptions): void;
78
+ initMSE(video: HTMLVideoElement, type: string): void;
79
+ initVideo(video: HTMLVideoElement, type: string): void;
80
+ switchQuality(index: number | string): void;
81
+ notice(text: string, time?: number, opacity?: number, id?: string): void;
82
+ resize(): void;
83
+ speed(rate: number): void;
84
+ destroy(): void;
85
+ static get version(): string;
86
+ }
87
+ export default NeoPlayer;
@@ -0,0 +1,30 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ declare class Setting {
3
+ private player;
4
+ loop: boolean;
5
+ showDanmaku: number;
6
+ unlimitDanmaku: number;
7
+ private speedValues;
8
+ currentSpeed: number;
9
+ constructor(player: NeoPlayerInstance);
10
+ private _initMask;
11
+ private _initLoop;
12
+ private _initShowDanmaku;
13
+ private _initUnlimitDanmaku;
14
+ private _initSpeedMenu;
15
+ private _initSpeedSlider;
16
+ private _initDanmakuOpacity;
17
+ hide(): void;
18
+ show(): void;
19
+ toggleSpeedPanel(): void;
20
+ showSpeedPanel(): void;
21
+ hideSpeedPanel(): void;
22
+ /** Called externally when speed changes (e.g. from hotkey) to sync slider */
23
+ updateSpeedPanelActive(speed: number): void;
24
+ private _positionSpeedTicks;
25
+ private _getSpeedFromPercentage;
26
+ private _getPercentageFromSpeed;
27
+ private _updateSliderToSpeed;
28
+ private _highlightActivePreset;
29
+ }
30
+ export default Setting;
@@ -0,0 +1,14 @@
1
+ import { SubtitleOptions } from './types';
2
+ import Events from './events';
3
+ declare class Subtitle {
4
+ private container;
5
+ private video;
6
+ private options;
7
+ private events;
8
+ constructor(container: HTMLElement, video: HTMLVideoElement, options: SubtitleOptions, events: Events);
9
+ private init;
10
+ show(): void;
11
+ hide(): void;
12
+ toggle(): void;
13
+ }
14
+ export default Subtitle;
@@ -0,0 +1,11 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ declare class Subtitles {
3
+ private player;
4
+ constructor(player: NeoPlayerInstance);
5
+ subContainerShow(): void;
6
+ subContainerHide(): void;
7
+ hide(): void;
8
+ show(): void;
9
+ adaptiveHeight(): void;
10
+ }
11
+ export default Subtitles;
@@ -0,0 +1,96 @@
1
+ import { NeoPlayerOptions, TemplateConstructorOptions } from './types';
2
+ declare class Template {
3
+ container: HTMLElement;
4
+ options: NeoPlayerOptions;
5
+ index: number;
6
+ tran: (key: string) => string;
7
+ volumeBar: HTMLElement;
8
+ volumeBarWrap: HTMLElement;
9
+ volumeBarWrapWrap: HTMLElement;
10
+ volumeButton: HTMLElement;
11
+ volumeButtonIcon: HTMLElement;
12
+ volumeIcon: HTMLElement;
13
+ playedBar: HTMLElement;
14
+ loadedBar: HTMLElement;
15
+ playedBarWrap: HTMLElement;
16
+ playedBarTime: HTMLElement;
17
+ danmaku: HTMLElement;
18
+ danmakuLoading: HTMLElement;
19
+ danmakuOpacityBar: HTMLElement;
20
+ danmakuOpacityBarWrap: HTMLElement;
21
+ danmakuOpacityBarWrapWrap: HTMLElement;
22
+ danmakuOpacityBox: HTMLElement;
23
+ video: HTMLVideoElement;
24
+ videoWrap: HTMLElement;
25
+ bezel: HTMLElement;
26
+ playButton: HTMLElement;
27
+ mobilePlayButton: HTMLElement;
28
+ controllerMask: HTMLElement;
29
+ controller: HTMLElement;
30
+ ptime: HTMLElement;
31
+ dtime: HTMLElement;
32
+ settingButton: HTMLElement;
33
+ settingBox: HTMLElement;
34
+ mask: HTMLElement;
35
+ loop: HTMLElement;
36
+ loopToggle: HTMLInputElement;
37
+ showDanmaku: HTMLElement | null;
38
+ showDanmakuToggle: HTMLInputElement | null;
39
+ unlimitDanmaku: HTMLElement | null;
40
+ unlimitDanmakuToggle: HTMLInputElement | null;
41
+ speed: HTMLElement;
42
+ speedOriginValue: HTMLElement;
43
+ speedBack: HTMLElement;
44
+ speedCurrent: HTMLElement;
45
+ speedItem: NodeListOf<HTMLElement>;
46
+ speedIndicator: HTMLElement;
47
+ speedSliderTrack: HTMLElement;
48
+ speedSliderFilled: HTMLElement;
49
+ speedSliderThumb: HTMLElement;
50
+ speedSliderTicks: NodeListOf<HTMLElement>;
51
+ speedSliderBtnMinus: HTMLElement;
52
+ speedSliderBtnPlus: HTMLElement;
53
+ commentInput: HTMLInputElement;
54
+ commentButton: HTMLElement;
55
+ commentSettingBox: HTMLElement;
56
+ commentSettingButton: HTMLElement;
57
+ commentSettingFill: HTMLElement;
58
+ commentSendButton: HTMLElement;
59
+ commentSendFill: HTMLElement;
60
+ commentColorSettingBox: HTMLElement;
61
+ browserFullButton: HTMLElement;
62
+ webFullButton: HTMLElement;
63
+ menu: HTMLElement;
64
+ menuItem: NodeListOf<HTMLElement>;
65
+ qualityList: HTMLElement;
66
+ qualityButton: HTMLElement;
67
+ camareButton: HTMLElement;
68
+ airplayButton: HTMLElement;
69
+ chromecastButton: HTMLElement;
70
+ subtitleButton: HTMLElement;
71
+ subtitleButtonInner: HTMLElement;
72
+ subtitlesButton: HTMLElement;
73
+ subtitlesBox: HTMLElement;
74
+ subtitlesItem: NodeListOf<HTMLElement>;
75
+ subtitle: HTMLElement;
76
+ subtrack: HTMLTrackElement;
77
+ barPreview: HTMLElement;
78
+ barWrap: HTMLElement;
79
+ noticeList: HTMLElement;
80
+ infoPanel: HTMLElement;
81
+ infoPanelClose: HTMLElement;
82
+ infoVersion: HTMLElement;
83
+ infoFPS: HTMLElement;
84
+ infoType: HTMLElement;
85
+ infoUrl: HTMLElement;
86
+ infoResolution: HTMLElement;
87
+ infoDuration: HTMLElement;
88
+ infoDanmakuId: HTMLElement;
89
+ infoDanmakuApi: HTMLElement;
90
+ infoDanmakuAmount: HTMLElement;
91
+ constructor(options: TemplateConstructorOptions);
92
+ private init;
93
+ /** Create a notice element */
94
+ static NewNotice(text: string, opacity: number, id?: string): HTMLElement;
95
+ }
96
+ export default Template;
@@ -0,0 +1,12 @@
1
+ import { ThumbnailsOptions } from './types';
2
+ declare class Thumbnails {
3
+ private container;
4
+ private barWidth;
5
+ private events;
6
+ constructor(options: ThumbnailsOptions);
7
+ resize(width: number, height: number, barWrapWidth: number): void;
8
+ show(): void;
9
+ move(position: number): void;
10
+ hide(): void;
11
+ }
12
+ export default Thumbnails;
@@ -0,0 +1,26 @@
1
+ import { NeoPlayerInstance } from './types';
2
+ type TimerType = 'loading' | 'info' | 'fps';
3
+ declare class Timer {
4
+ private player;
5
+ private readonly types;
6
+ private enableloadingChecker;
7
+ private enableinfoChecker;
8
+ private enablefpsChecker;
9
+ private loadingChecker?;
10
+ private infoChecker?;
11
+ private fpsStart;
12
+ private fpsIndex;
13
+ private lastPresentedFrameTime;
14
+ private stalledCount;
15
+ private onActivityReset;
16
+ constructor(player: NeoPlayerInstance);
17
+ private init;
18
+ private initChecker;
19
+ private initloadingChecker;
20
+ private initfpsChecker;
21
+ private initinfoChecker;
22
+ enable(type: TimerType): void;
23
+ disable(type: TimerType): void;
24
+ destroy(): void;
25
+ }
26
+ export default Timer;
@@ -0,0 +1,12 @@
1
+ import { NeoPlayerOptions } from './types';
2
+ import { IconsMap } from './icons';
3
+ import { tplVideo } from './tpl-video';
4
+ export interface PlayerTplData {
5
+ options: NeoPlayerOptions;
6
+ index: number;
7
+ tran: (key: string) => string;
8
+ icons: IconsMap;
9
+ mobile: boolean;
10
+ video: Parameters<typeof tplVideo>[0];
11
+ }
12
+ export declare function tplPlayer(data: PlayerTplData): string;
@@ -0,0 +1,12 @@
1
+ import { SubtitleOptions } from './types';
2
+ export interface VideoTplData {
3
+ current: boolean;
4
+ pic?: string | null;
5
+ screenshot?: boolean;
6
+ airplay?: boolean;
7
+ chromecast?: boolean;
8
+ preload?: string;
9
+ url?: string;
10
+ subtitle?: SubtitleOptions;
11
+ }
12
+ export declare function tplVideo(data: VideoTplData): string;