@tencentcloud/trtc-cloud-wx 0.0.30-beta.1 → 0.0.30-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/trtc-cloud-wx.js +88 -59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencentcloud/trtc-cloud-wx",
3
- "version": "0.0.30-beta.1",
3
+ "version": "0.0.30-beta.2",
4
4
  "description": "",
5
5
  "main": "./trtc-cloud-wx.js",
6
6
  "type": "module",
package/trtc-cloud-wx.js CHANGED
@@ -1391,7 +1391,7 @@ var Logger = /*#__PURE__*/function () {
1391
1391
  var logger = new Logger();
1392
1392
 
1393
1393
  var name = "@tencentcloud/trtc-cloud-wx";
1394
- var version = "0.0.30-beta.1";
1394
+ var version = "0.0.30-beta.2";
1395
1395
  var description = "";
1396
1396
  var main = "dist/trtc-cloud-wx.js";
1397
1397
  var module$1 = "dist/trtc-cloud-wx.js";
@@ -2634,20 +2634,49 @@ var TRTCCloud = /*#__PURE__*/function () {
2634
2634
  }, {
2635
2635
  key: "switchCamera",
2636
2636
  value: function switchCamera(frontCamera) {
2637
+ var _this12 = this;
2637
2638
  logger.info('switchCamera with options: ', frontCamera);
2638
2639
  var pusher = this.trtc.getPusherInstance();
2639
2640
  if (frontCamera === (pusher.pusherAttributes.frontCamera === 'front')) return Promise.resolve();
2640
- return new Promise(function (resolve, reject) {});
2641
+ return new Promise(function (resolve, reject) {
2642
+ wx.createLivePusherContext().switchCamera({
2643
+ success: function success(event) {
2644
+ return __awaiter(_this12, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2645
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2646
+ while (1) switch (_context26.prev = _context26.next) {
2647
+ case 0:
2648
+ _context26.next = 2;
2649
+ return this.setAttributes({
2650
+ params: {
2651
+ frontCamera: frontCamera
2652
+ }
2653
+ }, 'switchCamera');
2654
+ case 2:
2655
+ logger.info('switchCamera success');
2656
+ resolve(event);
2657
+ case 4:
2658
+ case "end":
2659
+ return _context26.stop();
2660
+ }
2661
+ }, _callee26, this);
2662
+ }));
2663
+ },
2664
+ fail: function fail(error) {
2665
+ logger.info('switchCamera fail');
2666
+ reject(error);
2667
+ }
2668
+ });
2669
+ });
2641
2670
  }
2642
2671
  }, {
2643
2672
  key: "setBeautyStyle",
2644
2673
  value: function setBeautyStyle(style, beauty, white, ruddiness) {
2645
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2646
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2647
- while (1) switch (_context26.prev = _context26.next) {
2674
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2675
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2676
+ while (1) switch (_context27.prev = _context27.next) {
2648
2677
  case 0:
2649
2678
  logger.info('setBeautyStyle with options: ', style, beauty, white, ruddiness);
2650
- _context26.next = 3;
2679
+ _context27.next = 3;
2651
2680
  return this.setAttributes({
2652
2681
  params: {
2653
2682
  beautyStyle: style,
@@ -2659,9 +2688,9 @@ var TRTCCloud = /*#__PURE__*/function () {
2659
2688
  logger.info('setBeautyStyle success');
2660
2689
  case 4:
2661
2690
  case "end":
2662
- return _context26.stop();
2691
+ return _context27.stop();
2663
2692
  }
2664
- }, _callee26, this);
2693
+ }, _callee27, this);
2665
2694
  }));
2666
2695
  }
2667
2696
  }, {
@@ -2829,9 +2858,9 @@ var TRTCCloud = /*#__PURE__*/function () {
2829
2858
  }, {
2830
2859
  key: "pusherAttributesChange",
2831
2860
  value: function pusherAttributesChange(pusher) {
2832
- var _this12 = this;
2861
+ var _this13 = this;
2833
2862
  return new Promise(function (resolve) {
2834
- _this12.InterfaceEventEmitter.emit('pusherAttributesChange', {
2863
+ _this13.InterfaceEventEmitter.emit('pusherAttributesChange', {
2835
2864
  pusher: pusher,
2836
2865
  callback: function callback() {
2837
2866
  resolve(pusher);
@@ -2842,13 +2871,13 @@ var TRTCCloud = /*#__PURE__*/function () {
2842
2871
  }, {
2843
2872
  key: "playerAttributesChange",
2844
2873
  value: function playerAttributesChange(params) {
2845
- var _this13 = this;
2874
+ var _this14 = this;
2846
2875
  var streamId = params.streamId,
2847
2876
  playerAttributes = params.playerAttributes;
2848
2877
  return new Promise(function (resolve) {
2849
- _this13.InterfaceEventEmitter.emit('playerAttributesChange', {
2878
+ _this14.InterfaceEventEmitter.emit('playerAttributesChange', {
2850
2879
  streamId: streamId,
2851
- view: _this13.renderMap.get(streamId),
2880
+ view: _this14.renderMap.get(streamId),
2852
2881
  playerAttributes: playerAttributes,
2853
2882
  callback: function callback() {
2854
2883
  resolve(playerAttributes);
@@ -2859,10 +2888,10 @@ var TRTCCloud = /*#__PURE__*/function () {
2859
2888
  }, {
2860
2889
  key: "playerAudioRouteChange",
2861
2890
  value: function playerAudioRouteChange(params) {
2862
- var _this14 = this;
2891
+ var _this15 = this;
2863
2892
  var soundMode = params.soundMode;
2864
2893
  return new Promise(function (resolve) {
2865
- _this14.InterfaceEventEmitter.emit('playerAudioRouteChange', {
2894
+ _this15.InterfaceEventEmitter.emit('playerAudioRouteChange', {
2866
2895
  soundMode: soundMode,
2867
2896
  callback: function callback() {
2868
2897
  resolve(soundMode);
@@ -2873,122 +2902,122 @@ var TRTCCloud = /*#__PURE__*/function () {
2873
2902
  }, {
2874
2903
  key: "setAttributes",
2875
2904
  value: function setAttributes(options, funName, handleType) {
2876
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2877
- var _this15 = this;
2905
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2906
+ var _this16 = this;
2878
2907
  var params, streamId, handleMap, timeoutDuration, retriesNumber;
2879
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2880
- while (1) switch (_context29.prev = _context29.next) {
2908
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2909
+ while (1) switch (_context30.prev = _context30.next) {
2881
2910
  case 0:
2882
2911
  params = options.params, streamId = options.streamId;
2883
2912
  handleMap = _defineProperty(_defineProperty({}, Handletype.setPlayer, function () {
2884
- return __awaiter(_this15, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2913
+ return __awaiter(_this16, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2885
2914
  var playerAttributes;
2886
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2887
- while (1) switch (_context27.prev = _context27.next) {
2915
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2916
+ while (1) switch (_context28.prev = _context28.next) {
2888
2917
  case 0:
2889
- _context27.next = 2;
2918
+ _context28.next = 2;
2890
2919
  return this.playerAttributesChange({
2891
2920
  playerAttributes: this.setTRTCPlayerAttributes(streamId, params),
2892
2921
  streamId: streamId
2893
2922
  });
2894
2923
  case 2:
2895
- playerAttributes = _context27.sent;
2896
- return _context27.abrupt("return", playerAttributes);
2924
+ playerAttributes = _context28.sent;
2925
+ return _context28.abrupt("return", playerAttributes);
2897
2926
  case 4:
2898
2927
  case "end":
2899
- return _context27.stop();
2928
+ return _context28.stop();
2900
2929
  }
2901
- }, _callee27, this);
2930
+ }, _callee28, this);
2902
2931
  }));
2903
2932
  }), Handletype.setPusher, function () {
2904
- return __awaiter(_this15, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2933
+ return __awaiter(_this16, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2905
2934
  var _pusher, pusher;
2906
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2907
- while (1) switch (_context28.prev = _context28.next) {
2935
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2936
+ while (1) switch (_context29.prev = _context29.next) {
2908
2937
  case 0:
2909
2938
  if (!(funName === 'enterRoom')) {
2910
- _context28.next = 5;
2939
+ _context29.next = 5;
2911
2940
  break;
2912
2941
  }
2913
- _context28.next = 3;
2942
+ _context29.next = 3;
2914
2943
  return this.pusherAttributesChange(this.trtc.enterRoom(params));
2915
2944
  case 3:
2916
- _pusher = _context28.sent;
2917
- return _context28.abrupt("return", _pusher);
2945
+ _pusher = _context29.sent;
2946
+ return _context29.abrupt("return", _pusher);
2918
2947
  case 5:
2919
- _context28.next = 7;
2948
+ _context29.next = 7;
2920
2949
  return this.pusherAttributesChange(this.trtc.setPusherAttributes(params));
2921
2950
  case 7:
2922
- pusher = _context28.sent;
2923
- return _context28.abrupt("return", pusher);
2951
+ pusher = _context29.sent;
2952
+ return _context29.abrupt("return", pusher);
2924
2953
  case 9:
2925
2954
  case "end":
2926
- return _context28.stop();
2955
+ return _context29.stop();
2927
2956
  }
2928
- }, _callee28, this);
2957
+ }, _callee29, this);
2929
2958
  }));
2930
2959
  }); // 定义一个超时时间(以毫秒为单位)
2931
2960
  timeoutDuration = 2000; // 定义超时重试次数
2932
2961
  retriesNumber = 3;
2933
- return _context29.abrupt("return", this.retryWithTimeout(function () {
2962
+ return _context30.abrupt("return", this.retryWithTimeout(function () {
2934
2963
  return handleMap[handleType] ? handleMap[handleType]() : Promise.reject(Object.assign(new Error('setAttributes fail'), {
2935
2964
  errorCode: -1
2936
2965
  }));
2937
2966
  }, timeoutDuration, retriesNumber));
2938
2967
  case 5:
2939
2968
  case "end":
2940
- return _context29.stop();
2969
+ return _context30.stop();
2941
2970
  }
2942
- }, _callee29, this);
2971
+ }, _callee30, this);
2943
2972
  }));
2944
2973
  }
2945
2974
  }, {
2946
2975
  key: "retryWithTimeout",
2947
2976
  value: function retryWithTimeout(fn, timeout, retries) {
2948
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2977
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2949
2978
  var lastError, i, result;
2950
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2951
- while (1) switch (_context30.prev = _context30.next) {
2979
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2980
+ while (1) switch (_context31.prev = _context31.next) {
2952
2981
  case 0:
2953
2982
  lastError = null;
2954
2983
  i = 0;
2955
2984
  case 2:
2956
2985
  if (!(i < retries)) {
2957
- _context30.next = 19;
2986
+ _context31.next = 19;
2958
2987
  break;
2959
2988
  }
2960
- _context30.prev = 3;
2989
+ _context31.prev = 3;
2961
2990
  logger.info("setAttributes ".concat(i + 1, "st retry"));
2962
- _context30.next = 7;
2991
+ _context31.next = 7;
2963
2992
  return Promise.race([fn(), new Promise(function (resolve, reject) {
2964
2993
  return setTimeout(function () {
2965
2994
  return reject(new Error('setAttributes timed out'));
2966
2995
  }, timeout);
2967
2996
  })]);
2968
2997
  case 7:
2969
- result = _context30.sent;
2970
- return _context30.abrupt("return", result);
2998
+ result = _context31.sent;
2999
+ return _context31.abrupt("return", result);
2971
3000
  case 11:
2972
- _context30.prev = 11;
2973
- _context30.t0 = _context30["catch"](3);
2974
- if (!((_context30.t0 === null || _context30.t0 === void 0 ? void 0 : _context30.t0.errorCode) === -1)) {
2975
- _context30.next = 15;
3001
+ _context31.prev = 11;
3002
+ _context31.t0 = _context31["catch"](3);
3003
+ if (!((_context31.t0 === null || _context31.t0 === void 0 ? void 0 : _context31.t0.errorCode) === -1)) {
3004
+ _context31.next = 15;
2976
3005
  break;
2977
3006
  }
2978
- return _context30.abrupt("return", _context30.t0);
3007
+ return _context31.abrupt("return", _context31.t0);
2979
3008
  case 15:
2980
- lastError = _context30.t0;
3009
+ lastError = _context31.t0;
2981
3010
  case 16:
2982
3011
  i++;
2983
- _context30.next = 2;
3012
+ _context31.next = 2;
2984
3013
  break;
2985
3014
  case 19:
2986
3015
  throw lastError;
2987
3016
  case 20:
2988
3017
  case "end":
2989
- return _context30.stop();
3018
+ return _context31.stop();
2990
3019
  }
2991
- }, _callee30, null, [[3, 11]]);
3020
+ }, _callee31, null, [[3, 11]]);
2992
3021
  }));
2993
3022
  }
2994
3023
  }], [{