@byteplus/veplayer 1.6.0-alpha.3 → 1.6.3-rc.1

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 CHANGED
@@ -1,62 +1,46 @@
1
- ### Volcengine/player
1
+ ### VePlayer
2
2
 
3
- 火山引擎视频云播放器,BytePlus平台见[英文版](./READEME_EN.md)
4
-
5
- ### 安装
3
+ [BytePlus](https://www.byteplus.com/en) Web player SDK,can automatically adapt to PC and H5 scenes, support MP4, HLS, FLV, DASH and other formats of on-demand and live broadcast, combined with video cloud, it has functions such as playback quality log reporting, encrypted playback, etc.
6
4
 
5
+ ### Import the SDK
6
+ Install SDK dependencies into the project through the package management tool.
7
7
  ```bash
8
- npm install @volcengine/veplayer --save
8
+ npm install @byteplus/veplayer --save
9
+ ```
10
+ Import VePlayer and style files in the project.
11
+ ```javascript
12
+ import VePlayer from '@byteplus/veplayer';
13
+ import '@byteplus/veplayer/dist/index.min.css';
9
14
  ```
10
15
 
11
- ### 示例
16
+ ### Add playback container
17
+ Add a player container on the page where the player needs to be displayed, for example, add the following code to index.html.
18
+ ```javascript
19
+ <div id="video"></div>
20
+ ```
21
+ ### Player instantiation
22
+ After getting the video URL, instantiate the player.
12
23
 
13
- ```js
14
- const playerSdk = new VePlayer({
15
- id: 'mse',
16
- url: '/url',
17
- playList: [
18
- {
19
- lineId: 1,
20
- lineTextKey: '线路一',
21
- url: '/url',
22
- definition: 'ld',
23
- streamType: 'rtm',
24
- definitionTextKey: 'LD',
25
- },
26
- {
27
- lineId: 1,
28
- lineTextKey: '线路一',
29
- url: '/url',
30
- definition: 'hd',
31
- streamType: 'rtm',
32
- definitionTextKey: 'HD',
33
- },
34
- {
35
- lineId: 1,
36
- lineTextKey: '线路一',
37
- url: '/url',
38
- definition: 'uhd',
39
- streamType: 'rtm',
40
- definitionTextKey: 'UHD',
41
- },
42
- {
43
- lineId: 2,
44
- lineTextKey: '线路二',
45
- url: '/url',
46
- definition: 'ld',
47
- streamType: 'rtm',
48
- definitionTextKey: 'LD',
49
- },
50
- {
51
- lineId: 2,
52
- lineTextKey: '线路二',
53
- url: '/url',
54
- definition: 'hd',
55
- streamType: 'rtm',
56
- definitionTextKey: 'HD',
57
- },
58
- ],
59
- width: 600,
60
- height: 400,
24
+ #### Video On Demand
25
+ ```javascript
26
+ const player = new VePlayer({
27
+ id: 'video', // playback container
28
+ url: "https://demo.vod.com/xxx.mp4", // video URL
29
+ vodLogOpts: {
30
+ vtype: 'MP4', // Video format, the video of HLS protocol should be imported into HLS
31
+ tag: 'Normal', // Business tags, used to distinguish different scenarios in the business, to facilitate subsequent multi-dimensional analysis
32
+ line_app_id: 235399, // [Required] The value is int type, the SDK application id for accessing VOD, which can be obtained from VOD Console-VOD SDK-Application Management
33
+ line_user_id: 'XXX' // User id, String or int type, if not passed in, it will be a value randomly generated according to the user's browser
34
+ }
61
35
  });
62
36
  ```
37
+ For a detailed description of VOD, refer to[BytePlus - Video On Demand - Player SDK - Web](https://docs.byteplus.com/en/byteplus-vod/docs/getting-started-with-the-sdk_2)
38
+
39
+ #### Live
40
+ ```javascript
41
+ const playerSdk = new VePlayer({
42
+ id: 'video',
43
+ isLive: true,
44
+ url: '//livepull.example.com/appname/streamname.flv'
45
+ });
46
+ ```
@@ -1,4 +1,6 @@
1
+ import VodLogger from '@byted/xgplayer-app-logger/es/logger.js';
1
2
  import { Property } from 'dom-helpers/esm/types';
3
+ import EventEmitter from 'eventemitter3';
2
4
  import Player from 'xgplayer';
3
5
  import { I18N, IXGI18nText, Plugin } from 'xgplayer';
4
6
 
@@ -445,62 +447,6 @@ export interface ISubtitleStyle {
445
447
  */
446
448
  fontColor?: string;
447
449
  }
448
- /**
449
- * @detail Options
450
- *
451
- * @export
452
- * @interface IListItem
453
- */
454
- export interface IListItem {
455
- /**
456
- * 开始时间
457
- * 默认值:无
458
- * @type { number}
459
- * @memberof IListItem
460
- */
461
- start: number;
462
- /**
463
- * 结束时间
464
- * 默认值:无
465
- * @type { number}
466
- * @memberof IListItem
467
- */
468
- end: number;
469
- /**
470
- * 字幕文案列表
471
- * 默认值:无
472
- * @type {Array<Object>}
473
- * @memberof IListItem
474
- */
475
- list: {
476
- /**
477
- * 默认值:无
478
- * @hidden
479
- * @type {any}
480
- */
481
- [propName: string]: any;
482
- /**
483
- * 开始时间
484
- * @type {number}
485
- */
486
- start: number;
487
- /**
488
- * 结束时间
489
- * @type {number}
490
- */
491
- end: number;
492
- /**
493
- * 字幕文案数组
494
- * @type {string[]}
495
- */
496
- text: string[];
497
- /**
498
- * 字幕顺序
499
- * @type {number}
500
- */
501
- index?: number;
502
- }[];
503
- }
504
450
  /**
505
451
  * @detail Options
506
452
  *
@@ -557,29 +503,70 @@ export interface ISubTitleItem {
557
503
  * @type {Array<Object>}
558
504
  * @memberof ISubTitleItem
559
505
  */
560
- list?: {
561
- /**
562
- * 默认值:无
563
- * @hidden
564
- * @type {any}
565
- */
566
- [propName: string]: any;
567
- /**
568
- * 开始时间
569
- * @type {number}
570
- */
571
- start: number;
572
- /**
573
- * 结束时间
574
- * @type {number}
575
- */
576
- end: number;
577
- /**
578
- * 子字幕列表
579
- * @type {Array<IListItem>}
580
- */
581
- list: Array<IListItem>;
582
- }[];
506
+ list?: IListItem[];
507
+ }
508
+ /**
509
+ * @detail Options
510
+ *
511
+ * @export
512
+ * @interface IListItem
513
+ */
514
+ export interface IListItem {
515
+ /**
516
+ * 开始时间
517
+ * @type {number}
518
+ */
519
+ start: number;
520
+ /**
521
+ * 结束时间
522
+ * @type {number}
523
+ */
524
+ end: number;
525
+ /**
526
+ * 字幕数据列表
527
+ * @type {Array<ITextItem>}
528
+ */
529
+ list: Array<ITextItem>;
530
+ /**
531
+ * 默认值:无
532
+ * @hidden
533
+ * @type {any}
534
+ */
535
+ [propName: string]: any;
536
+ }
537
+ /**
538
+ * @detail Options
539
+ *
540
+ * @export
541
+ * @interface ITextItem
542
+ */
543
+ export interface ITextItem {
544
+ /**
545
+ * 默认值:无
546
+ * @hidden
547
+ * @type {any}
548
+ */
549
+ [propName: string]: any;
550
+ /**
551
+ * 开始时间
552
+ * @type {number}
553
+ */
554
+ start: number;
555
+ /**
556
+ * 结束时间
557
+ * @type {number}
558
+ */
559
+ end: number;
560
+ /**
561
+ * 字幕文案数组
562
+ * @type {string[]}
563
+ */
564
+ text: string[];
565
+ /**
566
+ * 字幕顺序
567
+ * @type {number}
568
+ */
569
+ index?: number;
583
570
  }
584
571
  /**
585
572
  * @detail Options
@@ -828,11 +815,17 @@ export interface IVodLogOptsConfig {
828
815
  */
829
816
  vtype?: "MP4" | "HLS" | "DASH" | "FLV";
830
817
  /**
831
- * 自定义标签
818
+ * 自定义标签,对应控制台"业务维类型"维度
832
819
  * 默认:`default`
833
820
  * 必选
834
821
  */
835
822
  tag?: string;
823
+ /**
824
+ * 自定义子标签,对应控制台"自定义标签"维度
825
+ * 默认:`default`
826
+ * 必选
827
+ */
828
+ subtag?: string;
836
829
  /**
837
830
  * 视频解码器类型名称
838
831
  * 默认:`h264`
@@ -1105,10 +1098,20 @@ export interface apiMapItem {
1105
1098
  playDomain: string;
1106
1099
  backupPlayDomain?: string;
1107
1100
  }
1101
+ export interface IAutoplayPluginConfig {
1102
+ position?: string;
1103
+ enableDegradeMuteAutoplay?: boolean;
1104
+ enableWxJsBridgeAutoplay?: boolean;
1105
+ userActionDom?: Node;
1106
+ enableUserActionAutoplay?: boolean;
1107
+ }
1108
1108
  declare enum CodecType {
1109
1109
  H265 = "h265",
1110
1110
  H264 = "h264"
1111
1111
  }
1112
+ declare enum RTMCodec {
1113
+ H264 = "h264"
1114
+ }
1112
1115
  export declare type PLAY_MODE_TYPE = "order" | "sloop" | "loop" | "random";
1113
1116
  export interface IMusicListItem {
1114
1117
  /**
@@ -1373,6 +1376,13 @@ export interface IPlayerConfig extends IPlayerOptions {
1373
1376
  * @memberof IPlayerConfig
1374
1377
  */
1375
1378
  enableHlsMSE?: boolean;
1379
+ /**
1380
+ * 在PC Safari上是否不使用hls插件播放,默认true。true: 启用;false: 不启用
1381
+ *
1382
+ * @type {boolean}
1383
+ * @memberof IPlayerConfig
1384
+ */
1385
+ useHlsPluginForSafari?: boolean;
1376
1386
  /**
1377
1387
  * 是否开启mp4的MSE模式,开启后采用MSE方式播放MP4,
1378
1388
  * 同时带来精确的seek加载、视频的无缝切换、流量节省等功能
@@ -1489,6 +1499,34 @@ export interface IPlayerConfig extends IPlayerOptions {
1489
1499
  * @memberof IPlayerConfig
1490
1500
  */
1491
1501
  expireDetectType?: Array<"xhrStatus" | "getUrlTime">;
1502
+ /**
1503
+ * 有声音自动播放失败时是否降级成静音自动播放,默认不降级
1504
+ *
1505
+ * @type {boolean}
1506
+ * @memberof IPlayerConfig
1507
+ */
1508
+ enableDegradeMuteAutoplay?: boolean;
1509
+ /**
1510
+ * 启用微信jsBridge方式的自动播放,默认不开启
1511
+ *
1512
+ * @type {boolean}
1513
+ * @memberof IPlayerConfig
1514
+ */
1515
+ enableWxJsBridgeAutoplay?: boolean;
1516
+ /**
1517
+ * 开启任意点击的用户行为触发自动播放,默认不开启
1518
+ *
1519
+ * @type {boolean}
1520
+ * @memberof IPlayerConfig
1521
+ */
1522
+ enableUserActionAutoplay?: boolean;
1523
+ /**
1524
+ * 禁用点播日志配置检测,默认开启,如果未配置line_app_id则会播放报错
1525
+ *
1526
+ * @type {boolean}
1527
+ * @memberof IPlayerConfig
1528
+ */
1529
+ disableVodLogOptsCheck?: boolean;
1492
1530
  /**
1493
1531
  * 播放器报错展示配置, 可以配置播放异常时的播放器显示的异常文案、图片,以及是否提供刷新按钮等
1494
1532
  *
@@ -1580,6 +1618,12 @@ export interface IPlayerConfig extends IPlayerOptions {
1580
1618
  * @memberof IPlayerConfig
1581
1619
  */
1582
1620
  music?: IMusicConfig;
1621
+ /**
1622
+ * 自动播放配置
1623
+ * @type {IMusicConfig}
1624
+ * @memberof IPlayerConfig
1625
+ */
1626
+ AutoplayPlugin?: IAutoplayPluginConfig;
1583
1627
  }
1584
1628
  /**
1585
1629
  * 初始配置
@@ -1661,6 +1705,14 @@ export interface IPlayAuthTokenConfig {
1661
1705
  * @memberof IPlayAuthTokenConfig
1662
1706
  */
1663
1707
  playAuthToken: string;
1708
+ /**
1709
+ * 默认清晰度
1710
+ *
1711
+ * @notes 为空时默认为最大码率的清晰度
1712
+ * @type {string}
1713
+ * @memberof IPlayAuthTokenConfig
1714
+ */
1715
+ defaultDefinition?: string;
1664
1716
  /**
1665
1717
  * 求地址接口域名
1666
1718
  *
@@ -1712,20 +1764,20 @@ export interface IPlayAuthTokenConfig {
1712
1764
  */
1713
1765
  getKeyType?: string;
1714
1766
  /**
1715
- * 获取privateDrmAuthToken的回调,
1767
+ * 获取privateDrmAuthToken的异步回调,
1716
1768
  * @type {(
1717
1769
  * playAuthIds: string,
1718
1770
  * vid: string,
1719
1771
  * unionInfo: string,
1720
- * ) => Promise<Record<string, string>>}
1772
+ * ) => Promise<string>}
1773
+ * 回调入参:
1774
+ * playAuthIds 视频的密钥 KeyID,对应OpenAPI GetPlayInfo{@link https://www.volcengine.com/docs/4/2918#%E8%AF%B7%E6%B1%82%E8%AF%B4%E6%98%8E} 返回视频信息中的PlayAuthId,当有多个KeyID时以英文逗号相连
1775
+ * vid 视频vid
1776
+ * unionInfo 由unionId生成的unionInfo,以用来加密PrivateDrmAuthToken
1721
1777
  * @memberof IPlayAuthTokenConfig
1778
+ *
1722
1779
  */
1723
1780
  getDrmAuthToken?: (playAuthIds: string, vid: string, unionInfo: string) => Promise<string>;
1724
- /**
1725
- * 是否禁用DRM解密播放降级,默认false
1726
- * @type {boolean}
1727
- */
1728
- disDrmDegraded?: boolean;
1729
1781
  /**
1730
1782
  * 可携带aid等透传参数,如
1731
1783
  * {aid: 1234},以playAuthToken下发的参数的优先级最高。
@@ -1902,6 +1954,8 @@ declare class PlayerData {
1902
1954
  unionId?: string;
1903
1955
  unionInfo?: string;
1904
1956
  isMusic?: boolean;
1957
+ sdkPlugins: any[];
1958
+ useHlsPluginForSafari: boolean;
1905
1959
  constructor(configs: IPlayerConfig);
1906
1960
  initPlayData(configs: any): void;
1907
1961
  initPlaylistAndGetCurrent(configs: IPlayerConfig): any;
@@ -1927,7 +1981,7 @@ declare class PlayerData {
1927
1981
  /**
1928
1982
  * @description: 获取根据线路ID去重的流,用于获取有几个线路
1929
1983
  */
1930
- getLineList(): any;
1984
+ getLineList(): Stream[];
1931
1985
  /**
1932
1986
  * @description: 根据线路ID获取符合条件的流
1933
1987
  * @param {number} lineId
@@ -1937,7 +1991,7 @@ declare class PlayerData {
1937
1991
  * @description: 根据线路ID获取清晰度list,用于获取某个线路下有几个清晰度
1938
1992
  * @param {number} lineId
1939
1993
  */
1940
- getDefinitionListByLineId(lineId: number | string): any;
1994
+ getDefinitionListByLineId(lineId: number | string): Stream[];
1941
1995
  /**
1942
1996
  * @description: 根据条件筛选符合条件的流list
1943
1997
  * @param {Condition} condition
@@ -1965,6 +2019,7 @@ declare class MobilePlayerPanel {
1965
2019
  container: HTMLElement | undefined;
1966
2020
  title: HTMLElement | undefined;
1967
2021
  isShow: boolean;
2022
+ showCancelBtn: boolean;
1968
2023
  constructor(args: any);
1969
2024
  initEvents(): void;
1970
2025
  handleOrientationChange(): void;
@@ -2002,6 +2057,7 @@ declare class VePlayer {
2002
2057
  playerVersion?: string;
2003
2058
  panel?: MobilePlayerPanel;
2004
2059
  emitExpireTimestamp?: number;
2060
+ vodLogger?: VodLogger;
2005
2061
  };
2006
2062
  /**
2007
2063
  * @hidden
@@ -2099,7 +2155,10 @@ declare class VePlayer {
2099
2155
  private sdkUmdLoader;
2100
2156
  static isMSESupported: typeof isMSESupport;
2101
2157
  static isRTMSupported: typeof import("@byted/xgplayer-rts").RtsPlugin.isSupported;
2102
- static playerVersion: string;
2158
+ static sdkVersion: string;
2159
+ static isRTMSupportCodec: (codec: RTMCodec, options: {
2160
+ targetProfileLevel?: string;
2161
+ }) => Promise<boolean>;
2103
2162
  constructor(configs: IPlayerConfig);
2104
2163
  /**
2105
2164
  *
@@ -2127,6 +2186,7 @@ declare class VePlayer {
2127
2186
  * @memberof VePlayer
2128
2187
  */
2129
2188
  private initUmdLoader;
2189
+ private checkVodLogOptions;
2130
2190
  /**
2131
2191
  * @hidden
2132
2192
  * @description umd 加载失败的回调
@@ -2209,6 +2269,7 @@ declare class VePlayer {
2209
2269
  playerVersion?: string;
2210
2270
  panel?: MobilePlayerPanel;
2211
2271
  emitExpireTimestamp?: number;
2272
+ vodLogger?: VodLogger;
2212
2273
  }>;
2213
2274
  /**
2214
2275
  * @hidden
@@ -2425,6 +2486,7 @@ declare class VePlayer {
2425
2486
  playerVersion?: string;
2426
2487
  panel?: MobilePlayerPanel;
2427
2488
  emitExpireTimestamp?: number;
2489
+ vodLogger?: VodLogger;
2428
2490
  };
2429
2491
  /**
2430
2492
  * @hidden
@@ -2565,6 +2627,11 @@ declare class VePlayer {
2565
2627
  * @memberof VePlayer
2566
2628
  */
2567
2629
  musicRemoveAbCycle(): void;
2630
+ /**
2631
+ * 获取质量日志上报的用户id
2632
+ * @return {string | undefined}
2633
+ */
2634
+ getLogUserId(): any;
2568
2635
  /**
2569
2636
  * 销毁当前播放器SDK实例
2570
2637
  *
@@ -3130,6 +3197,54 @@ export declare class LiveInfoPanel extends Plugin {
3130
3197
  close(): void;
3131
3198
  render(): string;
3132
3199
  }
3200
+ export declare class SdkPlugin {
3201
+ pluginName: string;
3202
+ __args: any;
3203
+ sdk: VePlayer;
3204
+ playerData: PlayerData;
3205
+ player: Player;
3206
+ _emitter: EventEmitter;
3207
+ static defineGetterOrSetter(Obj: any, map: any): void;
3208
+ /**
3209
+ * @type { string }
3210
+ */
3211
+ static get pluginName(): string;
3212
+ /**
3213
+ * @constructor
3214
+ * @param { { sdk: object, pluginName: string, [propName: string]: any;} } args
3215
+ */
3216
+ constructor(args: any);
3217
+ /**
3218
+ * @description sdk实例创建,挂载插件实例时首先执行
3219
+ */
3220
+ beforeCreate(): void;
3221
+ /**
3222
+ * @description sdk实例创建,挂载插件实例完后执行
3223
+ */
3224
+ afterCreate(): void;
3225
+ /**
3226
+ * @description sdk创建播放器前执行,只有这里能保证异步操作在creatPlayer之前同步完成
3227
+ */
3228
+ beforePlayerCreate(): void;
3229
+ /**
3230
+ * @description sdk创建播放器完执行
3231
+ */
3232
+ afterPlayerCreate(): void;
3233
+ /**
3234
+ * @description sdk销毁时执行
3235
+ */
3236
+ destroy(): void;
3237
+ /**
3238
+ * @private
3239
+ * @param { any } args
3240
+ */
3241
+ __init(args: any): void;
3242
+ /**
3243
+ * @description 插件销毁
3244
+ * @private
3245
+ */
3246
+ __destroy(): void;
3247
+ }
3133
3248
  export * from "xgplayer";
3134
3249
 
3135
3250
  export {