@byteplus/veplayer 2.11.2 → 2.12.0-rc.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.
@@ -659,6 +659,22 @@
659
659
  .xgplayer-pc.xgplayer-is-error .xgplayer-start {
660
660
  display: none;
661
661
  }
662
+ .xgplayer-mobile.xgplayer-mobile-mini-window video,
663
+ .xgplayer-mobile.xgplayer-mobile-mini-window xg-video {
664
+ position: fixed;
665
+ top: 0;
666
+ left: 0;
667
+ z-index: 9999;
668
+ /* stylelint-disable-next-line declaration-no-important */
669
+ width: 100vw !important;
670
+ /* stylelint-disable-next-line declaration-no-important */
671
+ height: 100vh !important;
672
+ }
673
+ .xgplayer-mobile.xgplayer-mobile-mini-window .xgplayer-start {
674
+ position: fixed;
675
+ /* stylelint-disable-next-line declaration-no-important */
676
+ z-index: 10000 !important;
677
+ }
662
678
  .xgplayer-mobile .xgplayer-progress .xgplayer-progress-played {
663
679
  background: #3469ff;
664
680
  }
@@ -701,15 +717,15 @@
701
717
  display: none;
702
718
  }
703
719
  .veplayer-logo {
704
- display: none;
705
720
  position: absolute;
706
- visibility: visible;
721
+ top: 20px;
722
+ right: 20px;
723
+ z-index: 10;
724
+ display: none;
707
725
  width: 70px;
708
726
  height: 20px;
709
- right: 20px;
710
- top: 20px;
727
+ visibility: visible;
711
728
  opacity: 1;
712
- z-index: 10;
713
729
  }
714
730
  .veplayer-logo svg {
715
731
  width: 100%;
@@ -14337,6 +14337,373 @@ class CustomMedia {
14337
14337
  replaceAttributes(this._el, this._videoAttributes);
14338
14338
  }
14339
14339
  }
14340
+ var Web2NativeMessageEvent = /* @__PURE__ */ ((Web2NativeMessageEvent2) => {
14341
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["INIT_FINISH"] = 10001] = "INIT_FINISH";
14342
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["CREATE_PLAYER"] = 11e3] = "CREATE_PLAYER";
14343
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["DESTROY_PLAYER"] = 11001] = "DESTROY_PLAYER";
14344
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["OPEN_FULLSCREEN"] = 11002] = "OPEN_FULLSCREEN";
14345
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["EXIT_FULLSCREEN"] = 11003] = "EXIT_FULLSCREEN";
14346
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["LIVE_ROOM_STATE_CHANGE"] = 11004] = "LIVE_ROOM_STATE_CHANGE";
14347
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["PLAYER_STATE_CHANGE"] = 11005] = "PLAYER_STATE_CHANGE";
14348
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["MEDIA_LOAD_FINISH"] = 11006] = "MEDIA_LOAD_FINISH";
14349
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["OPEN_MINI_WINDOW"] = 11007] = "OPEN_MINI_WINDOW";
14350
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["CLOSE_MINI_WINDOW"] = 11008] = "CLOSE_MINI_WINDOW";
14351
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["OPEN_WAKE_LOCK"] = 11009] = "OPEN_WAKE_LOCK";
14352
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["EXIT_WAKE_LOCK"] = 110010] = "EXIT_WAKE_LOCK";
14353
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["PUSH_WEB_DATA_INFO"] = 110011] = "PUSH_WEB_DATA_INFO";
14354
+ return Web2NativeMessageEvent2;
14355
+ })(Web2NativeMessageEvent || {});
14356
+ var Native2WebMessageEvent = /* @__PURE__ */ ((Native2WebMessageEvent2) => {
14357
+ Native2WebMessageEvent2[Native2WebMessageEvent2["ENTER_MINI_WINDOW"] = 21e3] = "ENTER_MINI_WINDOW";
14358
+ Native2WebMessageEvent2[Native2WebMessageEvent2["EXIT_MINI_WINDOW"] = 21001] = "EXIT_MINI_WINDOW";
14359
+ Native2WebMessageEvent2[Native2WebMessageEvent2["PAUSE"] = 21002] = "PAUSE";
14360
+ Native2WebMessageEvent2[Native2WebMessageEvent2["START_PLAY"] = 21003] = "START_PLAY";
14361
+ Native2WebMessageEvent2[Native2WebMessageEvent2["PLAY"] = 21004] = "PLAY";
14362
+ Native2WebMessageEvent2[Native2WebMessageEvent2["WEBVIEW_CONFIG"] = 21005] = "WEBVIEW_CONFIG";
14363
+ Native2WebMessageEvent2[Native2WebMessageEvent2["GET_WEB_DATA_INFO"] = 21006] = "GET_WEB_DATA_INFO";
14364
+ Native2WebMessageEvent2[Native2WebMessageEvent2["ENTER_FULLSCREEN"] = 21007] = "ENTER_FULLSCREEN";
14365
+ Native2WebMessageEvent2[Native2WebMessageEvent2["EXIT_FULLSCREEN"] = 21008] = "EXIT_FULLSCREEN";
14366
+ return Native2WebMessageEvent2;
14367
+ })(Native2WebMessageEvent || {});
14368
+ class ByteLiveJsBridge {
14369
+ constructor(data2) {
14370
+ __publicField(this, "_emitter", new EventEmitter$1());
14371
+ __publicField(this, "isInIOS", false);
14372
+ __publicField(this, "jsBridgeName", "ByteLiveJsBridge");
14373
+ __publicField(this, "jsBridge", null);
14374
+ __publicField(this, "data", {
14375
+ room: {},
14376
+ player: {}
14377
+ });
14378
+ // eslint-disable-next-line @typescript-eslint/member-ordering
14379
+ __publicField(this, "nativeConfig", {});
14380
+ if (data2 == null ? void 0 : data2.name) {
14381
+ this.jsBridgeName = data2.name;
14382
+ }
14383
+ this.init();
14384
+ }
14385
+ init() {
14386
+ this.initVariables();
14387
+ if (!this.jsBridge) {
14388
+ this.mountGlobal();
14389
+ }
14390
+ this.callToNative(Web2NativeMessageEvent.INIT_FINISH, {});
14391
+ }
14392
+ getJsBridge() {
14393
+ const jsBridge = Reflect.get(window, this.jsBridgeName);
14394
+ if (jsBridge) {
14395
+ this.jsBridge = jsBridge;
14396
+ }
14397
+ return this.jsBridge;
14398
+ }
14399
+ setJsBridge(jsBridge) {
14400
+ Reflect.set(window, this.jsBridgeName, jsBridge);
14401
+ Reflect.set(window, "VeCloudJsBridge", jsBridge);
14402
+ console.log("设置到 window 上");
14403
+ this.jsBridge = jsBridge;
14404
+ }
14405
+ initVariables() {
14406
+ this.isInIOS = Boolean(sniffer$1.os.isIos);
14407
+ }
14408
+ mountGlobal() {
14409
+ const JsBridge = this.getJsBridge();
14410
+ console.log("从 window 上获取到的 jsBridge", JsBridge);
14411
+ if (JsBridge) {
14412
+ JsBridge.nativeCallBack = (data2) => {
14413
+ console.log("收到native发来消息", data2);
14414
+ this.handelEventCallBack(data2);
14415
+ };
14416
+ this.jsBridge = JsBridge;
14417
+ } else {
14418
+ const JsBridge2 = {
14419
+ nativeCallBack: (data2) => {
14420
+ console.log("收到native发来消息", data2);
14421
+ this.handelEventCallBack(data2);
14422
+ }
14423
+ // invokeNative: (data: IMessage) => {
14424
+ // console.log('发送给native', data);
14425
+ // },
14426
+ };
14427
+ this.setJsBridge(JsBridge2);
14428
+ }
14429
+ this.bindWebDataInfo();
14430
+ this.bindGetNativeConfig();
14431
+ }
14432
+ on(action, func) {
14433
+ this._emitter.on(action, func);
14434
+ }
14435
+ handelEventCallBack(data2) {
14436
+ const { eventKey, info } = data2 ?? {};
14437
+ if (!eventKey || !Native2WebMessageEvent[eventKey]) {
14438
+ console.log("Native2Web未匹配到对应事件", eventKey);
14439
+ return;
14440
+ }
14441
+ this._emitter.emit(Native2WebMessageEvent[eventKey], info);
14442
+ }
14443
+ invokeNative(data2) {
14444
+ var _a, _b, _c;
14445
+ console.log("发送给native", data2);
14446
+ if (this.isInIOS) {
14447
+ (_c = (_b = (_a = window == null ? void 0 : window.webkit) == null ? void 0 : _a.messageHandlers) == null ? void 0 : _b.invokeNative) == null ? void 0 : _c.postMessage(data2);
14448
+ }
14449
+ const JsBridge = this.jsBridge || Reflect.get(window, this.jsBridgeName);
14450
+ console.log(
14451
+ "JsBridge",
14452
+ this.jsBridge,
14453
+ Reflect.get(window, this.jsBridgeName)
14454
+ );
14455
+ if (JsBridge.invokeNative) {
14456
+ JsBridge.invokeNative(JSON.stringify(data2));
14457
+ } else {
14458
+ console.log("未找到对应invokeNative方法");
14459
+ }
14460
+ }
14461
+ bindWebDataInfo() {
14462
+ this.on("GET_WEB_DATA_INFO", () => {
14463
+ this.callToNative(Web2NativeMessageEvent.PUSH_WEB_DATA_INFO, {
14464
+ ...this.data
14465
+ });
14466
+ });
14467
+ }
14468
+ bindGetNativeConfig() {
14469
+ this.on("WEBVIEW_CONFIG", (data2) => {
14470
+ this.nativeConfig = {
14471
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14472
+ // @ts-ignore
14473
+ ...this.nativeConfig,
14474
+ ...data2
14475
+ };
14476
+ });
14477
+ }
14478
+ callToNative(eventKey, info) {
14479
+ if (!eventKey || !Web2NativeMessageEvent[eventKey]) {
14480
+ console.log("Web2Native未匹配到对应事件", eventKey);
14481
+ return;
14482
+ }
14483
+ this.invokeNative({ eventKey, info });
14484
+ }
14485
+ callToNativeCreatePlayer(data2) {
14486
+ this.data.room = {
14487
+ ...this.data.room,
14488
+ isPortrait: data2.isPortrait
14489
+ };
14490
+ this.callToNative(Web2NativeMessageEvent.CREATE_PLAYER, data2);
14491
+ }
14492
+ callToNativeDestroyPlayer() {
14493
+ this.callToNative(Web2NativeMessageEvent.DESTROY_PLAYER, {});
14494
+ }
14495
+ callToNativeOpenFullScreen() {
14496
+ this.data.player = {
14497
+ ...this.data.player,
14498
+ fullscreen: true
14499
+ };
14500
+ this.callToNative(Web2NativeMessageEvent.OPEN_FULLSCREEN, {});
14501
+ }
14502
+ callToNativeExitFullScreen() {
14503
+ this.data.player = {
14504
+ ...this.data.player,
14505
+ fullscreen: false
14506
+ };
14507
+ this.callToNative(Web2NativeMessageEvent.EXIT_FULLSCREEN, {});
14508
+ }
14509
+ callToNativeLiveRoomStateChange(data2) {
14510
+ this.data.room = {
14511
+ ...this.data.room,
14512
+ status: data2.status
14513
+ };
14514
+ this.callToNative(Web2NativeMessageEvent.LIVE_ROOM_STATE_CHANGE, data2);
14515
+ }
14516
+ callToNativePlayerStateChange(data2) {
14517
+ this.data.player = {
14518
+ ...this.data.player,
14519
+ created: data2.created,
14520
+ paused: data2.paused
14521
+ };
14522
+ this.callToNative(Web2NativeMessageEvent.PLAYER_STATE_CHANGE, data2);
14523
+ }
14524
+ callToNativeMediaLoadFinish(data2) {
14525
+ this.data.player = {
14526
+ ...this.data.player,
14527
+ videoWidth: data2.videoWidth,
14528
+ videoHeight: data2.videoHeight
14529
+ };
14530
+ this.callToNative(Web2NativeMessageEvent.MEDIA_LOAD_FINISH, data2);
14531
+ }
14532
+ callToNativeOpenMiniWindow() {
14533
+ this.data.player = {
14534
+ ...this.data.player,
14535
+ mini: true
14536
+ };
14537
+ this.callToNative(Web2NativeMessageEvent.OPEN_MINI_WINDOW, {});
14538
+ }
14539
+ callToNativeCloseMiniWindow() {
14540
+ this.data.player = {
14541
+ ...this.data.player,
14542
+ mini: false
14543
+ };
14544
+ console.log("通知Native关闭小窗", /* @__PURE__ */ new Date());
14545
+ this.callToNative(Web2NativeMessageEvent.CLOSE_MINI_WINDOW, {});
14546
+ }
14547
+ callToNativeOpenWakeLock() {
14548
+ this.callToNative(Web2NativeMessageEvent.OPEN_WAKE_LOCK, {});
14549
+ }
14550
+ callToNativeExitWakeLock() {
14551
+ this.callToNative(Web2NativeMessageEvent.EXIT_WAKE_LOCK, {});
14552
+ }
14553
+ }
14554
+ let InnerJsBridge;
14555
+ const getJsbInstance = () => {
14556
+ if (InnerJsBridge)
14557
+ return InnerJsBridge;
14558
+ InnerJsBridge = new ByteLiveJsBridge();
14559
+ return InnerJsBridge;
14560
+ };
14561
+ var InnerJsBridge$1 = getJsbInstance();
14562
+ const bindPlayerEventsCallJSB = (player) => {
14563
+ const isPortrait = true;
14564
+ const isLive = true;
14565
+ if (!InnerJsBridge$1) {
14566
+ return;
14567
+ }
14568
+ if (!sniffer$1.os.isPc) {
14569
+ bindMiniWindowEvents(player);
14570
+ }
14571
+ InnerJsBridge$1.callToNativeCreatePlayer({
14572
+ isLive,
14573
+ isPortrait
14574
+ });
14575
+ InnerJsBridge$1.callToNativePlayerStateChange({
14576
+ created: true,
14577
+ paused: false
14578
+ });
14579
+ player.on(Events$2.PLAY, () => {
14580
+ InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativePlayerStateChange({
14581
+ created: true,
14582
+ paused: false
14583
+ });
14584
+ });
14585
+ player.on(Events$2.PAUSE, () => {
14586
+ InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativePlayerStateChange({
14587
+ created: true,
14588
+ paused: true
14589
+ });
14590
+ });
14591
+ player.on(Events$2.ERROR, () => {
14592
+ existMiniWindow();
14593
+ });
14594
+ player.on(Events$2.LOADED_DATA, () => {
14595
+ getVideoSizeWithRetry(player, isPortrait).then(
14596
+ ({ videoWidth, videoHeight }) => {
14597
+ InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativeMediaLoadFinish({
14598
+ isPortrait: videoHeight > videoWidth,
14599
+ videoWidth,
14600
+ videoHeight
14601
+ });
14602
+ }
14603
+ );
14604
+ });
14605
+ };
14606
+ const destroyPlayerEventsCallJSB = () => {
14607
+ if (InnerJsBridge$1) {
14608
+ InnerJsBridge$1.callToNativeDestroyPlayer();
14609
+ InnerJsBridge$1.callToNativePlayerStateChange({
14610
+ created: false,
14611
+ paused: true
14612
+ });
14613
+ }
14614
+ existMiniWindow();
14615
+ };
14616
+ const bindMiniWindowEvents = (player) => {
14617
+ if (!InnerJsBridge$1) {
14618
+ return;
14619
+ }
14620
+ const handleMiniWindowChange = (state) => {
14621
+ if (!player || !player.root) {
14622
+ return;
14623
+ }
14624
+ if (state) {
14625
+ player.addClass("xgplayer-mobile-mini-window");
14626
+ } else {
14627
+ player.removeClass("xgplayer-mobile-mini-window");
14628
+ }
14629
+ };
14630
+ InnerJsBridge$1.on("WEBVIEW_CONFIG", (data2) => {
14631
+ console.log("WEBVIEW_CONFIG", data2);
14632
+ if (data2 == null ? void 0 : data2.keepPlayWhenPageHide) {
14633
+ player.unRegisterPlugin("PageChangePlugin");
14634
+ }
14635
+ });
14636
+ InnerJsBridge$1.on("ENTER_MINI_WINDOW", () => {
14637
+ handleMiniWindowChange(true);
14638
+ });
14639
+ InnerJsBridge$1.on("EXIT_MINI_WINDOW", () => {
14640
+ console.log("切回小窗播放器处于暂停: ", player.paused, /* @__PURE__ */ new Date());
14641
+ if (player.paused) {
14642
+ player.play();
14643
+ }
14644
+ handleMiniWindowChange(false);
14645
+ });
14646
+ InnerJsBridge$1.on("PAUSE", () => {
14647
+ if (!player) {
14648
+ return;
14649
+ }
14650
+ player.pause();
14651
+ });
14652
+ InnerJsBridge$1.on("START_PLAY", () => {
14653
+ handleMiniWindowChange(false);
14654
+ if (!player) {
14655
+ return;
14656
+ }
14657
+ player.play();
14658
+ });
14659
+ InnerJsBridge$1.on("PLAY", () => {
14660
+ if (!player) {
14661
+ return;
14662
+ }
14663
+ player.play();
14664
+ });
14665
+ InnerJsBridge$1.on("ENTER_FULLSCREEN", () => {
14666
+ var _a;
14667
+ if (!(player == null ? void 0 : player.fullscreen)) {
14668
+ (_a = player.getPlugin("fullscreen")) == null ? void 0 : _a.toggleFullScreen();
14669
+ }
14670
+ });
14671
+ InnerJsBridge$1.on("EXIT_FULLSCREEN", () => {
14672
+ var _a;
14673
+ if (player == null ? void 0 : player.fullscreen) {
14674
+ (_a = player.getPlugin("fullscreen")) == null ? void 0 : _a.toggleFullScreen();
14675
+ }
14676
+ });
14677
+ };
14678
+ const existMiniWindow = () => {
14679
+ InnerJsBridge$1 && (InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativeCloseMiniWindow());
14680
+ };
14681
+ const getVideoSizeWithRetry = (player, isPortrait) => {
14682
+ const retryGetVideoSize = (retryCount = 0) => {
14683
+ return new Promise((resolve) => {
14684
+ let { videoWidth, videoHeight } = player.video;
14685
+ if (videoWidth > 0 && videoHeight > 0) {
14686
+ resolve({ videoWidth, videoHeight });
14687
+ return;
14688
+ }
14689
+ if (retryCount < 15) {
14690
+ setTimeout(() => {
14691
+ retryGetVideoSize(retryCount + 1).then(resolve);
14692
+ }, 500);
14693
+ return;
14694
+ }
14695
+ if (isPortrait) {
14696
+ videoWidth = 1080;
14697
+ videoHeight = 1920;
14698
+ } else {
14699
+ videoWidth = 1920;
14700
+ videoHeight = 1080;
14701
+ }
14702
+ resolve({ videoWidth, videoHeight });
14703
+ });
14704
+ };
14705
+ return retryGetVideoSize();
14706
+ };
14340
14707
  const { POSITIONS: XGPosition } = Plugin;
14341
14708
  const POSITIONS$1 = {
14342
14709
  ...XGPosition,
@@ -14451,6 +14818,7 @@ class VePlayerBase {
14451
14818
  this.emit(Events$2.PLAYER_CREATE_FINISH, this._player);
14452
14819
  this._errorCallback = (err) => this._handleFallback(err);
14453
14820
  this._player.on(ERROR, this._errorCallback);
14821
+ bindPlayerEventsCallJSB(this._player);
14454
14822
  }
14455
14823
  /** {zh}
14456
14824
  * @brief 获取视频的就绪状态,其状态枚举值、枚举名称和说明如下:
@@ -14616,7 +14984,7 @@ class VePlayerBase {
14616
14984
  * @brief Retrieve the player SDK version number.
14617
14985
  */
14618
14986
  get playerVersion() {
14619
- return "2.11.2";
14987
+ return "2.12.0-rc.0";
14620
14988
  }
14621
14989
  /** {zh}
14622
14990
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -15121,6 +15489,7 @@ class VePlayerBase {
15121
15489
  */
15122
15490
  destroy() {
15123
15491
  var _a;
15492
+ destroyPlayerEventsCallJSB();
15124
15493
  this._player.off(ERROR, this._errorCallback);
15125
15494
  this._player.destroy();
15126
15495
  (_a = this._customMedia) == null ? void 0 : _a.destroy();
@@ -56476,7 +56845,7 @@ let Logger$1 = class Logger2 extends Plugin {
56476
56845
  device_id: deviceId,
56477
56846
  error_report_stop: true,
56478
56847
  ext: {
56479
- veplayer_version: "2.11.2",
56848
+ veplayer_version: "2.12.0-rc.0",
56480
56849
  flv_version: "3.0.23-rc.6",
56481
56850
  hls_version: "3.0.21-rc.21",
56482
56851
  rts_version: "0.2.1-alpha.57"
@@ -74181,7 +74550,7 @@ async function prepare(options) {
74181
74550
  }
74182
74551
  await ((_a = liveVeStrategy.veStrategyManager) == null ? void 0 : _a.init({
74183
74552
  ...options,
74184
- playerVersion: "2.11.2",
74553
+ playerVersion: "2.12.0-rc.0",
74185
74554
  type: "LIVE"
74186
74555
  }));
74187
74556
  return liveVeStrategy.veStrategyManager;
@@ -659,6 +659,22 @@
659
659
  .xgplayer-pc.xgplayer-is-error .xgplayer-start {
660
660
  display: none;
661
661
  }
662
+ .xgplayer-mobile.xgplayer-mobile-mini-window video,
663
+ .xgplayer-mobile.xgplayer-mobile-mini-window xg-video {
664
+ position: fixed;
665
+ top: 0;
666
+ left: 0;
667
+ z-index: 9999;
668
+ /* stylelint-disable-next-line declaration-no-important */
669
+ width: 100vw !important;
670
+ /* stylelint-disable-next-line declaration-no-important */
671
+ height: 100vh !important;
672
+ }
673
+ .xgplayer-mobile.xgplayer-mobile-mini-window .xgplayer-start {
674
+ position: fixed;
675
+ /* stylelint-disable-next-line declaration-no-important */
676
+ z-index: 10000 !important;
677
+ }
662
678
  .xgplayer-mobile .xgplayer-progress .xgplayer-progress-played {
663
679
  background: #3469ff;
664
680
  }
@@ -701,15 +717,15 @@
701
717
  display: none;
702
718
  }
703
719
  .veplayer-logo {
704
- display: none;
705
720
  position: absolute;
706
- visibility: visible;
721
+ top: 20px;
722
+ right: 20px;
723
+ z-index: 10;
724
+ display: none;
707
725
  width: 70px;
708
726
  height: 20px;
709
- right: 20px;
710
- top: 20px;
727
+ visibility: visible;
711
728
  opacity: 1;
712
- z-index: 10;
713
729
  }
714
730
  .veplayer-logo svg {
715
731
  width: 100%;