@polyv/wx-live-player-core 3.0.0 → 3.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.
Files changed (39) hide show
  1. package/README.md +144 -9
  2. package/api/api-url.d.ts +36 -0
  3. package/api/index.d.ts +75 -0
  4. package/api/request.d.ts +7 -0
  5. package/core.d.ts +98 -0
  6. package/events-type.d.ts +86 -0
  7. package/export.d.ts +4 -0
  8. package/index.d.ts +4 -0
  9. package/modules/auth/auth-module.d.ts +14 -0
  10. package/modules/auth/type.d.ts +18 -0
  11. package/modules/channel/channel-module.d.ts +23 -0
  12. package/modules/channel/type.d.ts +167 -0
  13. package/modules/level-control/level-control-module.d.ts +34 -0
  14. package/modules/line-control/line-control-module.d.ts +27 -0
  15. package/modules/live/live-module.d.ts +14 -0
  16. package/modules/module-base.d.ts +7 -0
  17. package/modules/monitor/monitor-module.d.ts +20 -0
  18. package/modules/playback/playback-module.d.ts +16 -0
  19. package/modules/qos/export.d.ts +1 -0
  20. package/modules/qos/qos-module.d.ts +58 -0
  21. package/modules/qos/type.d.ts +81 -0
  22. package/modules/quick-control/quick-control-module.d.ts +40 -0
  23. package/modules/restrict/restrict-module.d.ts +21 -0
  24. package/modules/restrict/type.d.ts +35 -0
  25. package/modules/statistics/statistics-module.d.ts +73 -0
  26. package/modules/status/export.d.ts +1 -0
  27. package/modules/status/status-module.d.ts +45 -0
  28. package/modules/status/type.d.ts +47 -0
  29. package/modules/warm/warm-module.d.ts +14 -0
  30. package/package.json +2 -18
  31. package/player.d.ts +151 -0
  32. package/polyv-live-player.d.ts +95 -0
  33. package/polyv-live-player.js +3 -3
  34. package/store/index.d.ts +12 -0
  35. package/store/types.d.ts +54 -0
  36. package/types/error-code.d.ts +24 -0
  37. package/types/index.d.ts +202 -0
  38. package/utils/index.d.ts +34 -0
  39. package/utils/stringByte.d.ts +13 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file 清晰度控制模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import { LevelItem } from '../../types';
6
+ export declare class LevelControl extends ModuleBase {
7
+ private readonly definitionMap;
8
+ /**
9
+ * 获取清晰度配置
10
+ */
11
+ getLevelSetting(): LevelItem[];
12
+ /**
13
+ * 设置初始线路
14
+ */
15
+ setInitDefaultLevel(): void;
16
+ /**
17
+ * 根据线路获取默认清晰度索引
18
+ * @param lineIndex
19
+ * @returns
20
+ */
21
+ getDefaultLevelIndexByLineIndex(lineIndex: number): number;
22
+ /**
23
+ * 切换清晰度
24
+ * @param level
25
+ * @returns
26
+ * */
27
+ changeLevel(level: number): void;
28
+ /**
29
+ * 根据清晰度获取源
30
+ * @param src
31
+ * @returns
32
+ */
33
+ getSrcFromLevel(src: string): string;
34
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @file 线路控制模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import { LineItem } from '../../types';
6
+ export declare class LineControl extends ModuleBase {
7
+ /**
8
+ * 获取线路配置
9
+ */
10
+ getLineSetting(): LineItem[];
11
+ /**
12
+ * 设置初始线路
13
+ */
14
+ setInitDefaultLine(): void;
15
+ /**
16
+ * 切换线路
17
+ * @param line
18
+ * @returns
19
+ */
20
+ changeLine(line: number): void;
21
+ /**
22
+ * 根据线路获取源
23
+ * @param src
24
+ * @returns
25
+ */
26
+ getSrcFromLine(src: string): string;
27
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 直播模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ export declare class Live extends ModuleBase {
6
+ /**
7
+ * 获取最新直播播放链接
8
+ */
9
+ getLiveSrc(): string;
10
+ /**
11
+ * 获取最新播放地址
12
+ */
13
+ resetLatestPlayUrl(): Promise<void>;
14
+ }
@@ -0,0 +1,7 @@
1
+ import PlayerCore from '../core';
2
+ export declare class ModuleBase {
3
+ private __playerCore;
4
+ constructor(__playerCore: PlayerCore);
5
+ getPlayerCore(): PlayerCore;
6
+ destroy(): void;
7
+ }
@@ -0,0 +1,20 @@
1
+ import { ModuleBase } from '../module-base';
2
+ export declare class Monitor extends ModuleBase {
3
+ /**
4
+ * 轮询定时器
5
+ */
6
+ private __timer;
7
+ /**
8
+ * 开始监控
9
+ */
10
+ start(): void;
11
+ /**
12
+ * 检查是否开始监控
13
+ */
14
+ private isStartCheck;
15
+ private __getPullTime;
16
+ /**
17
+ * 停止监控
18
+ */
19
+ private __stopTimer;
20
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 回放模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import { PlayType } from '../../types';
6
+ export declare class Playback extends ModuleBase {
7
+ /**
8
+ * 获取最新回放配置
9
+ */
10
+ getPlaybackSetting(): {
11
+ playType: PlayType;
12
+ src: string;
13
+ duration: number | undefined;
14
+ sessionId: string;
15
+ } | undefined;
16
+ }
@@ -0,0 +1 @@
1
+ export * from './type';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @file 质量监控模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import PlayerCore from '../../core';
6
+ import { QosEventType } from './type';
7
+ export declare class Qos extends ModuleBase {
8
+ /**
9
+ * 缓冲开始时间
10
+ */
11
+ private __loadingStartTime;
12
+ /**
13
+ * 是否是第一次缓冲
14
+ */
15
+ private __isFirstBuffer;
16
+ /**
17
+ * 是否是第一次加载
18
+ */
19
+ private __isFirstLoading;
20
+ /**
21
+ * 卡顿定时器
22
+ */
23
+ private __stallingTimer;
24
+ constructor(playerCore: PlayerCore);
25
+ /**
26
+ * 开始缓冲
27
+ */
28
+ loadingStart(): void;
29
+ /**
30
+ * 结束缓冲
31
+ */
32
+ loadingEnd(): void;
33
+ /**
34
+ * 发生播放错误
35
+ */
36
+ errorTrigger(args?: any): void;
37
+ /**
38
+ * 清除卡顿定时器
39
+ */
40
+ private __clearStallingTimer;
41
+ /**
42
+ * 获取当前播放地址的域名
43
+ * @returns 域名字符串,如果无法获取则返回空字符串
44
+ */
45
+ private __getCurrentPlayerSrcDomain;
46
+ /**
47
+ * 获取基础质量监控数据
48
+ * @returns 基础质量监控数据对象
49
+ */
50
+ private __getBaseQosData;
51
+ /**
52
+ * 发送QoS数据
53
+ * @param type 事件类型
54
+ * @param extraData 额外的数据,会合并到基础QoS数据中
55
+ * @returns Promise<void>
56
+ */
57
+ sendQosData(type: QosEventType, extraData?: Record<string, any>): Promise<void>;
58
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @file QoS类型定义
3
+ */
4
+ /**
5
+ * QoS事件类型枚举
6
+ */
7
+ export declare enum QosEventType {
8
+ /**
9
+ * 初始化
10
+ */
11
+ INIT = "init",
12
+ /**
13
+ * 频道配置更新
14
+ */
15
+ LOAD_CHANNEL_JSON = "cjson",
16
+ /**
17
+ * 限制配置更新
18
+ */
19
+ LOAD_RESTRICT_JSON = "rjson",
20
+ /**
21
+ * 二次缓冲结束
22
+ */
23
+ BUFFER = "buffer",
24
+ /**
25
+ * 加载到画面的时长
26
+ */
27
+ LOADING = "loading",
28
+ /**
29
+ * 播放错误
30
+ */
31
+ PLAY_ERROR = "error",
32
+ /**
33
+ * 播放卡顿
34
+ */
35
+ STALLING = "stalling",
36
+ /**
37
+ * 直播状态切换
38
+ */
39
+ SWITCH = "switch",
40
+ /**
41
+ * 直播状态
42
+ */
43
+ STATUS_LIVE = "statuslive"
44
+ }
45
+ /**
46
+ * 基础QoS数据接口
47
+ */
48
+ export interface IQosBaseData {
49
+ /**
50
+ * 用户ID
51
+ */
52
+ uid: string;
53
+ /**
54
+ * 频道ID
55
+ */
56
+ cid: string;
57
+ /**
58
+ * 播放ID
59
+ */
60
+ pid: string;
61
+ /**
62
+ * 时间戳
63
+ */
64
+ ts: number;
65
+ /**
66
+ * 当前播放链接域名
67
+ */
68
+ domain?: string;
69
+ /**
70
+ * 会话ID
71
+ */
72
+ session_id?: string;
73
+ /**
74
+ * 客户端信息
75
+ */
76
+ client?: string;
77
+ /**
78
+ * 动态参数
79
+ */
80
+ [key: string]: any;
81
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @file 无延迟控制模块
3
+ */
4
+ /// <reference types="miniprogram-api-typings" />
5
+ import { ModuleBase } from '../module-base';
6
+ import { PlayCoreType } from '../../types';
7
+ export declare class QuickControl extends ModuleBase {
8
+ /**
9
+ * 频道是否可以使用无延迟播放
10
+ * @returns
11
+ */
12
+ canUseQuick(): boolean;
13
+ /**
14
+ * 设备是否支持无延迟播放
15
+ * @returns
16
+ */
17
+ canQuickSupport(): boolean;
18
+ /**
19
+ * 获取无延迟播放地址
20
+ */
21
+ getSrcFromQuick(src: string): string;
22
+ /**
23
+ * 获取延迟内核配置
24
+ */
25
+ getPlayCoreSetting(): {
26
+ type: PlayCoreType;
27
+ core: number;
28
+ enabled: boolean;
29
+ }[];
30
+ /**
31
+ * 设置初始延迟内核
32
+ */
33
+ setInitDefaultPlayCore(): void;
34
+ /**
35
+ * 切换延迟内核
36
+ * @param playCore 延迟内核索引 0 代表普通延迟 1 代表无延迟
37
+ */
38
+ changePlayCore(playCore: number): void;
39
+ setLivePlayerStateChange(e: WechatMiniprogram.LivePlayerStateChange): void;
40
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file restrict.json 模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ export declare class RestrictJson extends ModuleBase {
6
+ /**
7
+ * 获取限制信息的配置
8
+ * @returns
9
+ */
10
+ private __getRestrictJson;
11
+ /**
12
+ * 获取限制信息的配置备用接口
13
+ * @returns
14
+ */
15
+ private __getBackupRestrictJson;
16
+ /**
17
+ * 检查是否可以观看
18
+ * @returns
19
+ */
20
+ checkCanWatch(): Promise<void>;
21
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 用户状态
3
+ */
4
+ type RestrictUserStatus = 'NORMAL' | '';
5
+ /**
6
+ * 限制信息配置接口返回内容
7
+ */
8
+ export interface IRestrictJsonResponse {
9
+ /**
10
+ * 用户状态
11
+ */
12
+ userStatus: RestrictUserStatus;
13
+ /**
14
+ * 是否可以观看
15
+ */
16
+ canWatch: boolean;
17
+ /**
18
+ * 错误码
19
+ */
20
+ errorCode: string;
21
+ }
22
+ /**
23
+ * 限制信息配置接口请求参数
24
+ */
25
+ export interface IRestrictJsonRequest {
26
+ /**
27
+ * 用户ID
28
+ */
29
+ uid: string;
30
+ /**
31
+ * 频道ID
32
+ */
33
+ cid: string;
34
+ }
35
+ export {};
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @file 统计模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import PlayerCore from '../../core';
6
+ import { PlayerStatisticsSetting } from '../../types';
7
+ export declare class Statistics extends ModuleBase {
8
+ /**
9
+ * 开始时间戳
10
+ */
11
+ private __startTimeStamps;
12
+ /**
13
+ * 轮询定时器
14
+ */
15
+ private __pollingInterval;
16
+ /**
17
+ * 播放唯一标识 PID
18
+ */
19
+ pid: string;
20
+ /**
21
+ * 轮询间隔时间
22
+ */
23
+ private __pollingIntervalTime;
24
+ /**
25
+ * 播放时长
26
+ */
27
+ playDuration: number;
28
+ /**
29
+ * 播放时长计算定时器
30
+ */
31
+ private __playDurationCountInterval;
32
+ /**
33
+ * 停留时长开始时间戳
34
+ */
35
+ private __stayDurationStartTimeStamps;
36
+ /**
37
+ * 统计数据
38
+ */
39
+ private __updatingStatistics;
40
+ constructor(playerCore: PlayerCore);
41
+ /**
42
+ * 初始化
43
+ */
44
+ private __init;
45
+ startPolling(): void;
46
+ stopPolling(): void;
47
+ startCountPd(): void;
48
+ stopCountPd(): void;
49
+ /**
50
+ * 发送统计日志
51
+ */
52
+ sendStatistics(): Promise<void>;
53
+ /**
54
+ * 设置统计数据
55
+ * @param statics 统计数据
56
+ */
57
+ setStatics(statics: PlayerStatisticsSetting): void;
58
+ /**
59
+ * 改变统计基础参数
60
+ */
61
+ changeStatisticsBaseParams(): void;
62
+ /**
63
+ * 获取播放唯一标识 PID, 需要注意PID变更pd需要同时重置为0
64
+ * @returns
65
+ */
66
+ private __getPid;
67
+ /**
68
+ * 获取统计数据
69
+ * @returns
70
+ */
71
+ getParams(): Record<string, any>;
72
+ destroy(): void;
73
+ }
@@ -0,0 +1 @@
1
+ export { ApiStatus } from './type';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file 流状态模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import PlayerCore from '../../core';
6
+ export declare class Status extends ModuleBase {
7
+ /**
8
+ * 开始时间戳
9
+ */
10
+ private __startTimeStamps;
11
+ /**
12
+ * 轮询定时器
13
+ */
14
+ private __pollingInterval;
15
+ /**
16
+ * 是否是第一次获取流状态
17
+ */
18
+ private __isFirstGetStatus;
19
+ constructor(playerCore: PlayerCore);
20
+ /**
21
+ * 初始化
22
+ */
23
+ private __init;
24
+ /**
25
+ * 获取轮询间隔时间
26
+ * @returns
27
+ */
28
+ private __getPollingIntervalTime;
29
+ /**
30
+ * 获取流名
31
+ * @returns
32
+ */
33
+ private __getStreamName;
34
+ /**
35
+ * 获取频道ID
36
+ * @returns
37
+ */
38
+ private __getCid;
39
+ startPolling(): void;
40
+ /**
41
+ * 停止轮询
42
+ */
43
+ stopPolling(): void;
44
+ destroy(): void;
45
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 播放器状态
3
+ */
4
+ export declare enum ApiStatus {
5
+ /**
6
+ * 直播进行中
7
+ */
8
+ LIVE = "live",
9
+ /**
10
+ * 直播结束
11
+ */
12
+ END = "end",
13
+ /**
14
+ * 中途暂停
15
+ */
16
+ STOP = "stop"
17
+ }
18
+ /**
19
+ * 获取API状态接口响应参数
20
+ */
21
+ export interface IGetApiStatusResponse {
22
+ /**
23
+ * 状态
24
+ */
25
+ status: ApiStatus;
26
+ /**
27
+ * 场次ID
28
+ */
29
+ sessionId: string;
30
+ }
31
+ /**
32
+ * 获取API状态接口请求参数
33
+ */
34
+ export interface IGetApiStatusRequest {
35
+ /**
36
+ * 频道ID
37
+ */
38
+ channelId: string;
39
+ /**
40
+ * 流名
41
+ */
42
+ stream: string;
43
+ /**
44
+ * 随机数
45
+ */
46
+ ran: number;
47
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 暖场模块
3
+ */
4
+ import { ModuleBase } from '../module-base';
5
+ import { PlayType } from '../../types';
6
+ export declare class Warm extends ModuleBase {
7
+ /**
8
+ * 获取暖场配置
9
+ */
10
+ getWarmSetting(): {
11
+ playType: PlayType;
12
+ src: string;
13
+ } | undefined;
14
+ }
package/package.json CHANGED
@@ -1,22 +1,6 @@
1
1
  {
2
2
  "name": "@polyv/wx-live-player-core",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "main": "polyv-live-player.js",
5
- "types": "polyv-live-player.d.ts",
6
- "dependencies": {
7
- "aes-js": "^3.1.2",
8
- "eventemitter3": "^5.0.1",
9
- "js-base64": "^3.7.7",
10
- "md5": "^2.3.0"
11
- },
12
- "files": [
13
- "polyv-live-player.d.ts",
14
- "polyv-live-player.js"
15
- ],
16
- "lint-staged": {
17
- "*.{js,ts}": [
18
- "eslint --fix",
19
- "prettier --write"
20
- ]
21
- }
5
+ "types": "polyv-live-player.d.ts"
22
6
  }