mn-video-player-v2 1.4.9

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,79 @@
1
+ import MnPlayer from "./js/mn-player.js";
2
+ export type MnVideoPlayerOptions = {
3
+ el: HTMLElement;
4
+ port: number;
5
+ host: string;
6
+ ws: string;
7
+ userId: string;
8
+ tenantId: string;
9
+ accessToken: string;
10
+ phone: string;
11
+ channelNo: string;
12
+ lang: string;
13
+ outerWorker?: Worker;
14
+ beginTime?: string;
15
+ renderType: 'wasm' | 'decode';
16
+ streamType?: number;
17
+ showControlBar: boolean;
18
+ debug?: boolean;
19
+ };
20
+ export type MnVideoPlayerPlayOptions = {
21
+ beginTime: string;
22
+ streamType: number;
23
+ };
24
+ export type MnVideoPlayerControlType = 'play' | 'stop' | 'audio' | 'speedDec' | 'speedInc' | 'fullscreen' | "close" | "refresh" | 'stream0' | 'stream1' | 'stream2';
25
+ export declare class MnVideoPlayer {
26
+ canvasEl: HTMLCanvasElement | null;
27
+ playBtn: HTMLButtonElement | null;
28
+ audioBtn: HTMLButtonElement | null;
29
+ opt: MnVideoPlayerOptions | null;
30
+ el: HTMLElement | null;
31
+ $el: any | null;
32
+ player: MnPlayer | null;
33
+ beginTime?: string;
34
+ streamType: number;
35
+ videoTime: number;
36
+ isPlaying: boolean;
37
+ isPlayStart: boolean;
38
+ isEnableAudio: boolean;
39
+ currentSpeed: number;
40
+ isFullscreen: boolean;
41
+ resizeObserver: ResizeObserver | null;
42
+ outerWorker?: Worker | null;
43
+ noDataImg: HTMLImageElement | null;
44
+ showControlBar: boolean;
45
+ enableDoubleClickFullscreen: boolean;
46
+ id: string;
47
+ timeCallbackFn: (time: number) => void;
48
+ controlCallbackFn: (type: MnVideoPlayerControlType) => boolean;
49
+ debug: boolean;
50
+ debugEl: HTMLDivElement | null;
51
+ debugTimer: any;
52
+ netSpeedKb: number;
53
+ netSpeedCache: number;
54
+ constructor(id?: string);
55
+ isSupportHardDecode(): Promise<boolean>;
56
+ init(opt: MnVideoPlayerOptions): void;
57
+ initDom(): void;
58
+ initControlDom(): void;
59
+ injectControlStyles(): void;
60
+ initDebugDom(): void;
61
+ updateDebug(): void;
62
+ injectDebugStyles(): void;
63
+ resetCanvas(w?: number, h?: number): void;
64
+ removeDom(): void;
65
+ resetAudioOffset(time?: number): void;
66
+ play(opt: MnVideoPlayerPlayOptions): void;
67
+ pause(): void;
68
+ resume(): void;
69
+ stop(): void;
70
+ restart(): void;
71
+ switchStream(type: number): void;
72
+ enableAudio(enable: boolean): void;
73
+ timeCallBack(callback: (time: number) => void): void;
74
+ changeSpeed(speed: number): void;
75
+ formatDateTime(date: Date): string;
76
+ setSyncTime(time: number): void;
77
+ }
78
+ export default MnVideoPlayer;
79
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAIzC,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,WAAW,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,OAAO,CAAC;IAExB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AACD,MAAM,MAAM,wBAAwB,GAAG;IAC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,GAAG,IAAI,CAAO;IACrC,UAAU,EAAE,GAAG,CAAO;IACtB,UAAU,EAAE,MAAM,CAAI;IACtB,aAAa,EAAE,MAAM,CAAI;gBACb,EAAE,GAAE,MAAe;IAKzB,mBAAmB;IAuBzB,IAAI,CAAC,GAAG,EAAE,oBAAoB;IA8D9B,OAAO;IAwCP,cAAc;IA8Pd,mBAAmB;IA0FnB,YAAY;IAoBZ,WAAW;IAwBX,iBAAiB;IAsBjB,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM;IAoBlC,SAAS;IAoBT,gBAAgB,CAAC,IAAI,GAAE,MAAU;IAGjC,IAAI,CAAC,GAAG,EAAE,wBAAwB;IAuClC,KAAK;IAQL,MAAM;IAQN,IAAI;IAYJ,OAAO;IAmBP,YAAY,CAAC,IAAI,EAAE,MAAM;IAazB,WAAW,CAAC,MAAM,EAAE,OAAO;IAU3B,YAAY,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;IAG7C,WAAW,CAAC,KAAK,EAAE,MAAM;IAMzB,cAAc,CAAC,IAAI,EAAE,IAAI;IAoBzB,WAAW,CAAC,IAAI,EAAC,MAAM;CAMxB;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @description: 常量定义(classic 版,供 mn-worker.js 以 importScripts 方式在 classic worker 中加载)
3
+ * @author: lantf
4
+ * @date: 2020/10/18 15:27
5
+ */
6
+
7
+ const kPlayVideoReq = 0;
8
+ const kPauseVideoReq = 1;
9
+ const kStopVideoReq = 2;
10
+
11
+ const kMediaVideo = 0;
12
+ const kMediaAudio = 1;
13
+ const kMediaSpeak = 2;
14
+
15
+ const kDecoderH264 = 0;
16
+ const kDecoderH265 = 1;
17
+
18
+ const kProtoHttp = 0;
19
+ const kProtoWebsocket = 1;
20
+
21
+ const kOpenDecoderReq = 1;
22
+ const kCloseDecoderReq = 2;
23
+ const kResumeDecodingReq = 3;
24
+ const kPauseDecodingReq = 4;
25
+ const kOpenStreamReq = 5;
26
+ const kCloseStreamReq = 6;
27
+ const kEnableAudioReq = 7;
28
+ const kRecorderStreamReq = 8;
29
+ const kSwitchStreamReq = 9;
30
+ const kFastForward = 10;
31
+ const kRecorderSpeakReq = 11;
32
+ const kRecorderTalkReq = 12;
33
+ const kReplayReq = 13;
34
+ const kVideoAudioOffset = 14;
35
+ const kReplaySpeedReq = 15;
36
+ const kChangeRenderTypeReq = 16;
37
+
38
+ const kInitDecoderRsp = 0;
39
+ const kUninitDecoderRsp = 1;
40
+ const kOpenDecoderRsp = 2;
41
+ const kCloseDecoderRsp = 3;
42
+ const kVideoReady = 4;
43
+ const kVideoFrame = 5;
44
+ const kAudioFrame = 6;
45
+ const kStringFrame = 7;
46
+ const kNetSpeedFrame = 8;
47
+ const kPauseDecodingRsp = 9;
48
+ const kDecodeFinishedEvt = 10;
49
+ const kSocketOpenRsp = 11;
50
+ const kSocketTimeoutRsp = 12;
51
+ const kSocketErrorRsp = 13;
52
+ const kSocketCloseRsp = 14;
53
+ const kVideoFrameOriginRsp = 16;
54
+ const kFlushAudio = 17;
55
+ const kNoCache = 18;
56
+ const kCacheAvailable = 19;
57
+
58
+
59
+
60
+ class Logger {
61
+ constructor(module) {
62
+ this.module = module;
63
+ }
64
+
65
+ log(line) {
66
+ console.log("[" + this.currentTimeStr() + "][" + this.module + "]" + line);
67
+ }
68
+
69
+ logError(line) {
70
+ console.log(
71
+ "[" + this.currentTimeStr() + "][" + this.module + "][ER] " + line,
72
+ );
73
+ }
74
+
75
+ logInfo(line) {
76
+ console.log(
77
+ "[" + this.currentTimeStr() + "][" + this.module + "][IF] " + line,
78
+ );
79
+ }
80
+
81
+ logDebug(line) {
82
+ console.log(
83
+ "[" + this.currentTimeStr() + "][" + this.module + "][DT] " + line,
84
+ );
85
+ }
86
+
87
+ currentTimeStr() {
88
+ const now = new Date(Date.now());
89
+ const year = now.getFullYear();
90
+ const month = now.getMonth() + 1;
91
+ const day = now.getDate();
92
+ const hour = now.getHours();
93
+ const min = now.getMinutes();
94
+ const sec = now.getSeconds();
95
+ const ms = now.getMilliseconds();
96
+ return (
97
+ year +
98
+ "-" +
99
+ month +
100
+ "-" +
101
+ day +
102
+ " " +
103
+ hour +
104
+ ":" +
105
+ min +
106
+ ":" +
107
+ sec +
108
+ ":" +
109
+ ms
110
+ );
111
+ }
112
+ }