@tencentcloud/trtc-cloud-wx 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/trtc-cloud-wx.js +70 -46
package/package.json
CHANGED
package/trtc-cloud-wx.js
CHANGED
|
@@ -1150,13 +1150,13 @@ var Logger = /*#__PURE__*/function () {
|
|
|
1150
1150
|
var logger = new Logger();
|
|
1151
1151
|
|
|
1152
1152
|
var name = "@tencentcloud/trtc-cloud-wx";
|
|
1153
|
-
var version = "0.0.
|
|
1153
|
+
var version = "0.0.19";
|
|
1154
1154
|
var description = "";
|
|
1155
1155
|
var main = "dist/trtc-cloud-wx.js";
|
|
1156
1156
|
var module$1 = "dist/trtc-cloud-wx.js";
|
|
1157
1157
|
var type = "module";
|
|
1158
1158
|
var scripts = {
|
|
1159
|
-
build: "npm run clear && rollup -c",
|
|
1159
|
+
build: "npm run clear && rollup -c && node ./build/copy_to_roomkit.js",
|
|
1160
1160
|
dev: "node ./build/chokidar.js",
|
|
1161
1161
|
clear: "node ./build/clear.js",
|
|
1162
1162
|
copy: "node ./build/copy.js",
|
|
@@ -1236,7 +1236,6 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1236
1236
|
this.userId = '';
|
|
1237
1237
|
this.isEnterRoom = false;
|
|
1238
1238
|
this.isVideoMuted = false;
|
|
1239
|
-
this.isMicMuted = false;
|
|
1240
1239
|
this.isOpenCamera = false;
|
|
1241
1240
|
this.audioVolumeEvaluation = 0;
|
|
1242
1241
|
this.allTimer = {};
|
|
@@ -1279,7 +1278,6 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1279
1278
|
this.userId = '';
|
|
1280
1279
|
this.isEnterRoom = false;
|
|
1281
1280
|
this.isVideoMuted = false;
|
|
1282
|
-
this.isMicMuted = false;
|
|
1283
1281
|
this.isOpenCamera = false;
|
|
1284
1282
|
Object.keys(this.allTimer).forEach(function (key) {
|
|
1285
1283
|
clearInterval(_this.allTimer[key]);
|
|
@@ -1296,6 +1294,9 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1296
1294
|
_this2.trtc.createPusher({});
|
|
1297
1295
|
taskMachine.send(TaskQueueEvent.SETPROCESS);
|
|
1298
1296
|
} else {
|
|
1297
|
+
if (_this2.isEnterRoom) {
|
|
1298
|
+
_this2.exitRoom();
|
|
1299
|
+
}
|
|
1299
1300
|
taskMachine.send(TaskQueueEvent.SETDONE);
|
|
1300
1301
|
}
|
|
1301
1302
|
});
|
|
@@ -1747,31 +1748,44 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1747
1748
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1748
1749
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1749
1750
|
case 0:
|
|
1750
|
-
logger.info('muteLocalVideo with options: ', mute, streamType);
|
|
1751
|
+
logger.info('muteLocalVideo called with options: ', mute, streamType);
|
|
1751
1752
|
if (this.isOpenCamera) {
|
|
1752
|
-
_context6.next =
|
|
1753
|
+
_context6.next = 4;
|
|
1753
1754
|
break;
|
|
1754
1755
|
}
|
|
1756
|
+
logger.info('muteLocalVideo early exit: isOpenCamera is false');
|
|
1755
1757
|
return _context6.abrupt("return");
|
|
1756
|
-
case
|
|
1758
|
+
case 4:
|
|
1757
1759
|
_context6.t0 = streamType;
|
|
1758
|
-
_context6.next = _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig ?
|
|
1760
|
+
_context6.next = _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig ? 7 : _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeSub ? 7 : 20;
|
|
1759
1761
|
break;
|
|
1760
|
-
case
|
|
1762
|
+
case 7:
|
|
1761
1763
|
this.isVideoMuted = mute;
|
|
1762
|
-
|
|
1764
|
+
logger.info('muteLocalVideo: isVideoMuted set to ', mute);
|
|
1765
|
+
_context6.prev = 9;
|
|
1766
|
+
_context6.next = 12;
|
|
1763
1767
|
return this.setPusherAttributes({
|
|
1764
1768
|
videoPreview: mute,
|
|
1765
1769
|
enableCamera: !mute
|
|
1766
1770
|
}, 'muteLocalVideo');
|
|
1767
|
-
case
|
|
1771
|
+
case 12:
|
|
1772
|
+
logger.info('muteLocalVideo: setPusherAttributes success');
|
|
1773
|
+
_context6.next = 18;
|
|
1774
|
+
break;
|
|
1775
|
+
case 15:
|
|
1776
|
+
_context6.prev = 15;
|
|
1777
|
+
_context6.t1 = _context6["catch"](9);
|
|
1778
|
+
logger.error('muteLocalVideo: setPusherAttributes failed with error ', _context6.t1);
|
|
1779
|
+
case 18:
|
|
1768
1780
|
logger.info('muteLocalVideo success');
|
|
1769
|
-
return _context6.abrupt("break",
|
|
1770
|
-
case
|
|
1781
|
+
return _context6.abrupt("break", 21);
|
|
1782
|
+
case 20:
|
|
1783
|
+
logger.info('muteLocalVideo: streamType not supported ', streamType);
|
|
1784
|
+
case 21:
|
|
1771
1785
|
case "end":
|
|
1772
1786
|
return _context6.stop();
|
|
1773
1787
|
}
|
|
1774
|
-
}, _callee6, this);
|
|
1788
|
+
}, _callee6, this, [[9, 15]]);
|
|
1775
1789
|
}));
|
|
1776
1790
|
}
|
|
1777
1791
|
/**
|
|
@@ -2000,7 +2014,6 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2000
2014
|
key: "startLocalAudio",
|
|
2001
2015
|
value: function startLocalAudio(quality) {
|
|
2002
2016
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2003
|
-
var _this12 = this;
|
|
2004
2017
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2005
2018
|
while (1) switch (_context9.prev = _context9.next) {
|
|
2006
2019
|
case 0:
|
|
@@ -2011,26 +2024,18 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2011
2024
|
}
|
|
2012
2025
|
throw new Error('Current role is audience, unable to access mic. Call switchRole to become a host.');
|
|
2013
2026
|
case 3:
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}
|
|
2018
|
-
throw new Error('The microphone has been muted. Please unmute it first.');
|
|
2019
|
-
case 5:
|
|
2020
|
-
_context9.next = 7;
|
|
2021
|
-
return this.setPusherAttributes(function () {
|
|
2022
|
-
return {
|
|
2023
|
-
enableMic: !_this12.isMicMuted
|
|
2024
|
-
};
|
|
2027
|
+
_context9.next = 5;
|
|
2028
|
+
return this.setPusherAttributes({
|
|
2029
|
+
enableMic: true
|
|
2025
2030
|
}, 'startLocalAudio');
|
|
2026
|
-
case
|
|
2031
|
+
case 5:
|
|
2027
2032
|
logger.info('startLocalAudio success');
|
|
2028
2033
|
this.emit('onMicDidReady');
|
|
2029
2034
|
this.emit('onUserAudioAvailable', this.userId, 1);
|
|
2030
2035
|
if (this.enterRoom) {
|
|
2031
2036
|
this.emit('onSendFirstLocalAudioFrame');
|
|
2032
2037
|
}
|
|
2033
|
-
case
|
|
2038
|
+
case 9:
|
|
2034
2039
|
case "end":
|
|
2035
2040
|
return _context9.stop();
|
|
2036
2041
|
}
|
|
@@ -2066,20 +2071,39 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2066
2071
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2067
2072
|
while (1) switch (_context11.prev = _context11.next) {
|
|
2068
2073
|
case 0:
|
|
2069
|
-
logger.info('muteLocalAudio with options: ', mute);
|
|
2070
|
-
_context11.
|
|
2074
|
+
logger.info('muteLocalAudio called with options: ', mute);
|
|
2075
|
+
_context11.prev = 1;
|
|
2076
|
+
_context11.next = 4;
|
|
2071
2077
|
return this.setPusherAttributes({
|
|
2072
|
-
|
|
2078
|
+
muted: mute
|
|
2073
2079
|
}, 'muteLocalAudio');
|
|
2074
|
-
case
|
|
2075
|
-
|
|
2076
|
-
|
|
2080
|
+
case 4:
|
|
2081
|
+
logger.info('setPusherAttributes executed successfully');
|
|
2082
|
+
_context11.next = 11;
|
|
2083
|
+
break;
|
|
2084
|
+
case 7:
|
|
2085
|
+
_context11.prev = 7;
|
|
2086
|
+
_context11.t0 = _context11["catch"](1);
|
|
2087
|
+
logger.error('Error in setPusherAttributes: ', _context11.t0);
|
|
2088
|
+
throw _context11.t0;
|
|
2089
|
+
case 11:
|
|
2090
|
+
_context11.prev = 11;
|
|
2077
2091
|
this.emit('onUserAudioAvailable', this.userId, mute === true ? 0 : 1);
|
|
2078
|
-
|
|
2092
|
+
logger.info('onUserAudioAvailable event emitted successfully');
|
|
2093
|
+
_context11.next = 20;
|
|
2094
|
+
break;
|
|
2095
|
+
case 16:
|
|
2096
|
+
_context11.prev = 16;
|
|
2097
|
+
_context11.t1 = _context11["catch"](11);
|
|
2098
|
+
logger.error('Error in emitting onUserAudioAvailable event: ', _context11.t1);
|
|
2099
|
+
throw _context11.t1;
|
|
2100
|
+
case 20:
|
|
2101
|
+
logger.info('muteLocalAudio execution finished');
|
|
2102
|
+
case 21:
|
|
2079
2103
|
case "end":
|
|
2080
2104
|
return _context11.stop();
|
|
2081
2105
|
}
|
|
2082
|
-
}, _callee11, this);
|
|
2106
|
+
}, _callee11, this, [[1, 7], [11, 16]]);
|
|
2083
2107
|
}));
|
|
2084
2108
|
}
|
|
2085
2109
|
}, {
|
|
@@ -2102,17 +2126,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2102
2126
|
}, {
|
|
2103
2127
|
key: "muteAllRemoteAudio",
|
|
2104
2128
|
value: function muteAllRemoteAudio(mute) {
|
|
2105
|
-
var
|
|
2129
|
+
var _this12 = this;
|
|
2106
2130
|
logger.info('muteAllRemoteAudio with options: ', mute);
|
|
2107
2131
|
var playerList = this.trtc.getPlayerList();
|
|
2108
2132
|
playerList.forEach(function (player) {
|
|
2109
2133
|
var streamId = player.streamID;
|
|
2110
|
-
var playerAttributes =
|
|
2134
|
+
var playerAttributes = _this12.setTRTCPlayerAttributes(streamId, {
|
|
2111
2135
|
muteAudio: mute
|
|
2112
2136
|
});
|
|
2113
|
-
|
|
2137
|
+
_this12.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
2114
2138
|
streamId: streamId,
|
|
2115
|
-
view:
|
|
2139
|
+
view: _this12.renderMap.get(streamId),
|
|
2116
2140
|
playerAttributes: playerAttributes,
|
|
2117
2141
|
callback: function callback() {
|
|
2118
2142
|
logger.info('muteAllRemoteAudio success');
|
|
@@ -2132,14 +2156,14 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2132
2156
|
}, {
|
|
2133
2157
|
key: "switchCamera",
|
|
2134
2158
|
value: function switchCamera(frontCamera) {
|
|
2135
|
-
var
|
|
2159
|
+
var _this13 = this;
|
|
2136
2160
|
logger.info('switchCamera with options: ', frontCamera);
|
|
2137
2161
|
var pusher = this.trtc.getPusherInstance();
|
|
2138
2162
|
if (frontCamera === (pusher.pusherAttributes.frontCamera === 'front')) return Promise.resolve();
|
|
2139
2163
|
return new Promise(function (resolve, reject) {
|
|
2140
2164
|
wx.createLivePusherContext().switchCamera({
|
|
2141
2165
|
success: function success(event) {
|
|
2142
|
-
return __awaiter(
|
|
2166
|
+
return __awaiter(_this13, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2143
2167
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2144
2168
|
while (1) switch (_context12.prev = _context12.next) {
|
|
2145
2169
|
case 0:
|
|
@@ -2352,7 +2376,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2352
2376
|
}, {
|
|
2353
2377
|
key: "setPusherAttributes",
|
|
2354
2378
|
value: function setPusherAttributes(params, funName) {
|
|
2355
|
-
var
|
|
2379
|
+
var _this14 = this;
|
|
2356
2380
|
// 定义一个超时时间(以毫秒为单位)
|
|
2357
2381
|
var timeoutDuration = 2000;
|
|
2358
2382
|
var timeoutPromise = new Promise(function (resolve, reject) {
|
|
@@ -2365,13 +2389,13 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2365
2389
|
var pusher = {};
|
|
2366
2390
|
switch (funName) {
|
|
2367
2391
|
case 'enterRoom':
|
|
2368
|
-
pusher =
|
|
2392
|
+
pusher = _this14.trtc.enterRoom(params);
|
|
2369
2393
|
break;
|
|
2370
2394
|
default:
|
|
2371
|
-
pusher =
|
|
2395
|
+
pusher = _this14.trtc.setPusherAttributes(params);
|
|
2372
2396
|
break;
|
|
2373
2397
|
}
|
|
2374
|
-
|
|
2398
|
+
_this14.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
2375
2399
|
pusher: pusher,
|
|
2376
2400
|
callback: function callback() {
|
|
2377
2401
|
resolve(pusher);
|