trtc-electron-sdk 13.3.801-alpha.3 → 13.3.802-beta.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.
@@ -95,6 +95,13 @@ export declare enum TRTCMediaMixingEvent {
95
95
  * @param {Number} size.height 媒体源最新高度
96
96
  */
97
97
  onMediaSourceSizeChanged = "onMediaSourceSizeChanged",
98
+ /**
99
+ * @description 本地混流服务丢失事件
100
+ * @deprecated
101
+ * @private
102
+ *
103
+ * @event TRTCMediaMixingEvent#onMediaMixingServerLost
104
+ */
98
105
  onMediaMixingServerLost = "onMediaMixingServerLost"
99
106
  }
100
107
  declare enum TRTCMediaMixingServerMode {
@@ -264,12 +271,15 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
264
271
  */
265
272
  updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
266
273
  /**
274
+ * @deprecated
275
+ *
267
276
  * 设置摄像头采集参数
268
277
  * @param cameraID {string} - 摄像头 ID
269
278
  * @param params {TRTCCameraCaptureParams} - 摄像头采集参数
270
279
  */
271
280
  setCameraCaptureParam(cameraID: string, params: TRTCCameraCaptureParams): void;
272
281
  /**
282
+ * @deprecated
273
283
  * 设置手机投屏参数
274
284
  * @private
275
285
  * @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
@@ -277,18 +287,24 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
277
287
  */
278
288
  setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
279
289
  /**
290
+ * @deprecated
291
+ *
280
292
  * 设置屏幕采集参数
281
293
  * @param screenOrWindowID {String} - 屏幕 ID 或 窗口 ID
282
294
  * @param property {TRTCScreenCaptureProperty} - 屏幕采集属性
283
295
  */
284
296
  setScreenCaptureProperty(screenOrWindowID: string, property: TRTCScreenCaptureProperty): void;
285
297
  /**
298
+ * @deprecated
299
+ *
286
300
  * 设置在线视频源播放参数
287
301
  * @param url {string} - 在线视频源 URL
288
302
  * @param param {TRTCOnlineVideoParam} - 在线视频源播放参数
289
303
  */
290
304
  setOnlineVideoParam(url: string, param: TRTCOnlineVideoParam): void;
291
305
  /**
306
+ * @deprecated
307
+ *
292
308
  * 设置视频文件播放参数
293
309
  * @param videoFilePath {string} - 视频文件路径
294
310
  * @param param {TRTCVideoFileParam} - 视频文件播放参数
@@ -458,6 +474,58 @@ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
458
474
  private onCallExperimentalAPIFinish;
459
475
  private recoverMediaMixingServer;
460
476
  private onDevicePixelRatioChange;
477
+ /**
478
+ * @private
479
+ * Apply camera capture params BEFORE native addMediaSource.
480
+ *
481
+ * Calling setCameraCaptureParam after the camera has already been added
482
+ * triggers an extra camera restart (the camera first starts with default
483
+ * params and then restarts with the new ones). To avoid this we set
484
+ * camera params up-front for the add path. For all other source types
485
+ * the corresponding setters are dispatched in the post-add callback
486
+ * (`onMediaSourceAdded` -> `_applyMediaSourceParams`).
487
+ */
488
+ private _applyCameraParamsBeforeAdd;
489
+ /**
490
+ * @private
491
+ * Apply capture params from TRTCMediaSource to the native plugin.
492
+ *
493
+ * This method is called after media source is added or updated. To avoid
494
+ * costly side-effects of native setters (e.g. setCameraCaptureParam will
495
+ * restart the camera), the setter is invoked only when params are actually
496
+ * provided AND differ from the previous value carried by `oldMediaSource`.
497
+ *
498
+ * Camera handling differs by phase:
499
+ * - Add path (oldMediaSource is undefined): camera params have been set
500
+ * before native addMediaSource via `_applyCameraParamsBeforeAdd`, so
501
+ * this method skips kCamera to avoid duplicate setter invocation.
502
+ * - Update path (oldMediaSource is provided): kCamera goes through the
503
+ * same diff check as other types and is dispatched only when changed.
504
+ *
505
+ * @param mediaSource - The new media source carrying capture params.
506
+ * @param oldMediaSource - The previous media source (omit for the add path
507
+ * where no previous params exist; in that case the
508
+ * setter is always invoked when params are present).
509
+ */
510
+ private _applyMediaSourceParams;
511
+ /**
512
+ * @private
513
+ * Shallow-but-stable equality check on capture param objects via JSON.
514
+ *
515
+ * Returns true when both sides represent the "same" params, false otherwise.
516
+ * Semantics:
517
+ * - both empty (undefined / null) → true (no change requested)
518
+ * - exactly one side empty → false (first-time apply or transition)
519
+ * - both non-empty → byte-equal after JSON.stringify
520
+ *
521
+ * Note: JSON.stringify is sensitive to key ordering. Capture param objects
522
+ * carried by `TRTCMediaSource` are constructed by the SDK via
523
+ * `JSON.parse(JSON.stringify(...))` flow, so key order is stable in
524
+ * practice; for caller-supplied literal objects with unstable key order,
525
+ * the comparison may yield a false-negative and trigger an unnecessary
526
+ * setter call.
527
+ */
528
+ private _isSameCaptureParams;
461
529
  private previewInNativeWindow;
462
530
  private previewInWebElement;
463
531
  private previewInNone;
@@ -258,6 +258,13 @@ var TRTCMediaMixingEvent;
258
258
  * @param {Number} size.height 媒体源最新高度
259
259
  */
260
260
  TRTCMediaMixingEvent["onMediaSourceSizeChanged"] = "onMediaSourceSizeChanged";
261
+ /**
262
+ * @description 本地混流服务丢失事件
263
+ * @deprecated
264
+ * @private
265
+ *
266
+ * @event TRTCMediaMixingEvent#onMediaMixingServerLost
267
+ */
261
268
  TRTCMediaMixingEvent["onMediaMixingServerLost"] = "onMediaMixingServerLost";
262
269
  })(TRTCMediaMixingEvent = exports.TRTCMediaMixingEvent || (exports.TRTCMediaMixingEvent = {}));
263
270
  const promiseKeys = {
@@ -598,6 +605,10 @@ class TRTCMediaMixingManager {
598
605
  }
599
606
  }, timeoutMs);
600
607
  this.addMediaSourceTimers.set(key, timer);
608
+ // Apply camera capture params BEFORE native addMediaSource to avoid an
609
+ // extra camera restart on first add. Other source types are handled in
610
+ // the onMediaSourceAdded callback once the C++ layer reports success.
611
+ this._applyCameraParamsBeforeAdd(newMediaSource);
601
612
  this.nodeMediaMixingPlugin.addMediaSource(newMediaSource);
602
613
  (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.addMedia({
603
614
  id: `${newMediaSource.sourceType}__${newMediaSource.sourceId}`,
@@ -620,11 +631,11 @@ class TRTCMediaMixingManager {
620
631
  getAddMediaSourceTimeoutMs(sourceType) {
621
632
  switch (sourceType) {
622
633
  case types_1.TRTCMediaSourceType.kOnlineVideo:
623
- return 15000;
634
+ return 11000;
624
635
  case types_1.TRTCMediaSourceType.kVideoFile:
625
- return 10000;
636
+ return 6000;
626
637
  default:
627
- return 8000;
638
+ return 5000;
628
639
  }
629
640
  }
630
641
  /**
@@ -701,6 +712,7 @@ class TRTCMediaMixingManager {
701
712
  }
702
713
  }
703
714
  yield this.nodeMediaMixingPlugin.updateMediaSource(newMediaSource);
715
+ this._applyMediaSourceParams(newMediaSource, this.sourceList[index]);
704
716
  (_a = this.mediaMixingDesigner) === null || _a === void 0 ? void 0 : _a.updateMedia({
705
717
  id: `${mediaSource.sourceType}__${mediaSource.sourceId}`,
706
718
  rect: mediaSource.rect,
@@ -712,6 +724,8 @@ class TRTCMediaMixingManager {
712
724
  });
713
725
  }
714
726
  /**
727
+ * @deprecated
728
+ *
715
729
  * 设置摄像头采集参数
716
730
  * @param cameraID {string} - 摄像头 ID
717
731
  * @param params {TRTCCameraCaptureParams} - 摄像头采集参数
@@ -730,6 +744,7 @@ class TRTCMediaMixingManager {
730
744
  }
731
745
  }
732
746
  /**
747
+ * @deprecated
733
748
  * 设置手机投屏参数
734
749
  * @private
735
750
  * @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
@@ -739,6 +754,8 @@ class TRTCMediaMixingManager {
739
754
  this.nodeMediaMixingPlugin.setPhoneMirrorParam(phoneMirrorSourceId, param);
740
755
  }
741
756
  /**
757
+ * @deprecated
758
+ *
742
759
  * 设置屏幕采集参数
743
760
  * @param screenOrWindowID {String} - 屏幕 ID 或 窗口 ID
744
761
  * @param property {TRTCScreenCaptureProperty} - 屏幕采集属性
@@ -747,6 +764,8 @@ class TRTCMediaMixingManager {
747
764
  this.nodeMediaMixingPlugin.setScreenCaptureProperty(screenOrWindowID, property);
748
765
  }
749
766
  /**
767
+ * @deprecated
768
+ *
750
769
  * 设置在线视频源播放参数
751
770
  * @param url {string} - 在线视频源 URL
752
771
  * @param param {TRTCOnlineVideoParam} - 在线视频源播放参数
@@ -755,6 +774,8 @@ class TRTCMediaMixingManager {
755
774
  this.nodeMediaMixingPlugin.setOnlineVideoParam(url, param);
756
775
  }
757
776
  /**
777
+ * @deprecated
778
+ *
758
779
  * 设置视频文件播放参数
759
780
  * @param videoFilePath {string} - 视频文件路径
760
781
  * @param param {TRTCVideoFileParam} - 视频文件播放参数
@@ -1294,6 +1315,13 @@ class TRTCMediaMixingManager {
1294
1315
  }
1295
1316
  let flag = false;
1296
1317
  if (data.errCode === 0) {
1318
+ const addedIndex = this.findMediaSourceIndex({
1319
+ sourceId: data.sourceId,
1320
+ sourceType: data.sourceType,
1321
+ });
1322
+ if (addedIndex !== -1) {
1323
+ this._applyMediaSourceParams(this.sourceList[addedIndex]);
1324
+ }
1297
1325
  flag = this.promiseStore.resolvePromise(promiseKey, undefined);
1298
1326
  }
1299
1327
  else {
@@ -1456,6 +1484,7 @@ class TRTCMediaMixingManager {
1456
1484
  this.setStreamLayout(this.paramsStore.streamLayout);
1457
1485
  }
1458
1486
  this.sourceList.forEach((item) => {
1487
+ this._applyCameraParamsBeforeAdd(item);
1459
1488
  this.nodeMediaMixingPlugin.addMediaSource(item);
1460
1489
  });
1461
1490
  if (((_b = this.trtcParamsStore) === null || _b === void 0 ? void 0 : _b.enterRoomParams) && ((_c = this.trtcParamsStore) === null || _c === void 0 ? void 0 : _c.enterRoomScene)) {
@@ -1497,7 +1526,108 @@ class TRTCMediaMixingManager {
1497
1526
  logger_1.default.debug(`${this.logPrefix}onDevicePixelRatioChange:`, window.devicePixelRatio);
1498
1527
  this.setDisplayRect();
1499
1528
  }
1529
+ /**
1530
+ * @private
1531
+ * Apply camera capture params BEFORE native addMediaSource.
1532
+ *
1533
+ * Calling setCameraCaptureParam after the camera has already been added
1534
+ * triggers an extra camera restart (the camera first starts with default
1535
+ * params and then restarts with the new ones). To avoid this we set
1536
+ * camera params up-front for the add path. For all other source types
1537
+ * the corresponding setters are dispatched in the post-add callback
1538
+ * (`onMediaSourceAdded` -> `_applyMediaSourceParams`).
1539
+ */
1540
+ _applyCameraParamsBeforeAdd(mediaSource) {
1541
+ if (mediaSource.sourceType === types_1.TRTCMediaSourceType.kCamera && mediaSource.camera) {
1542
+ this.setCameraCaptureParam(mediaSource.sourceId, mediaSource.camera);
1543
+ }
1544
+ }
1545
+ /**
1546
+ * @private
1547
+ * Apply capture params from TRTCMediaSource to the native plugin.
1548
+ *
1549
+ * This method is called after media source is added or updated. To avoid
1550
+ * costly side-effects of native setters (e.g. setCameraCaptureParam will
1551
+ * restart the camera), the setter is invoked only when params are actually
1552
+ * provided AND differ from the previous value carried by `oldMediaSource`.
1553
+ *
1554
+ * Camera handling differs by phase:
1555
+ * - Add path (oldMediaSource is undefined): camera params have been set
1556
+ * before native addMediaSource via `_applyCameraParamsBeforeAdd`, so
1557
+ * this method skips kCamera to avoid duplicate setter invocation.
1558
+ * - Update path (oldMediaSource is provided): kCamera goes through the
1559
+ * same diff check as other types and is dispatched only when changed.
1560
+ *
1561
+ * @param mediaSource - The new media source carrying capture params.
1562
+ * @param oldMediaSource - The previous media source (omit for the add path
1563
+ * where no previous params exist; in that case the
1564
+ * setter is always invoked when params are present).
1565
+ */
1566
+ _applyMediaSourceParams(mediaSource, oldMediaSource) {
1567
+ switch (mediaSource.sourceType) {
1568
+ case types_1.TRTCMediaSourceType.kCamera:
1569
+ // Skip kCamera on the add path to avoid an extra camera restart;
1570
+ // it has been handled by `_applyCameraParamsBeforeAdd` already.
1571
+ if (oldMediaSource && mediaSource.camera && !this._isSameCaptureParams(mediaSource.camera, oldMediaSource.camera)) {
1572
+ this.setCameraCaptureParam(mediaSource.sourceId, mediaSource.camera);
1573
+ }
1574
+ break;
1575
+ case types_1.TRTCMediaSourceType.kScreen:
1576
+ if (mediaSource.screen && !this._isSameCaptureParams(mediaSource.screen, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.screen)) {
1577
+ this.setScreenCaptureProperty(mediaSource.sourceId, mediaSource.screen);
1578
+ }
1579
+ break;
1580
+ case types_1.TRTCMediaSourceType.kOnlineVideo:
1581
+ if (mediaSource.onlineVideo && !this._isSameCaptureParams(mediaSource.onlineVideo, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.onlineVideo)) {
1582
+ this.setOnlineVideoParam(mediaSource.sourceId, mediaSource.onlineVideo);
1583
+ }
1584
+ break;
1585
+ case types_1.TRTCMediaSourceType.kVideoFile:
1586
+ if (mediaSource.localVideo && !this._isSameCaptureParams(mediaSource.localVideo, oldMediaSource === null || oldMediaSource === void 0 ? void 0 : oldMediaSource.localVideo)) {
1587
+ this.setVideoFileParam(mediaSource.sourceId, mediaSource.localVideo);
1588
+ }
1589
+ break;
1590
+ }
1591
+ }
1592
+ /**
1593
+ * @private
1594
+ * Shallow-but-stable equality check on capture param objects via JSON.
1595
+ *
1596
+ * Returns true when both sides represent the "same" params, false otherwise.
1597
+ * Semantics:
1598
+ * - both empty (undefined / null) → true (no change requested)
1599
+ * - exactly one side empty → false (first-time apply or transition)
1600
+ * - both non-empty → byte-equal after JSON.stringify
1601
+ *
1602
+ * Note: JSON.stringify is sensitive to key ordering. Capture param objects
1603
+ * carried by `TRTCMediaSource` are constructed by the SDK via
1604
+ * `JSON.parse(JSON.stringify(...))` flow, so key order is stable in
1605
+ * practice; for caller-supplied literal objects with unstable key order,
1606
+ * the comparison may yield a false-negative and trigger an unnecessary
1607
+ * setter call.
1608
+ */
1609
+ _isSameCaptureParams(next, prev) {
1610
+ if (next === prev) {
1611
+ return true;
1612
+ }
1613
+ const nextEmpty = next === undefined || next === null;
1614
+ const prevEmpty = prev === undefined || prev === null;
1615
+ if (nextEmpty && prevEmpty) {
1616
+ return true;
1617
+ }
1618
+ if (nextEmpty || prevEmpty) {
1619
+ return false;
1620
+ }
1621
+ try {
1622
+ return JSON.stringify(next) === JSON.stringify(prev);
1623
+ }
1624
+ catch (err) {
1625
+ logger_1.default.warn(`${this.logPrefix}_isSameCaptureParams: stringify failed, treat as different.`, err);
1626
+ return false;
1627
+ }
1628
+ }
1500
1629
  previewInNativeWindow(viewOrRegion) {
1630
+ var _a;
1501
1631
  return __awaiter(this, void 0, void 0, function* () {
1502
1632
  if (this.serverMode === TRTCMediaMixingServerMode.Embedded && (this.serverStatus === TRTCMediaMixingServerStatus.Started || this.serverStatus === TRTCMediaMixingServerStatus.Starting)) {
1503
1633
  try {
@@ -1530,9 +1660,15 @@ class TRTCMediaMixingManager {
1530
1660
  this.destroyDesigner();
1531
1661
  this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, viewOrRegion);
1532
1662
  }
1663
+ if (!((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout)) {
1664
+ this.setStreamLayout({
1665
+ layoutMode: types_1.TRTCStreamLayoutMode.None,
1666
+ });
1667
+ }
1533
1668
  });
1534
1669
  }
1535
1670
  previewInWebElement(viewOrRegion) {
1671
+ var _a;
1536
1672
  return __awaiter(this, void 0, void 0, function* () {
1537
1673
  if (this.serverMode === TRTCMediaMixingServerMode.Independent && (this.serverStatus === TRTCMediaMixingServerStatus.Started || this.serverStatus === TRTCMediaMixingServerStatus.Starting)) {
1538
1674
  try {
@@ -1559,6 +1695,11 @@ class TRTCMediaMixingManager {
1559
1695
  this.createDesigner();
1560
1696
  }
1561
1697
  }
1698
+ if (!((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout)) {
1699
+ this.setStreamLayout({
1700
+ layoutMode: types_1.TRTCStreamLayoutMode.None,
1701
+ });
1702
+ }
1562
1703
  }
1563
1704
  else {
1564
1705
  // neither native window nor web element, stop preview
@@ -1567,12 +1708,16 @@ class TRTCMediaMixingManager {
1567
1708
  });
1568
1709
  }
1569
1710
  previewInNone() {
1711
+ var _a;
1570
1712
  this.destroyResizeObserver();
1571
1713
  this.destroyLayoutManager();
1572
1714
  this.destroyDesigner();
1573
1715
  this.destroyWebRenderer();
1574
1716
  this.view = null;
1575
1717
  this.nodeMediaMixingPlugin.setDisplayParams(this.windowID, { left: 0, right: 0, top: 0, bottom: 0 });
1718
+ if ((_a = this.paramsStore) === null || _a === void 0 ? void 0 : _a.streamLayout) {
1719
+ this.paramsStore.streamLayout = null;
1720
+ }
1576
1721
  }
1577
1722
  createWebRenderer(view) {
1578
1723
  if (this.view === view) {
@@ -39,6 +39,13 @@ export declare type TRTCPhoneMirrorParam = {
39
39
  frameRate: number;
40
40
  bitrateKbps: number;
41
41
  };
42
+ export declare type TRTCOnlineVideoParam = {
43
+ networkCacheSizeKB: number;
44
+ playoutVolume: number;
45
+ };
46
+ export declare type TRTCVideoFileParam = {
47
+ playoutVolume: number;
48
+ };
42
49
  export declare type TRTCMediaSource = {
43
50
  sourceType: TRTCMediaSourceType;
44
51
  sourceId: string;
@@ -49,6 +56,10 @@ export declare type TRTCMediaSource = {
49
56
  rotation?: TRTCVideoRotation;
50
57
  fillMode?: TRTCVideoFillMode;
51
58
  mirrorType?: TRTCVideoMirrorType;
59
+ camera?: TRTCCameraCaptureParams;
60
+ screen?: TRTCScreenCaptureProperty;
61
+ localVideo?: TRTCVideoFileParam;
62
+ onlineVideo?: TRTCOnlineVideoParam;
52
63
  };
53
64
  export declare type TRTCMediaMixingEncParam = {
54
65
  videoEncoderParams: TRTCVideoEncParam;
@@ -83,20 +94,10 @@ export declare type TRTCStreamLayout = {
83
94
  };
84
95
  streams?: Array<TRTCStreamInfo>;
85
96
  };
86
- export declare type TRTCOnlineVideoParam = {
87
- networkCacheSizeKB: number;
88
- playoutVolume: number;
89
- };
90
- export declare type TRTCVideoFileParam = {
91
- playoutVolume: number;
92
- };
93
97
  export interface ITRTCMediaMixingManager {
94
98
  addMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
95
99
  removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
96
100
  updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
97
- setCameraCaptureParam(cameraID: string, param: TRTCCameraCaptureParams): void;
98
- setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
99
- setScreenCaptureProperty(screenWindowID: string, property: TRTCScreenCaptureProperty): void;
100
101
  startPublish(): Promise<void>;
101
102
  stopPublish(): Promise<void>;
102
103
  updatePublishParams(params: TRTCMediaMixingEncParam): Promise<void>;
package/liteav/trtc.d.ts CHANGED
@@ -1167,7 +1167,6 @@ declare class TRTCCloud extends EventEmitter implements ITRTCCloud {
1167
1167
  * 该接口跟 startPublishing() 类似,但 startPublishCDNStream() 支持向非腾讯云的直播 CDN 转推。
1168
1168
  *
1169
1169
  * 注意:
1170
- * - 使用 startPublishing() 绑定腾讯云直播 CDN 不收取额外的费用。
1171
1170
  * - 使用 startPublishCDNStream() 绑定非腾讯云直播 CDN 需要收取转推费用,且需要通过工单联系我们开通。
1172
1171
  *
1173
1172
  * @param {TRTCPublishCDNParam} param - 转推参数
package/liteav/trtc.js CHANGED
@@ -2097,7 +2097,6 @@ class TRTCCloud extends events_1.EventEmitter {
2097
2097
  * 该接口跟 startPublishing() 类似,但 startPublishCDNStream() 支持向非腾讯云的直播 CDN 转推。
2098
2098
  *
2099
2099
  * 注意:
2100
- * - 使用 startPublishing() 绑定腾讯云直播 CDN 不收取额外的费用。
2101
2100
  * - 使用 startPublishCDNStream() 绑定非腾讯云直播 CDN 需要收取转推费用,且需要通过工单联系我们开通。
2102
2101
  *
2103
2102
  * @param {TRTCPublishCDNParam} param - 转推参数
@@ -1125,85 +1125,3 @@ export interface TRTCInitConfig {
1125
1125
  };
1126
1126
  isIPCMode?: boolean;
1127
1127
  }
1128
- /**
1129
- * @namespace TRTCVodPlayerEvent
1130
- * @description 点播播放器(VOD Player)事件
1131
- */
1132
- export declare enum TRTCVodPlayerEvent {
1133
- /**
1134
- * @description 多媒体文件开始播放事件
1135
- *
1136
- * @event TRTCVodPlayerEvent#onVodPlayerStarted
1137
- * @param {Number} msLength 多媒体文件总长度,单位毫秒
1138
- */
1139
- onVodPlayerStarted = "onVodPlayerStarted",
1140
- /**
1141
- * @description 播放器就绪事件
1142
- *
1143
- * 调用 `preload()` 完成后触发,或 `switchSource()` 切换成功后触发。
1144
- *
1145
- * @event TRTCVodPlayerEvent#onVodPlayerLoaded
1146
- * @param {Number} durationMs 视频总时长,单位毫秒
1147
- * @param {Number} width 视频宽度(像素),纯音频文件时为 0
1148
- * @param {Number} height 视频高度(像素),纯音频文件时为 0
1149
- */
1150
- onVodPlayerLoaded = "onVodPlayerLoaded",
1151
- /**
1152
- * @description 多媒体文件播放进度改变事件
1153
- *
1154
- * @event TRTCVodPlayerEvent#onVodPlayerProgress
1155
- * @param {Number} msPos 多媒体文件当前播放进度,单位毫秒
1156
- */
1157
- onVodPlayerProgress = "onVodPlayerProgress",
1158
- /**
1159
- * @description 多媒体文件播放暂停事件
1160
- *
1161
- * @event TRTCVodPlayerEvent#onVodPlayerPaused
1162
- */
1163
- onVodPlayerPaused = "onVodPlayerPaused",
1164
- /**
1165
- * @description 多媒体文件播放恢复事件
1166
- *
1167
- * @event TRTCVodPlayerEvent#onVodPlayerResumed
1168
- */
1169
- onVodPlayerResumed = "onVodPlayerResumed",
1170
- /**
1171
- * @description 多媒体文件播放停止事件
1172
- *
1173
- * @event TRTCVodPlayerEvent#onVodPlayerStopped
1174
- * @param {Number} reason 停止原因
1175
- * - 0:用户主动停止;
1176
- * - 1:文件播放完;
1177
- * - 2:视频断流。
1178
- */
1179
- onVodPlayerStopped = "onVodPlayerStopped",
1180
- /**
1181
- * @description 多媒体文件播放出错事件
1182
- *
1183
- * @event TRTCVodPlayerEvent#onVodPlayerError
1184
- * @param {Number} error 错误码
1185
- * - -6001:未知错误;
1186
- * - -6002:通用错误;
1187
- * - -6003:解封装失败;
1188
- * - -6005:解封装超时;
1189
- * - -6006:视频解码错误;
1190
- * - -6007:音频解码错误;
1191
- * - -6009:视频渲染错误。
1192
- */
1193
- onVodPlayerError = "onVodPlayerError"
1194
- }
1195
- /**
1196
- * 点播播放器事件监听器类型定义
1197
- *
1198
- * key 为 {@link TRTCVodPlayerEvent},value 为该事件回调接收的参数元组。
1199
- * 用于在 TS 层实现事件名到回调参数的精确类型映射,避免 any 滥用。
1200
- */
1201
- export interface TRTCVodPlayerEventMap {
1202
- [TRTCVodPlayerEvent.onVodPlayerStarted]: [msLength: number];
1203
- [TRTCVodPlayerEvent.onVodPlayerLoaded]: [durationMs: number, width: number, height: number];
1204
- [TRTCVodPlayerEvent.onVodPlayerProgress]: [msPos: number];
1205
- [TRTCVodPlayerEvent.onVodPlayerPaused]: [];
1206
- [TRTCVodPlayerEvent.onVodPlayerResumed]: [];
1207
- [TRTCVodPlayerEvent.onVodPlayerStopped]: [reason: number];
1208
- [TRTCVodPlayerEvent.onVodPlayerError]: [error: number];
1209
- }
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.TRTCTranscodingConfig = exports.TRTCPluginType = exports.TRTCVoiceChangerType = exports.TRTCVoiceReverbType = exports.TRTCPublishMode = exports.TRTCAudioRecordingContent = exports.TRTCMixInputType = exports.TRTCTranscodingConfigMode = exports.TRTCMixUser = exports.Rect = exports.TRTCSpeedTestResult = exports.TRTCSpeedTestParams = exports.TRTCVolumeInfo = exports.TRTCQualityInfo = exports.TRTCNetworkQosParam = exports.TRTCRenderParams = exports.TRTCVideoEncParam = exports.TRTCParams = exports.TRTCWaterMarkSrcType = exports.TRTCVideoEncodeComplexity = exports.TRTCVideoColorSpace = exports.TRTCVideoColorRange = exports.TRTCCameraCaptureMode = exports.TRTCDeviceType = exports.TRTCDeviceState = exports.TRTCLogLevel = exports.TRTCAudioFrame = exports.TRTCVideoFrame = exports.TRTCDeviceInfo = exports.TRTCScreenCaptureProperty = exports.TRTCScreenCaptureSourceInfo = exports.TRTCImageBuffer = exports.TRTCAudioQuality = exports.TRTCScreenCaptureSourceType = exports.TRTCAudioFrameFormat = exports.TRTCVideoQosPreference = exports.TRTCQosControlMode = exports.TRTCRoleType = exports.TRTCAppScene = exports.TRTCRecordType = exports.TRTCVideoMirrorType = exports.TRTCVideoBufferType = exports.TRTCVideoPixelFormat = exports.TRTCBeautyStyle = exports.TRTCVideoRotation = exports.TRTCVideoFillMode = exports.TRTCQuality = exports.TRTCVideoStreamType = exports.TRTCVideoResolutionMode = exports.TRTCVideoResolution = void 0;
10
- exports.TRTCVodPlayerEvent = exports.VideoBufferInfo = exports.TRTCSwitchRoomParam = exports.AudioMusicParam = exports.TRTCStatistics = exports.TRTCRemoteStatistics = exports.TRTCLocalStatistics = exports.TRTCAudioEffectParam = exports.TRTCAudioRecordingParams = exports.TRTCPublishCDNParam = void 0;
10
+ exports.VideoBufferInfo = exports.TRTCSwitchRoomParam = exports.AudioMusicParam = exports.TRTCStatistics = exports.TRTCRemoteStatistics = exports.TRTCLocalStatistics = exports.TRTCAudioEffectParam = exports.TRTCAudioRecordingParams = exports.TRTCPublishCDNParam = void 0;
11
11
  const util_1 = require("./Renderer/util");
12
12
  /////////////////////////////////////////////////////////////////////////////////
13
13
  //
@@ -2032,76 +2032,3 @@ class VideoBufferInfo {
2032
2032
  }
2033
2033
  }
2034
2034
  exports.VideoBufferInfo = VideoBufferInfo;
2035
- /////////////////////////////////////////////////////////////////////////////////
2036
- //
2037
- // TRTCVodPlayer 相关类型定义
2038
- //
2039
- /////////////////////////////////////////////////////////////////////////////////
2040
- /**
2041
- * @namespace TRTCVodPlayerEvent
2042
- * @description 点播播放器(VOD Player)事件
2043
- */
2044
- var TRTCVodPlayerEvent;
2045
- (function (TRTCVodPlayerEvent) {
2046
- /**
2047
- * @description 多媒体文件开始播放事件
2048
- *
2049
- * @event TRTCVodPlayerEvent#onVodPlayerStarted
2050
- * @param {Number} msLength 多媒体文件总长度,单位毫秒
2051
- */
2052
- TRTCVodPlayerEvent["onVodPlayerStarted"] = "onVodPlayerStarted";
2053
- /**
2054
- * @description 播放器就绪事件
2055
- *
2056
- * 调用 `preload()` 完成后触发,或 `switchSource()` 切换成功后触发。
2057
- *
2058
- * @event TRTCVodPlayerEvent#onVodPlayerLoaded
2059
- * @param {Number} durationMs 视频总时长,单位毫秒
2060
- * @param {Number} width 视频宽度(像素),纯音频文件时为 0
2061
- * @param {Number} height 视频高度(像素),纯音频文件时为 0
2062
- */
2063
- TRTCVodPlayerEvent["onVodPlayerLoaded"] = "onVodPlayerLoaded";
2064
- /**
2065
- * @description 多媒体文件播放进度改变事件
2066
- *
2067
- * @event TRTCVodPlayerEvent#onVodPlayerProgress
2068
- * @param {Number} msPos 多媒体文件当前播放进度,单位毫秒
2069
- */
2070
- TRTCVodPlayerEvent["onVodPlayerProgress"] = "onVodPlayerProgress";
2071
- /**
2072
- * @description 多媒体文件播放暂停事件
2073
- *
2074
- * @event TRTCVodPlayerEvent#onVodPlayerPaused
2075
- */
2076
- TRTCVodPlayerEvent["onVodPlayerPaused"] = "onVodPlayerPaused";
2077
- /**
2078
- * @description 多媒体文件播放恢复事件
2079
- *
2080
- * @event TRTCVodPlayerEvent#onVodPlayerResumed
2081
- */
2082
- TRTCVodPlayerEvent["onVodPlayerResumed"] = "onVodPlayerResumed";
2083
- /**
2084
- * @description 多媒体文件播放停止事件
2085
- *
2086
- * @event TRTCVodPlayerEvent#onVodPlayerStopped
2087
- * @param {Number} reason 停止原因
2088
- * - 0:用户主动停止;
2089
- * - 1:文件播放完;
2090
- * - 2:视频断流。
2091
- */
2092
- TRTCVodPlayerEvent["onVodPlayerStopped"] = "onVodPlayerStopped";
2093
- /**
2094
- * @description 多媒体文件播放出错事件
2095
- *
2096
- * @event TRTCVodPlayerEvent#onVodPlayerError
2097
- * @param {Number} error 错误码
2098
- * - -6001:未知错误;
2099
- * - -6002:通用错误;
2100
- * - -6003:解封装失败;
2101
- * - -6005:解封装超时;
2102
- * - -6006:视频解码错误;
2103
- * - -6007:音频解码错误;
2104
- * - -6009:视频渲染错误。
2105
- */
2106
- TRTCVodPlayerEvent["onVodPlayerError"] = "onVodPlayerError";
2107
- })(TRTCVodPlayerEvent = exports.TRTCVodPlayerEvent || (exports.TRTCVodPlayerEvent = {}));
package/liteav/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import TRTCMediaMixingManager, { TRTCMediaMixingService } from './extensions/MediaMixingManager';
2
- import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceType, TRTCLogLevel, TRTCAudioFrame, TRTCVideoFillMode, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, TRTCPluginType, TRTCPluginInfo, TRTCVideoProcessPluginOptions, TRTCMediaEncryptDecryptPluginOptions, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo, TRTCCameraCaptureParams, TRTCImageBuffer, TRTCInitConfig, TRTCAudioParallelParams, TRTCVoiceReverbType, TRTCVoiceChangerType, TRTCMusicPlayObserver, TRTCAudioFrameCallback, TRTCAudioProcessPluginOptions, TRTCPublishTarget, TRTCStreamEncoderParam, TRTCStreamMixingConfig, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoBufferType, TRTCVodPlayerEventMap } from './trtc_define';
2
+ import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceType, TRTCLogLevel, TRTCAudioFrame, TRTCVideoFillMode, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, TRTCPluginType, TRTCPluginInfo, TRTCVideoProcessPluginOptions, TRTCMediaEncryptDecryptPluginOptions, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo, TRTCCameraCaptureParams, TRTCImageBuffer, TRTCInitConfig, TRTCAudioParallelParams, TRTCVoiceReverbType, TRTCVoiceChangerType, TRTCMusicPlayObserver, TRTCAudioFrameCallback, TRTCAudioProcessPluginOptions, TRTCPublishTarget, TRTCStreamEncoderParam, TRTCStreamMixingConfig, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoBufferType } from './trtc_define';
3
+ import { TRTCVodPlayerEventMap } from './vod_player';
3
4
  export interface TRTCVideoRenderCallback {
4
5
  onRenderVideoFrame(userId: string, streamType: TRTCVideoStreamType, frame: TRTCVideoFrame): void;
5
6
  }
@@ -1,5 +1,87 @@
1
- import { TRTCVideoRotation, TRTCVideoFillMode, TRTCVodPlayerEventMap } from './trtc_define';
1
+ import { TRTCVideoRotation, TRTCVideoFillMode } from './trtc_define';
2
2
  import { IVodPlayer } from './types';
3
+ /**
4
+ * @namespace TRTCVodPlayerEvent
5
+ * @description 点播播放器(VOD Player)事件
6
+ */
7
+ export declare enum TRTCVodPlayerEvent {
8
+ /**
9
+ * @description 多媒体文件开始播放事件
10
+ *
11
+ * @event TRTCVodPlayerEvent#onVodPlayerStarted
12
+ * @param {Number} msLength 多媒体文件总长度,单位毫秒
13
+ */
14
+ onVodPlayerStarted = "onVodPlayerStarted",
15
+ /**
16
+ * @description 播放器就绪事件
17
+ *
18
+ * 调用 `preload()` 完成后触发,或 `switchSource()` 切换成功后触发。
19
+ *
20
+ * @event TRTCVodPlayerEvent#onVodPlayerLoaded
21
+ * @param {Number} durationMs 视频总时长,单位毫秒
22
+ * @param {Number} width 视频宽度(像素),纯音频文件时为 0
23
+ * @param {Number} height 视频高度(像素),纯音频文件时为 0
24
+ */
25
+ onVodPlayerLoaded = "onVodPlayerLoaded",
26
+ /**
27
+ * @description 多媒体文件播放进度改变事件
28
+ *
29
+ * @event TRTCVodPlayerEvent#onVodPlayerProgress
30
+ * @param {Number} msPos 多媒体文件当前播放进度,单位毫秒
31
+ */
32
+ onVodPlayerProgress = "onVodPlayerProgress",
33
+ /**
34
+ * @description 多媒体文件播放暂停事件
35
+ *
36
+ * @event TRTCVodPlayerEvent#onVodPlayerPaused
37
+ */
38
+ onVodPlayerPaused = "onVodPlayerPaused",
39
+ /**
40
+ * @description 多媒体文件播放恢复事件
41
+ *
42
+ * @event TRTCVodPlayerEvent#onVodPlayerResumed
43
+ */
44
+ onVodPlayerResumed = "onVodPlayerResumed",
45
+ /**
46
+ * @description 多媒体文件播放停止事件
47
+ *
48
+ * @event TRTCVodPlayerEvent#onVodPlayerStopped
49
+ * @param {Number} reason 停止原因
50
+ * - 0:用户主动停止;
51
+ * - 1:文件播放完;
52
+ * - 2:视频断流。
53
+ */
54
+ onVodPlayerStopped = "onVodPlayerStopped",
55
+ /**
56
+ * @description 多媒体文件播放出错事件
57
+ *
58
+ * @event TRTCVodPlayerEvent#onVodPlayerError
59
+ * @param {Number} error 错误码
60
+ * - -6001:未知错误;
61
+ * - -6002:通用错误;
62
+ * - -6003:解封装失败;
63
+ * - -6005:解封装超时;
64
+ * - -6006:视频解码错误;
65
+ * - -6007:音频解码错误;
66
+ * - -6009:视频渲染错误。
67
+ */
68
+ onVodPlayerError = "onVodPlayerError"
69
+ }
70
+ /**
71
+ * 点播播放器事件监听器类型定义
72
+ *
73
+ * key 为 {@link TRTCVodPlayerEvent},value 为该事件回调接收的参数元组。
74
+ * 用于在 TS 层实现事件名到回调参数的精确类型映射,避免 any 滥用。
75
+ */
76
+ export interface TRTCVodPlayerEventMap {
77
+ [TRTCVodPlayerEvent.onVodPlayerStarted]: [msLength: number];
78
+ [TRTCVodPlayerEvent.onVodPlayerLoaded]: [durationMs: number, width: number, height: number];
79
+ [TRTCVodPlayerEvent.onVodPlayerProgress]: [msPos: number];
80
+ [TRTCVodPlayerEvent.onVodPlayerPaused]: [];
81
+ [TRTCVodPlayerEvent.onVodPlayerResumed]: [];
82
+ [TRTCVodPlayerEvent.onVodPlayerStopped]: [reason: number];
83
+ [TRTCVodPlayerEvent.onVodPlayerError]: [error: number];
84
+ }
3
85
  /**
4
86
  *
5
87
  * 腾讯云点播播放器
@@ -28,7 +110,6 @@ export declare class TRTCVodPlayer implements IVodPlayer {
28
110
  private nativeVodPlayer;
29
111
  private videoRender;
30
112
  private mediaFilePath;
31
- private isStarted;
32
113
  private isDestroyed;
33
114
  private isRenderPrepared;
34
115
  private _setBufferRetryCount;
@@ -125,8 +206,6 @@ export declare class TRTCVodPlayer implements IVodPlayer {
125
206
  * 重复调用会被忽略。
126
207
  *
127
208
  * @note 可以先调用 {@link preload} 预加载完成后再调用 start,也可以跳过 preload 直接调用 start。
128
- * @note 从 SDK 10.7 版本开始,需要通过 TXLiveBase#setLicence 设置 Licence 后方可成功播放,
129
- * 否则将播放失败(黑屏),全局仅设置一次即可。
130
209
  */
131
210
  start(): void;
132
211
  /**
@@ -154,14 +233,19 @@ export declare class TRTCVodPlayer implements IVodPlayer {
154
233
  */
155
234
  seek(msPos: number): void;
156
235
  /**
157
- * 无缝切换当前播放的媒体文件
236
+ * 切换当前播放的媒体文件
237
+ *
238
+ * 底层实现等价于 `stop + 加载新源`,**切换后是否自动播放取决于切换前的状态**:
239
+ * - 切换前在播放中:底层会自动 Started 新源,业务方无需再调 {@link start};
240
+ * - 切换前在暂停中:底层只 Loaded 新源不自动播放,业务方需在
241
+ * {@link TRTCVodPlayerEvent.onVodPlayerLoaded} 之后调 {@link start} 才会播。
158
242
  *
159
- * 在后台预加载新的媒体源,待新源就绪后无缝切换,避免切换时出现黑屏。
160
- * 切换成功后触发 {@link TRTCVodPlayerEvent.onVodPlayerLoaded} 事件,携带新文件的媒体信息。
243
+ * 切换过程中会按顺序触发:
244
+ * `onVodPlayerStopped` `onVodPlayerLoaded`(新源信息)
245
+ * `onVodPlayerStarted`(仅"切换前在播放中"路径才会有)。
161
246
  *
162
247
  * @param newMediaFile - 新的媒体文件路径或 URL
163
248
  *
164
- * @note 若当前处于暂停状态,切换后仍保持暂停并展示新文件第一帧。
165
249
  * @note 切换过程中调用 {@link stop} 会取消切换并停止当前播放。
166
250
  * @note 调用前必须先 {@link preload} 或 {@link start},否则会被忽略并打 warn 日志。
167
251
  * @note 传入空串会被忽略并打 warn 日志(C++ 层亦有同等保护)。
@@ -1,11 +1,84 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TRTCVodPlayer = void 0;
3
+ exports.TRTCVodPlayer = exports.TRTCVodPlayerEvent = void 0;
4
4
  const events_1 = require("events");
5
5
  const trtc_define_1 = require("./trtc_define");
6
6
  const video_render_1 = require("./Live/video-render");
7
7
  const logger_1 = require("./logger");
8
8
  const NodeTRTCEngine = require('../build/Release/trtc_electron_sdk.node');
9
+ /////////////////////////////////////////////////////////////////////////////////
10
+ //
11
+ // TRTCVodPlayer 相关类型定义
12
+ //
13
+ /////////////////////////////////////////////////////////////////////////////////
14
+ /**
15
+ * @namespace TRTCVodPlayerEvent
16
+ * @description 点播播放器(VOD Player)事件
17
+ */
18
+ var TRTCVodPlayerEvent;
19
+ (function (TRTCVodPlayerEvent) {
20
+ /**
21
+ * @description 多媒体文件开始播放事件
22
+ *
23
+ * @event TRTCVodPlayerEvent#onVodPlayerStarted
24
+ * @param {Number} msLength 多媒体文件总长度,单位毫秒
25
+ */
26
+ TRTCVodPlayerEvent["onVodPlayerStarted"] = "onVodPlayerStarted";
27
+ /**
28
+ * @description 播放器就绪事件
29
+ *
30
+ * 调用 `preload()` 完成后触发,或 `switchSource()` 切换成功后触发。
31
+ *
32
+ * @event TRTCVodPlayerEvent#onVodPlayerLoaded
33
+ * @param {Number} durationMs 视频总时长,单位毫秒
34
+ * @param {Number} width 视频宽度(像素),纯音频文件时为 0
35
+ * @param {Number} height 视频高度(像素),纯音频文件时为 0
36
+ */
37
+ TRTCVodPlayerEvent["onVodPlayerLoaded"] = "onVodPlayerLoaded";
38
+ /**
39
+ * @description 多媒体文件播放进度改变事件
40
+ *
41
+ * @event TRTCVodPlayerEvent#onVodPlayerProgress
42
+ * @param {Number} msPos 多媒体文件当前播放进度,单位毫秒
43
+ */
44
+ TRTCVodPlayerEvent["onVodPlayerProgress"] = "onVodPlayerProgress";
45
+ /**
46
+ * @description 多媒体文件播放暂停事件
47
+ *
48
+ * @event TRTCVodPlayerEvent#onVodPlayerPaused
49
+ */
50
+ TRTCVodPlayerEvent["onVodPlayerPaused"] = "onVodPlayerPaused";
51
+ /**
52
+ * @description 多媒体文件播放恢复事件
53
+ *
54
+ * @event TRTCVodPlayerEvent#onVodPlayerResumed
55
+ */
56
+ TRTCVodPlayerEvent["onVodPlayerResumed"] = "onVodPlayerResumed";
57
+ /**
58
+ * @description 多媒体文件播放停止事件
59
+ *
60
+ * @event TRTCVodPlayerEvent#onVodPlayerStopped
61
+ * @param {Number} reason 停止原因
62
+ * - 0:用户主动停止;
63
+ * - 1:文件播放完;
64
+ * - 2:视频断流。
65
+ */
66
+ TRTCVodPlayerEvent["onVodPlayerStopped"] = "onVodPlayerStopped";
67
+ /**
68
+ * @description 多媒体文件播放出错事件
69
+ *
70
+ * @event TRTCVodPlayerEvent#onVodPlayerError
71
+ * @param {Number} error 错误码
72
+ * - -6001:未知错误;
73
+ * - -6002:通用错误;
74
+ * - -6003:解封装失败;
75
+ * - -6005:解封装超时;
76
+ * - -6006:视频解码错误;
77
+ * - -6007:音频解码错误;
78
+ * - -6009:视频渲染错误。
79
+ */
80
+ TRTCVodPlayerEvent["onVodPlayerError"] = "onVodPlayerError";
81
+ })(TRTCVodPlayerEvent = exports.TRTCVodPlayerEvent || (exports.TRTCVodPlayerEvent = {}));
9
82
  /**
10
83
  *
11
84
  * 腾讯云点播播放器
@@ -36,7 +109,6 @@ class TRTCVodPlayer {
36
109
  this._dataRenderCallback = this._dataRenderCallback.bind(this);
37
110
  this.nativeVodPlayer = new NodeTRTCEngine.NodeVodPlayer(mediaFilePath, repeat);
38
111
  this.mediaFilePath = mediaFilePath;
39
- this.isStarted = false;
40
112
  this.isDestroyed = false;
41
113
  this.isRenderPrepared = false;
42
114
  this._setBufferRetryCount = 0;
@@ -159,10 +231,6 @@ class TRTCVodPlayer {
159
231
  this.logger.warn('preload: player already destroyed');
160
232
  return;
161
233
  }
162
- if (this.isStarted) {
163
- this.logger.warn('preload: already started, ignored');
164
- return;
165
- }
166
234
  this.logger.info(`preload mediaFile: ${this.mediaFilePath}`);
167
235
  this._prepareRender();
168
236
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.preload();
@@ -176,24 +244,18 @@ class TRTCVodPlayer {
176
244
  * 重复调用会被忽略。
177
245
  *
178
246
  * @note 可以先调用 {@link preload} 预加载完成后再调用 start,也可以跳过 preload 直接调用 start。
179
- * @note 从 SDK 10.7 版本开始,需要通过 TXLiveBase#setLicence 设置 Licence 后方可成功播放,
180
- * 否则将播放失败(黑屏),全局仅设置一次即可。
181
247
  */
182
248
  start() {
183
- var _a;
249
+ var _a, _b;
184
250
  if (this.isDestroyed) {
185
251
  this.logger.warn('start: player already destroyed');
186
252
  return;
187
253
  }
188
254
  this.logger.info(`start mediaFile: ${this.mediaFilePath}`);
189
- if (this.isStarted) {
190
- this.logger.warn('start: already started, ignored');
191
- return;
192
- }
193
255
  this._prepareRender();
194
256
  this.attachTRTC();
195
257
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.start();
196
- this.isStarted = true;
258
+ (_b = this.nativeVodPlayer) === null || _b === void 0 ? void 0 : _b.resume();
197
259
  }
198
260
  /**
199
261
  * 停止播放
@@ -205,14 +267,8 @@ class TRTCVodPlayer {
205
267
  return;
206
268
  }
207
269
  this.logger.info('stop');
208
- if (!this.isStarted && !this.isRenderPrepared) {
209
- return;
210
- }
211
- if (this.isStarted) {
212
- this.isStarted = false;
213
- (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.stop();
214
- this.detachTRTC();
215
- }
270
+ (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.stop();
271
+ this.detachTRTC();
216
272
  this._teardownRender();
217
273
  }
218
274
  /**
@@ -226,10 +282,6 @@ class TRTCVodPlayer {
226
282
  this.logger.warn('pause: player already destroyed');
227
283
  return;
228
284
  }
229
- if (!this.isStarted) {
230
- this.logger.warn('pause: player not started, ignored');
231
- return;
232
- }
233
285
  this.logger.info('pause');
234
286
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.pause();
235
287
  }
@@ -239,17 +291,14 @@ class TRTCVodPlayer {
239
291
  * @note 仅在 {@link start} 之后调用才有效;未播放时调用会被忽略并打 warn 日志。
240
292
  */
241
293
  resume() {
242
- var _a;
294
+ var _a, _b;
243
295
  if (this.isDestroyed) {
244
296
  this.logger.warn('resume: player already destroyed');
245
297
  return;
246
298
  }
247
- if (!this.isStarted) {
248
- this.logger.warn('resume: player not started, ignored');
249
- return;
250
- }
251
299
  this.logger.info('resume');
252
- (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.resume();
300
+ (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.start();
301
+ (_b = this.nativeVodPlayer) === null || _b === void 0 ? void 0 : _b.resume();
253
302
  }
254
303
  /**
255
304
  * 跳转到指定播放位置(seek)
@@ -264,7 +313,7 @@ class TRTCVodPlayer {
264
313
  this.logger.warn('seek: player already destroyed');
265
314
  return;
266
315
  }
267
- if (!this.isStarted && !this.isRenderPrepared) {
316
+ if (!this.isRenderPrepared) {
268
317
  this.logger.warn(`seek: player not preloaded or started, ignored (msPos=${msPos})`);
269
318
  return;
270
319
  }
@@ -272,14 +321,19 @@ class TRTCVodPlayer {
272
321
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.seek(msPos);
273
322
  }
274
323
  /**
275
- * 无缝切换当前播放的媒体文件
324
+ * 切换当前播放的媒体文件
276
325
  *
277
- * 在后台预加载新的媒体源,待新源就绪后无缝切换,避免切换时出现黑屏。
278
- * 切换成功后触发 {@link TRTCVodPlayerEvent.onVodPlayerLoaded} 事件,携带新文件的媒体信息。
326
+ * 底层实现等价于 `stop + 加载新源`,**切换后是否自动播放取决于切换前的状态**:
327
+ * - 切换前在播放中:底层会自动 Started 新源,业务方无需再调 {@link start}
328
+ * - 切换前在暂停中:底层只 Loaded 新源不自动播放,业务方需在
329
+ * {@link TRTCVodPlayerEvent.onVodPlayerLoaded} 之后调 {@link start} 才会播。
330
+ *
331
+ * 切换过程中会按顺序触发:
332
+ * `onVodPlayerStopped` → `onVodPlayerLoaded`(新源信息) →
333
+ * `onVodPlayerStarted`(仅"切换前在播放中"路径才会有)。
279
334
  *
280
335
  * @param newMediaFile - 新的媒体文件路径或 URL
281
336
  *
282
- * @note 若当前处于暂停状态,切换后仍保持暂停并展示新文件第一帧。
283
337
  * @note 切换过程中调用 {@link stop} 会取消切换并停止当前播放。
284
338
  * @note 调用前必须先 {@link preload} 或 {@link start},否则会被忽略并打 warn 日志。
285
339
  * @note 传入空串会被忽略并打 warn 日志(C++ 层亦有同等保护)。
@@ -294,7 +348,7 @@ class TRTCVodPlayer {
294
348
  this.logger.warn('switchSource: newMediaFile is empty, ignored');
295
349
  return;
296
350
  }
297
- if (!this.isStarted && !this.isRenderPrepared) {
351
+ if (!this.isRenderPrepared) {
298
352
  this.logger.warn(`switchSource: player not preloaded or started, ignored (newMediaFile=${newMediaFile})`);
299
353
  return;
300
354
  }
@@ -621,29 +675,30 @@ class TRTCVodPlayer {
621
675
  _initEventCallback() {
622
676
  var _a;
623
677
  (_a = this.nativeVodPlayer) === null || _a === void 0 ? void 0 : _a.setEventCallback((args) => {
624
- switch (args[0]) {
625
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerStarted:
626
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerStarted, args[1].msLength);
678
+ const event = args[0];
679
+ switch (event) {
680
+ case TRTCVodPlayerEvent.onVodPlayerStarted:
681
+ this.fire(TRTCVodPlayerEvent.onVodPlayerStarted, args[1].msLength);
627
682
  break;
628
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerLoaded: {
683
+ case TRTCVodPlayerEvent.onVodPlayerLoaded: {
629
684
  const data = args[1];
630
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerLoaded, data.durationMs, data.width, data.height);
685
+ this.fire(TRTCVodPlayerEvent.onVodPlayerLoaded, data.durationMs, data.width, data.height);
631
686
  break;
632
687
  }
633
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerProgress:
634
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerProgress, args[1].msPos);
688
+ case TRTCVodPlayerEvent.onVodPlayerProgress:
689
+ this.fire(TRTCVodPlayerEvent.onVodPlayerProgress, args[1].msPos);
635
690
  break;
636
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerPaused:
637
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerPaused);
691
+ case TRTCVodPlayerEvent.onVodPlayerPaused:
692
+ this.fire(TRTCVodPlayerEvent.onVodPlayerPaused);
638
693
  break;
639
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerResumed:
640
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerResumed);
694
+ case TRTCVodPlayerEvent.onVodPlayerResumed:
695
+ this.fire(TRTCVodPlayerEvent.onVodPlayerResumed);
641
696
  break;
642
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerStopped:
643
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerStopped, args[1].reason);
697
+ case TRTCVodPlayerEvent.onVodPlayerStopped:
698
+ this.fire(TRTCVodPlayerEvent.onVodPlayerStopped, args[1].reason);
644
699
  break;
645
- case trtc_define_1.TRTCVodPlayerEvent.onVodPlayerError:
646
- this.fire(trtc_define_1.TRTCVodPlayerEvent.onVodPlayerError, args[1].error);
700
+ case TRTCVodPlayerEvent.onVodPlayerError:
701
+ this.fire(TRTCVodPlayerEvent.onVodPlayerError, args[1].error);
647
702
  break;
648
703
  default: {
649
704
  const exhaustiveCheck = args[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "13.3.801-alpha.3",
3
+ "version": "13.3.802-beta.0",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/index.js",
6
6
  "types": "./liteav/index.d.ts",