@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%;
@@ -14341,6 +14341,373 @@ var __publicField = (obj, key, value) => {
14341
14341
  replaceAttributes(this._el, this._videoAttributes);
14342
14342
  }
14343
14343
  }
14344
+ var Web2NativeMessageEvent = /* @__PURE__ */ ((Web2NativeMessageEvent2) => {
14345
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["INIT_FINISH"] = 10001] = "INIT_FINISH";
14346
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["CREATE_PLAYER"] = 11e3] = "CREATE_PLAYER";
14347
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["DESTROY_PLAYER"] = 11001] = "DESTROY_PLAYER";
14348
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["OPEN_FULLSCREEN"] = 11002] = "OPEN_FULLSCREEN";
14349
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["EXIT_FULLSCREEN"] = 11003] = "EXIT_FULLSCREEN";
14350
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["LIVE_ROOM_STATE_CHANGE"] = 11004] = "LIVE_ROOM_STATE_CHANGE";
14351
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["PLAYER_STATE_CHANGE"] = 11005] = "PLAYER_STATE_CHANGE";
14352
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["MEDIA_LOAD_FINISH"] = 11006] = "MEDIA_LOAD_FINISH";
14353
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["OPEN_MINI_WINDOW"] = 11007] = "OPEN_MINI_WINDOW";
14354
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["CLOSE_MINI_WINDOW"] = 11008] = "CLOSE_MINI_WINDOW";
14355
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["OPEN_WAKE_LOCK"] = 11009] = "OPEN_WAKE_LOCK";
14356
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["EXIT_WAKE_LOCK"] = 110010] = "EXIT_WAKE_LOCK";
14357
+ Web2NativeMessageEvent2[Web2NativeMessageEvent2["PUSH_WEB_DATA_INFO"] = 110011] = "PUSH_WEB_DATA_INFO";
14358
+ return Web2NativeMessageEvent2;
14359
+ })(Web2NativeMessageEvent || {});
14360
+ var Native2WebMessageEvent = /* @__PURE__ */ ((Native2WebMessageEvent2) => {
14361
+ Native2WebMessageEvent2[Native2WebMessageEvent2["ENTER_MINI_WINDOW"] = 21e3] = "ENTER_MINI_WINDOW";
14362
+ Native2WebMessageEvent2[Native2WebMessageEvent2["EXIT_MINI_WINDOW"] = 21001] = "EXIT_MINI_WINDOW";
14363
+ Native2WebMessageEvent2[Native2WebMessageEvent2["PAUSE"] = 21002] = "PAUSE";
14364
+ Native2WebMessageEvent2[Native2WebMessageEvent2["START_PLAY"] = 21003] = "START_PLAY";
14365
+ Native2WebMessageEvent2[Native2WebMessageEvent2["PLAY"] = 21004] = "PLAY";
14366
+ Native2WebMessageEvent2[Native2WebMessageEvent2["WEBVIEW_CONFIG"] = 21005] = "WEBVIEW_CONFIG";
14367
+ Native2WebMessageEvent2[Native2WebMessageEvent2["GET_WEB_DATA_INFO"] = 21006] = "GET_WEB_DATA_INFO";
14368
+ Native2WebMessageEvent2[Native2WebMessageEvent2["ENTER_FULLSCREEN"] = 21007] = "ENTER_FULLSCREEN";
14369
+ Native2WebMessageEvent2[Native2WebMessageEvent2["EXIT_FULLSCREEN"] = 21008] = "EXIT_FULLSCREEN";
14370
+ return Native2WebMessageEvent2;
14371
+ })(Native2WebMessageEvent || {});
14372
+ class ByteLiveJsBridge {
14373
+ constructor(data2) {
14374
+ __publicField(this, "_emitter", new EventEmitter$1());
14375
+ __publicField(this, "isInIOS", false);
14376
+ __publicField(this, "jsBridgeName", "ByteLiveJsBridge");
14377
+ __publicField(this, "jsBridge", null);
14378
+ __publicField(this, "data", {
14379
+ room: {},
14380
+ player: {}
14381
+ });
14382
+ // eslint-disable-next-line @typescript-eslint/member-ordering
14383
+ __publicField(this, "nativeConfig", {});
14384
+ if (data2 == null ? void 0 : data2.name) {
14385
+ this.jsBridgeName = data2.name;
14386
+ }
14387
+ this.init();
14388
+ }
14389
+ init() {
14390
+ this.initVariables();
14391
+ if (!this.jsBridge) {
14392
+ this.mountGlobal();
14393
+ }
14394
+ this.callToNative(Web2NativeMessageEvent.INIT_FINISH, {});
14395
+ }
14396
+ getJsBridge() {
14397
+ const jsBridge = Reflect.get(window, this.jsBridgeName);
14398
+ if (jsBridge) {
14399
+ this.jsBridge = jsBridge;
14400
+ }
14401
+ return this.jsBridge;
14402
+ }
14403
+ setJsBridge(jsBridge) {
14404
+ Reflect.set(window, this.jsBridgeName, jsBridge);
14405
+ Reflect.set(window, "VeCloudJsBridge", jsBridge);
14406
+ console.log("设置到 window 上");
14407
+ this.jsBridge = jsBridge;
14408
+ }
14409
+ initVariables() {
14410
+ this.isInIOS = Boolean(sniffer$1.os.isIos);
14411
+ }
14412
+ mountGlobal() {
14413
+ const JsBridge = this.getJsBridge();
14414
+ console.log("从 window 上获取到的 jsBridge", JsBridge);
14415
+ if (JsBridge) {
14416
+ JsBridge.nativeCallBack = (data2) => {
14417
+ console.log("收到native发来消息", data2);
14418
+ this.handelEventCallBack(data2);
14419
+ };
14420
+ this.jsBridge = JsBridge;
14421
+ } else {
14422
+ const JsBridge2 = {
14423
+ nativeCallBack: (data2) => {
14424
+ console.log("收到native发来消息", data2);
14425
+ this.handelEventCallBack(data2);
14426
+ }
14427
+ // invokeNative: (data: IMessage) => {
14428
+ // console.log('发送给native', data);
14429
+ // },
14430
+ };
14431
+ this.setJsBridge(JsBridge2);
14432
+ }
14433
+ this.bindWebDataInfo();
14434
+ this.bindGetNativeConfig();
14435
+ }
14436
+ on(action, func) {
14437
+ this._emitter.on(action, func);
14438
+ }
14439
+ handelEventCallBack(data2) {
14440
+ const { eventKey, info } = data2 ?? {};
14441
+ if (!eventKey || !Native2WebMessageEvent[eventKey]) {
14442
+ console.log("Native2Web未匹配到对应事件", eventKey);
14443
+ return;
14444
+ }
14445
+ this._emitter.emit(Native2WebMessageEvent[eventKey], info);
14446
+ }
14447
+ invokeNative(data2) {
14448
+ var _a, _b, _c;
14449
+ console.log("发送给native", data2);
14450
+ if (this.isInIOS) {
14451
+ (_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);
14452
+ }
14453
+ const JsBridge = this.jsBridge || Reflect.get(window, this.jsBridgeName);
14454
+ console.log(
14455
+ "JsBridge",
14456
+ this.jsBridge,
14457
+ Reflect.get(window, this.jsBridgeName)
14458
+ );
14459
+ if (JsBridge.invokeNative) {
14460
+ JsBridge.invokeNative(JSON.stringify(data2));
14461
+ } else {
14462
+ console.log("未找到对应invokeNative方法");
14463
+ }
14464
+ }
14465
+ bindWebDataInfo() {
14466
+ this.on("GET_WEB_DATA_INFO", () => {
14467
+ this.callToNative(Web2NativeMessageEvent.PUSH_WEB_DATA_INFO, {
14468
+ ...this.data
14469
+ });
14470
+ });
14471
+ }
14472
+ bindGetNativeConfig() {
14473
+ this.on("WEBVIEW_CONFIG", (data2) => {
14474
+ this.nativeConfig = {
14475
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14476
+ // @ts-ignore
14477
+ ...this.nativeConfig,
14478
+ ...data2
14479
+ };
14480
+ });
14481
+ }
14482
+ callToNative(eventKey, info) {
14483
+ if (!eventKey || !Web2NativeMessageEvent[eventKey]) {
14484
+ console.log("Web2Native未匹配到对应事件", eventKey);
14485
+ return;
14486
+ }
14487
+ this.invokeNative({ eventKey, info });
14488
+ }
14489
+ callToNativeCreatePlayer(data2) {
14490
+ this.data.room = {
14491
+ ...this.data.room,
14492
+ isPortrait: data2.isPortrait
14493
+ };
14494
+ this.callToNative(Web2NativeMessageEvent.CREATE_PLAYER, data2);
14495
+ }
14496
+ callToNativeDestroyPlayer() {
14497
+ this.callToNative(Web2NativeMessageEvent.DESTROY_PLAYER, {});
14498
+ }
14499
+ callToNativeOpenFullScreen() {
14500
+ this.data.player = {
14501
+ ...this.data.player,
14502
+ fullscreen: true
14503
+ };
14504
+ this.callToNative(Web2NativeMessageEvent.OPEN_FULLSCREEN, {});
14505
+ }
14506
+ callToNativeExitFullScreen() {
14507
+ this.data.player = {
14508
+ ...this.data.player,
14509
+ fullscreen: false
14510
+ };
14511
+ this.callToNative(Web2NativeMessageEvent.EXIT_FULLSCREEN, {});
14512
+ }
14513
+ callToNativeLiveRoomStateChange(data2) {
14514
+ this.data.room = {
14515
+ ...this.data.room,
14516
+ status: data2.status
14517
+ };
14518
+ this.callToNative(Web2NativeMessageEvent.LIVE_ROOM_STATE_CHANGE, data2);
14519
+ }
14520
+ callToNativePlayerStateChange(data2) {
14521
+ this.data.player = {
14522
+ ...this.data.player,
14523
+ created: data2.created,
14524
+ paused: data2.paused
14525
+ };
14526
+ this.callToNative(Web2NativeMessageEvent.PLAYER_STATE_CHANGE, data2);
14527
+ }
14528
+ callToNativeMediaLoadFinish(data2) {
14529
+ this.data.player = {
14530
+ ...this.data.player,
14531
+ videoWidth: data2.videoWidth,
14532
+ videoHeight: data2.videoHeight
14533
+ };
14534
+ this.callToNative(Web2NativeMessageEvent.MEDIA_LOAD_FINISH, data2);
14535
+ }
14536
+ callToNativeOpenMiniWindow() {
14537
+ this.data.player = {
14538
+ ...this.data.player,
14539
+ mini: true
14540
+ };
14541
+ this.callToNative(Web2NativeMessageEvent.OPEN_MINI_WINDOW, {});
14542
+ }
14543
+ callToNativeCloseMiniWindow() {
14544
+ this.data.player = {
14545
+ ...this.data.player,
14546
+ mini: false
14547
+ };
14548
+ console.log("通知Native关闭小窗", /* @__PURE__ */ new Date());
14549
+ this.callToNative(Web2NativeMessageEvent.CLOSE_MINI_WINDOW, {});
14550
+ }
14551
+ callToNativeOpenWakeLock() {
14552
+ this.callToNative(Web2NativeMessageEvent.OPEN_WAKE_LOCK, {});
14553
+ }
14554
+ callToNativeExitWakeLock() {
14555
+ this.callToNative(Web2NativeMessageEvent.EXIT_WAKE_LOCK, {});
14556
+ }
14557
+ }
14558
+ let InnerJsBridge;
14559
+ const getJsbInstance = () => {
14560
+ if (InnerJsBridge)
14561
+ return InnerJsBridge;
14562
+ InnerJsBridge = new ByteLiveJsBridge();
14563
+ return InnerJsBridge;
14564
+ };
14565
+ var InnerJsBridge$1 = getJsbInstance();
14566
+ const bindPlayerEventsCallJSB = (player) => {
14567
+ const isPortrait = true;
14568
+ const isLive = true;
14569
+ if (!InnerJsBridge$1) {
14570
+ return;
14571
+ }
14572
+ if (!sniffer$1.os.isPc) {
14573
+ bindMiniWindowEvents(player);
14574
+ }
14575
+ InnerJsBridge$1.callToNativeCreatePlayer({
14576
+ isLive,
14577
+ isPortrait
14578
+ });
14579
+ InnerJsBridge$1.callToNativePlayerStateChange({
14580
+ created: true,
14581
+ paused: false
14582
+ });
14583
+ player.on(Events$2.PLAY, () => {
14584
+ InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativePlayerStateChange({
14585
+ created: true,
14586
+ paused: false
14587
+ });
14588
+ });
14589
+ player.on(Events$2.PAUSE, () => {
14590
+ InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativePlayerStateChange({
14591
+ created: true,
14592
+ paused: true
14593
+ });
14594
+ });
14595
+ player.on(Events$2.ERROR, () => {
14596
+ existMiniWindow();
14597
+ });
14598
+ player.on(Events$2.LOADED_DATA, () => {
14599
+ getVideoSizeWithRetry(player, isPortrait).then(
14600
+ ({ videoWidth, videoHeight }) => {
14601
+ InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativeMediaLoadFinish({
14602
+ isPortrait: videoHeight > videoWidth,
14603
+ videoWidth,
14604
+ videoHeight
14605
+ });
14606
+ }
14607
+ );
14608
+ });
14609
+ };
14610
+ const destroyPlayerEventsCallJSB = () => {
14611
+ if (InnerJsBridge$1) {
14612
+ InnerJsBridge$1.callToNativeDestroyPlayer();
14613
+ InnerJsBridge$1.callToNativePlayerStateChange({
14614
+ created: false,
14615
+ paused: true
14616
+ });
14617
+ }
14618
+ existMiniWindow();
14619
+ };
14620
+ const bindMiniWindowEvents = (player) => {
14621
+ if (!InnerJsBridge$1) {
14622
+ return;
14623
+ }
14624
+ const handleMiniWindowChange = (state) => {
14625
+ if (!player || !player.root) {
14626
+ return;
14627
+ }
14628
+ if (state) {
14629
+ player.addClass("xgplayer-mobile-mini-window");
14630
+ } else {
14631
+ player.removeClass("xgplayer-mobile-mini-window");
14632
+ }
14633
+ };
14634
+ InnerJsBridge$1.on("WEBVIEW_CONFIG", (data2) => {
14635
+ console.log("WEBVIEW_CONFIG", data2);
14636
+ if (data2 == null ? void 0 : data2.keepPlayWhenPageHide) {
14637
+ player.unRegisterPlugin("PageChangePlugin");
14638
+ }
14639
+ });
14640
+ InnerJsBridge$1.on("ENTER_MINI_WINDOW", () => {
14641
+ handleMiniWindowChange(true);
14642
+ });
14643
+ InnerJsBridge$1.on("EXIT_MINI_WINDOW", () => {
14644
+ console.log("切回小窗播放器处于暂停: ", player.paused, /* @__PURE__ */ new Date());
14645
+ if (player.paused) {
14646
+ player.play();
14647
+ }
14648
+ handleMiniWindowChange(false);
14649
+ });
14650
+ InnerJsBridge$1.on("PAUSE", () => {
14651
+ if (!player) {
14652
+ return;
14653
+ }
14654
+ player.pause();
14655
+ });
14656
+ InnerJsBridge$1.on("START_PLAY", () => {
14657
+ handleMiniWindowChange(false);
14658
+ if (!player) {
14659
+ return;
14660
+ }
14661
+ player.play();
14662
+ });
14663
+ InnerJsBridge$1.on("PLAY", () => {
14664
+ if (!player) {
14665
+ return;
14666
+ }
14667
+ player.play();
14668
+ });
14669
+ InnerJsBridge$1.on("ENTER_FULLSCREEN", () => {
14670
+ var _a;
14671
+ if (!(player == null ? void 0 : player.fullscreen)) {
14672
+ (_a = player.getPlugin("fullscreen")) == null ? void 0 : _a.toggleFullScreen();
14673
+ }
14674
+ });
14675
+ InnerJsBridge$1.on("EXIT_FULLSCREEN", () => {
14676
+ var _a;
14677
+ if (player == null ? void 0 : player.fullscreen) {
14678
+ (_a = player.getPlugin("fullscreen")) == null ? void 0 : _a.toggleFullScreen();
14679
+ }
14680
+ });
14681
+ };
14682
+ const existMiniWindow = () => {
14683
+ InnerJsBridge$1 && (InnerJsBridge$1 == null ? void 0 : InnerJsBridge$1.callToNativeCloseMiniWindow());
14684
+ };
14685
+ const getVideoSizeWithRetry = (player, isPortrait) => {
14686
+ const retryGetVideoSize = (retryCount = 0) => {
14687
+ return new Promise((resolve) => {
14688
+ let { videoWidth, videoHeight } = player.video;
14689
+ if (videoWidth > 0 && videoHeight > 0) {
14690
+ resolve({ videoWidth, videoHeight });
14691
+ return;
14692
+ }
14693
+ if (retryCount < 15) {
14694
+ setTimeout(() => {
14695
+ retryGetVideoSize(retryCount + 1).then(resolve);
14696
+ }, 500);
14697
+ return;
14698
+ }
14699
+ if (isPortrait) {
14700
+ videoWidth = 1080;
14701
+ videoHeight = 1920;
14702
+ } else {
14703
+ videoWidth = 1920;
14704
+ videoHeight = 1080;
14705
+ }
14706
+ resolve({ videoWidth, videoHeight });
14707
+ });
14708
+ };
14709
+ return retryGetVideoSize();
14710
+ };
14344
14711
  const { POSITIONS: XGPosition } = Plugin;
14345
14712
  const POSITIONS$1 = {
14346
14713
  ...XGPosition,
@@ -14455,6 +14822,7 @@ var __publicField = (obj, key, value) => {
14455
14822
  this.emit(Events$2.PLAYER_CREATE_FINISH, this._player);
14456
14823
  this._errorCallback = (err) => this._handleFallback(err);
14457
14824
  this._player.on(ERROR, this._errorCallback);
14825
+ bindPlayerEventsCallJSB(this._player);
14458
14826
  }
14459
14827
  /** {zh}
14460
14828
  * @brief 获取视频的就绪状态,其状态枚举值、枚举名称和说明如下:
@@ -14620,7 +14988,7 @@ var __publicField = (obj, key, value) => {
14620
14988
  * @brief Retrieve the player SDK version number.
14621
14989
  */
14622
14990
  get playerVersion() {
14623
- return "2.11.2";
14991
+ return "2.12.0-rc.0";
14624
14992
  }
14625
14993
  /** {zh}
14626
14994
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -15125,6 +15493,7 @@ var __publicField = (obj, key, value) => {
15125
15493
  */
15126
15494
  destroy() {
15127
15495
  var _a;
15496
+ destroyPlayerEventsCallJSB();
15128
15497
  this._player.off(ERROR, this._errorCallback);
15129
15498
  this._player.destroy();
15130
15499
  (_a = this._customMedia) == null ? void 0 : _a.destroy();
@@ -56480,7 +56849,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
56480
56849
  device_id: deviceId,
56481
56850
  error_report_stop: true,
56482
56851
  ext: {
56483
- veplayer_version: "2.11.2",
56852
+ veplayer_version: "2.12.0-rc.0",
56484
56853
  flv_version: "3.0.23-rc.6",
56485
56854
  hls_version: "3.0.21-rc.21",
56486
56855
  rts_version: "0.2.1-alpha.57"
@@ -74185,7 +74554,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
74185
74554
  }
74186
74555
  await ((_a = liveVeStrategy.veStrategyManager) == null ? void 0 : _a.init({
74187
74556
  ...options,
74188
- playerVersion: "2.11.2",
74557
+ playerVersion: "2.12.0-rc.0",
74189
74558
  type: "LIVE"
74190
74559
  }));
74191
74560
  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%;