@tencentcloud/trtc-cloud-wx 0.0.16 → 0.0.18
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 +790 -303
package/trtc-cloud-wx.js
CHANGED
|
@@ -413,6 +413,57 @@ function _nonIterableSpread() {
|
|
|
413
413
|
function _nonIterableRest() {
|
|
414
414
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
415
415
|
}
|
|
416
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
417
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
418
|
+
if (!it) {
|
|
419
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
420
|
+
if (it) o = it;
|
|
421
|
+
var i = 0;
|
|
422
|
+
var F = function () {};
|
|
423
|
+
return {
|
|
424
|
+
s: F,
|
|
425
|
+
n: function () {
|
|
426
|
+
if (i >= o.length) return {
|
|
427
|
+
done: true
|
|
428
|
+
};
|
|
429
|
+
return {
|
|
430
|
+
done: false,
|
|
431
|
+
value: o[i++]
|
|
432
|
+
};
|
|
433
|
+
},
|
|
434
|
+
e: function (e) {
|
|
435
|
+
throw e;
|
|
436
|
+
},
|
|
437
|
+
f: F
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
441
|
+
}
|
|
442
|
+
var normalCompletion = true,
|
|
443
|
+
didErr = false,
|
|
444
|
+
err;
|
|
445
|
+
return {
|
|
446
|
+
s: function () {
|
|
447
|
+
it = it.call(o);
|
|
448
|
+
},
|
|
449
|
+
n: function () {
|
|
450
|
+
var step = it.next();
|
|
451
|
+
normalCompletion = step.done;
|
|
452
|
+
return step;
|
|
453
|
+
},
|
|
454
|
+
e: function (e) {
|
|
455
|
+
didErr = true;
|
|
456
|
+
err = e;
|
|
457
|
+
},
|
|
458
|
+
f: function () {
|
|
459
|
+
try {
|
|
460
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
461
|
+
} finally {
|
|
462
|
+
if (didErr) throw err;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
416
467
|
function _toPrimitive(input, hint) {
|
|
417
468
|
if (typeof input !== "object" || input === null) return input;
|
|
418
469
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -444,6 +495,13 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
444
495
|
***************************************************************************** */
|
|
445
496
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
446
497
|
|
|
498
|
+
function __decorate(decorators, target, key, desc) {
|
|
499
|
+
var c = arguments.length,
|
|
500
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
501
|
+
d;
|
|
502
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
503
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
504
|
+
}
|
|
447
505
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
448
506
|
function adopt(value) {
|
|
449
507
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -562,6 +620,284 @@ exports.TRTCBeautyStyle = void 0;
|
|
|
562
620
|
TRTCBeautyStyle[TRTCBeautyStyle["TRTCBeautyStyleNature"] = 1] = "TRTCBeautyStyleNature";
|
|
563
621
|
})(exports.TRTCBeautyStyle || (exports.TRTCBeautyStyle = {}));
|
|
564
622
|
|
|
623
|
+
var Task = /*#__PURE__*/function () {
|
|
624
|
+
function Task(optinos) {
|
|
625
|
+
_classCallCheck(this, Task);
|
|
626
|
+
var _optinos$priority = optinos.priority,
|
|
627
|
+
priority = _optinos$priority === void 0 ? 0 : _optinos$priority,
|
|
628
|
+
action = optinos.action,
|
|
629
|
+
args = optinos.args,
|
|
630
|
+
resolve = optinos.resolve,
|
|
631
|
+
reject = optinos.reject,
|
|
632
|
+
ctx = optinos.ctx,
|
|
633
|
+
name = optinos.name;
|
|
634
|
+
this.ctx = ctx;
|
|
635
|
+
this.priority = priority;
|
|
636
|
+
this.action = action;
|
|
637
|
+
this.args = args;
|
|
638
|
+
this.resolve = resolve;
|
|
639
|
+
this.reject = reject;
|
|
640
|
+
this.name = name;
|
|
641
|
+
this.single = this.whetherSingle(name);
|
|
642
|
+
this.sequenceNumber = Task.nextSequenceNumber++;
|
|
643
|
+
}
|
|
644
|
+
_createClass(Task, [{
|
|
645
|
+
key: "whetherSingle",
|
|
646
|
+
value: function whetherSingle(funName) {
|
|
647
|
+
switch (funName) {
|
|
648
|
+
case 'enterRoom':
|
|
649
|
+
return true;
|
|
650
|
+
default:
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}]);
|
|
655
|
+
return Task;
|
|
656
|
+
}();
|
|
657
|
+
Task.nextSequenceNumber = 0;
|
|
658
|
+
// 数字越高,set优先级越高
|
|
659
|
+
var TaskPriorityMap = {
|
|
660
|
+
enterRoom: 0,
|
|
661
|
+
switchRole: 1,
|
|
662
|
+
startLocalPreview: 0,
|
|
663
|
+
stopLocalPreview: 0,
|
|
664
|
+
muteLocalVideo: 1,
|
|
665
|
+
setVideoEncoderParam: 0,
|
|
666
|
+
setLocalRenderParams: 0,
|
|
667
|
+
startLocalAudio: 0,
|
|
668
|
+
stopLocalAudio: 0,
|
|
669
|
+
muteLocalAudio: 1,
|
|
670
|
+
switchCamera: 0,
|
|
671
|
+
setBeautyStyle: 0,
|
|
672
|
+
exitRoom: 9
|
|
673
|
+
};
|
|
674
|
+
var TaskQueueState;
|
|
675
|
+
(function (TaskQueueState) {
|
|
676
|
+
TaskQueueState["IDLE"] = "idle";
|
|
677
|
+
TaskQueueState["PENDING"] = "pending";
|
|
678
|
+
TaskQueueState["PROCESS"] = "process";
|
|
679
|
+
})(TaskQueueState || (TaskQueueState = {}));
|
|
680
|
+
var TaskQueueEvent;
|
|
681
|
+
(function (TaskQueueEvent) {
|
|
682
|
+
TaskQueueEvent["SET"] = "SET";
|
|
683
|
+
TaskQueueEvent["SETPROCESS"] = "SETPROCESS";
|
|
684
|
+
TaskQueueEvent["SETDONE"] = "SETDONE";
|
|
685
|
+
})(TaskQueueEvent || (TaskQueueEvent = {}));
|
|
686
|
+
var TaskMachine = /*#__PURE__*/function () {
|
|
687
|
+
function TaskMachine() {
|
|
688
|
+
_classCallCheck(this, TaskMachine);
|
|
689
|
+
this.isProcessing = false; // 添加一个标志以跟踪任务是否正在处理
|
|
690
|
+
this.pusherDomReady = false;
|
|
691
|
+
this.state = TaskQueueState.IDLE;
|
|
692
|
+
this.context = {
|
|
693
|
+
taskQueue: [],
|
|
694
|
+
debounceTimeout: null
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
_createClass(TaskMachine, [{
|
|
698
|
+
key: "setPusherDomReady",
|
|
699
|
+
value: function setPusherDomReady(isReady) {
|
|
700
|
+
this.pusherDomReady = isReady;
|
|
701
|
+
return this.pusherDomReady;
|
|
702
|
+
}
|
|
703
|
+
}, {
|
|
704
|
+
key: "send",
|
|
705
|
+
value: function send(event) {
|
|
706
|
+
switch (this.state) {
|
|
707
|
+
case TaskQueueState.IDLE:
|
|
708
|
+
if (event === TaskQueueEvent.SET) {
|
|
709
|
+
this.state = TaskQueueState.PENDING;
|
|
710
|
+
this.processTasks();
|
|
711
|
+
}
|
|
712
|
+
break;
|
|
713
|
+
case TaskQueueState.PENDING:
|
|
714
|
+
if (event === TaskQueueEvent.SETPROCESS) {
|
|
715
|
+
this.processTasks();
|
|
716
|
+
}
|
|
717
|
+
if (event === TaskQueueEvent.SETDONE) {
|
|
718
|
+
this.state = TaskQueueState.IDLE;
|
|
719
|
+
}
|
|
720
|
+
break;
|
|
721
|
+
case TaskQueueState.PROCESS:
|
|
722
|
+
if (event === TaskQueueEvent.SETDONE) {
|
|
723
|
+
this.state = TaskQueueState.IDLE;
|
|
724
|
+
}
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}, {
|
|
729
|
+
key: "addTask",
|
|
730
|
+
value: function addTask(task) {
|
|
731
|
+
this.addTaskToQueue(task);
|
|
732
|
+
if (this.state === TaskQueueState.IDLE) {
|
|
733
|
+
this.send(TaskQueueEvent.SET);
|
|
734
|
+
} else if (this.state === TaskQueueState.PENDING) {
|
|
735
|
+
this.send(TaskQueueEvent.SETPROCESS);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}, {
|
|
739
|
+
key: "addTaskToQueue",
|
|
740
|
+
value: function addTaskToQueue(task) {
|
|
741
|
+
this.context.taskQueue.push(task);
|
|
742
|
+
this.context.taskQueue.sort(function (a, b) {
|
|
743
|
+
if (a.priority !== b.priority) {
|
|
744
|
+
return a.priority - b.priority;
|
|
745
|
+
}
|
|
746
|
+
return a.sequenceNumber - b.sequenceNumber;
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}, {
|
|
750
|
+
key: "processTasks",
|
|
751
|
+
value: function processTasks() {
|
|
752
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
753
|
+
var _this = this;
|
|
754
|
+
var currentTasks, singleTasks, exceptSingleTask, _iterator, _step, _task3, args, task, sequenceTask, r, _iterator2, _step2, _task, _iterator3, _step3, _task2;
|
|
755
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
756
|
+
while (1) switch (_context.prev = _context.next) {
|
|
757
|
+
case 0:
|
|
758
|
+
if (!(this.isProcessing || !this.pusherDomReady || this.context.taskQueue.length === 0)) {
|
|
759
|
+
_context.next = 2;
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
return _context.abrupt("return");
|
|
763
|
+
case 2:
|
|
764
|
+
this.isProcessing = true;
|
|
765
|
+
this.state = TaskQueueState.PROCESS;
|
|
766
|
+
currentTasks = _toConsumableArray(this.context.taskQueue);
|
|
767
|
+
this.context.taskQueue = [];
|
|
768
|
+
singleTasks = currentTasks.filter(function (task) {
|
|
769
|
+
return task.single;
|
|
770
|
+
});
|
|
771
|
+
exceptSingleTask = currentTasks.filter(function (task) {
|
|
772
|
+
return !task.single;
|
|
773
|
+
});
|
|
774
|
+
_iterator = _createForOfIteratorHelper(singleTasks);
|
|
775
|
+
_context.prev = 9;
|
|
776
|
+
_iterator.s();
|
|
777
|
+
case 11:
|
|
778
|
+
if ((_step = _iterator.n()).done) {
|
|
779
|
+
_context.next = 24;
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
_task3 = _step.value;
|
|
783
|
+
_context.prev = 13;
|
|
784
|
+
_context.next = 16;
|
|
785
|
+
return _task3.action.call(_task3.ctx, _task3.args, _task3.name);
|
|
786
|
+
case 16:
|
|
787
|
+
_task3.result = _context.sent;
|
|
788
|
+
_context.next = 22;
|
|
789
|
+
break;
|
|
790
|
+
case 19:
|
|
791
|
+
_context.prev = 19;
|
|
792
|
+
_context.t0 = _context["catch"](13);
|
|
793
|
+
_task3.err = _context.t0;
|
|
794
|
+
case 22:
|
|
795
|
+
_context.next = 11;
|
|
796
|
+
break;
|
|
797
|
+
case 24:
|
|
798
|
+
_context.next = 29;
|
|
799
|
+
break;
|
|
800
|
+
case 26:
|
|
801
|
+
_context.prev = 26;
|
|
802
|
+
_context.t1 = _context["catch"](9);
|
|
803
|
+
_iterator.e(_context.t1);
|
|
804
|
+
case 29:
|
|
805
|
+
_context.prev = 29;
|
|
806
|
+
_iterator.f();
|
|
807
|
+
return _context.finish(29);
|
|
808
|
+
case 32:
|
|
809
|
+
args = exceptSingleTask.reduce(function (acc, cur) {
|
|
810
|
+
return Object.assign(Object.assign({}, acc), typeof cur.args === 'function' ? cur.args() : cur.args);
|
|
811
|
+
}, {});
|
|
812
|
+
task = exceptSingleTask[0];
|
|
813
|
+
sequenceTask = currentTasks.sort(function (a, b) {
|
|
814
|
+
return a.sequenceNumber - b.sequenceNumber;
|
|
815
|
+
});
|
|
816
|
+
_context.prev = 35;
|
|
817
|
+
r = null;
|
|
818
|
+
if (!task) {
|
|
819
|
+
_context.next = 41;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
_context.next = 40;
|
|
823
|
+
return task.action.call(task.ctx, args);
|
|
824
|
+
case 40:
|
|
825
|
+
r = _context.sent;
|
|
826
|
+
case 41:
|
|
827
|
+
_iterator2 = _createForOfIteratorHelper(sequenceTask);
|
|
828
|
+
try {
|
|
829
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
830
|
+
_task = _step2.value;
|
|
831
|
+
if (_task.err) {
|
|
832
|
+
_task.reject(_task.err);
|
|
833
|
+
} else {
|
|
834
|
+
_task.resolve(_task.result || r);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
} catch (err) {
|
|
838
|
+
_iterator2.e(err);
|
|
839
|
+
} finally {
|
|
840
|
+
_iterator2.f();
|
|
841
|
+
}
|
|
842
|
+
_context.next = 49;
|
|
843
|
+
break;
|
|
844
|
+
case 45:
|
|
845
|
+
_context.prev = 45;
|
|
846
|
+
_context.t2 = _context["catch"](35);
|
|
847
|
+
_iterator3 = _createForOfIteratorHelper(sequenceTask);
|
|
848
|
+
try {
|
|
849
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
850
|
+
_task2 = _step3.value;
|
|
851
|
+
_task2.reject(_context.t2);
|
|
852
|
+
}
|
|
853
|
+
} catch (err) {
|
|
854
|
+
_iterator3.e(err);
|
|
855
|
+
} finally {
|
|
856
|
+
_iterator3.f();
|
|
857
|
+
}
|
|
858
|
+
case 49:
|
|
859
|
+
this.isProcessing = false;
|
|
860
|
+
this.send(TaskQueueEvent.SETDONE);
|
|
861
|
+
if (this.context.taskQueue.length > 0) {
|
|
862
|
+
Promise.resolve().then(function () {
|
|
863
|
+
_this.processTasks();
|
|
864
|
+
})["catch"](console.error);
|
|
865
|
+
}
|
|
866
|
+
case 52:
|
|
867
|
+
case "end":
|
|
868
|
+
return _context.stop();
|
|
869
|
+
}
|
|
870
|
+
}, _callee, this, [[9, 26, 29, 32], [13, 19], [35, 45]]);
|
|
871
|
+
}));
|
|
872
|
+
}
|
|
873
|
+
}]);
|
|
874
|
+
return TaskMachine;
|
|
875
|
+
}();
|
|
876
|
+
var taskMachine = new TaskMachine();
|
|
877
|
+
var setHandle = function setHandle(target, key, descriptor) {
|
|
878
|
+
var originalMethod = descriptor.value;
|
|
879
|
+
descriptor.value = function () {
|
|
880
|
+
var _this2 = this;
|
|
881
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
882
|
+
args[_key] = arguments[_key];
|
|
883
|
+
}
|
|
884
|
+
return new Promise(function (resolve, reject) {
|
|
885
|
+
var params = args[0],
|
|
886
|
+
funName = args[1];
|
|
887
|
+
taskMachine.addTask(new Task({
|
|
888
|
+
ctx: _this2,
|
|
889
|
+
priority: TaskPriorityMap[funName] || 0,
|
|
890
|
+
action: originalMethod,
|
|
891
|
+
args: params,
|
|
892
|
+
name: funName,
|
|
893
|
+
resolve: resolve,
|
|
894
|
+
reject: reject
|
|
895
|
+
}));
|
|
896
|
+
});
|
|
897
|
+
};
|
|
898
|
+
return descriptor;
|
|
899
|
+
};
|
|
900
|
+
|
|
565
901
|
var _TRTCVideoResolutionM, _TRTCBeautyStyleMap, _TRTCVideoFillModeMap;
|
|
566
902
|
var translateTRTCAppScene = function translateTRTCAppScene(scene) {
|
|
567
903
|
switch (scene) {
|
|
@@ -814,7 +1150,7 @@ var Logger = /*#__PURE__*/function () {
|
|
|
814
1150
|
var logger = new Logger();
|
|
815
1151
|
|
|
816
1152
|
var name = "@tencentcloud/trtc-cloud-wx";
|
|
817
|
-
var version = "0.0.
|
|
1153
|
+
var version = "0.0.18";
|
|
818
1154
|
var description = "";
|
|
819
1155
|
var main = "dist/trtc-cloud-wx.js";
|
|
820
1156
|
var module$1 = "dist/trtc-cloud-wx.js";
|
|
@@ -826,7 +1162,8 @@ var scripts = {
|
|
|
826
1162
|
copy: "node ./build/copy.js",
|
|
827
1163
|
doc: "npx typedoc --tsconfig typedoc.json",
|
|
828
1164
|
"doc:watch": "typedoc --watch",
|
|
829
|
-
"doc:build": "jsdoc -c jsdoc.json"
|
|
1165
|
+
"doc:build": "jsdoc -c jsdoc.json",
|
|
1166
|
+
publish: "bash ./sdk_publish.bash"
|
|
830
1167
|
};
|
|
831
1168
|
var keywords = [
|
|
832
1169
|
];
|
|
@@ -898,7 +1235,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
898
1235
|
this.role = exports.TRTCRoleType.TRTCRoleAnchor;
|
|
899
1236
|
this.userId = '';
|
|
900
1237
|
this.isEnterRoom = false;
|
|
901
|
-
this.
|
|
1238
|
+
this.isVideoMuted = false;
|
|
1239
|
+
this.isMicMuted = false;
|
|
902
1240
|
this.isOpenCamera = false;
|
|
903
1241
|
this.audioVolumeEvaluation = 0;
|
|
904
1242
|
this.allTimer = {};
|
|
@@ -918,6 +1256,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
918
1256
|
}, {
|
|
919
1257
|
key: "destroy",
|
|
920
1258
|
value: function destroy() {
|
|
1259
|
+
this.offTRTCEvent();
|
|
921
1260
|
this.EventEmitter.removeAllListeners();
|
|
922
1261
|
this.InterfaceEventEmitter.removeAllListeners();
|
|
923
1262
|
this.trtc.exitRoom();
|
|
@@ -928,8 +1267,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
928
1267
|
this.trtc = new TRTC(this);
|
|
929
1268
|
this.trtc.setLogLevel(3);
|
|
930
1269
|
this.TRTC_EVENT = this.trtc.EVENT;
|
|
931
|
-
this.trtc.createPusher({});
|
|
932
1270
|
this.bindTRTCEvent();
|
|
1271
|
+
this.bindComponentEvent();
|
|
933
1272
|
this.handleNetworkQuality = this.getHandleNetworkQuality(2000);
|
|
934
1273
|
}
|
|
935
1274
|
}, {
|
|
@@ -939,17 +1278,32 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
939
1278
|
this.role = exports.TRTCRoleType.TRTCRoleAnchor;
|
|
940
1279
|
this.userId = '';
|
|
941
1280
|
this.isEnterRoom = false;
|
|
942
|
-
this.
|
|
1281
|
+
this.isVideoMuted = false;
|
|
1282
|
+
this.isMicMuted = false;
|
|
943
1283
|
this.isOpenCamera = false;
|
|
944
1284
|
Object.keys(this.allTimer).forEach(function (key) {
|
|
945
1285
|
clearInterval(_this.allTimer[key]);
|
|
946
1286
|
_this.allTimer[key] = null;
|
|
947
1287
|
});
|
|
948
1288
|
}
|
|
1289
|
+
}, {
|
|
1290
|
+
key: "bindComponentEvent",
|
|
1291
|
+
value: function bindComponentEvent() {
|
|
1292
|
+
var _this2 = this;
|
|
1293
|
+
this.InterfaceEventEmitter.on('pusherDomReady', function (isReady) {
|
|
1294
|
+
taskMachine.setPusherDomReady(isReady);
|
|
1295
|
+
if (isReady) {
|
|
1296
|
+
_this2.trtc.createPusher({});
|
|
1297
|
+
taskMachine.send(TaskQueueEvent.SETPROCESS);
|
|
1298
|
+
} else {
|
|
1299
|
+
taskMachine.send(TaskQueueEvent.SETDONE);
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
949
1303
|
}, {
|
|
950
1304
|
key: "bindTRTCEvent",
|
|
951
1305
|
value: function bindTRTCEvent() {
|
|
952
|
-
var
|
|
1306
|
+
var _this3 = this;
|
|
953
1307
|
this.trtc.on(this.TRTC_EVENT.LOCAL_LEAVE, function (event) {
|
|
954
1308
|
// todo 第二个参数为进房耗时 此处调用start的时候处理
|
|
955
1309
|
// this.emit('onEnterRoom', 0)
|
|
@@ -958,42 +1312,42 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
958
1312
|
var _event$data = event.data,
|
|
959
1313
|
code = _event$data.code,
|
|
960
1314
|
message = _event$data.message;
|
|
961
|
-
|
|
1315
|
+
_this3.emit('onError', code, message);
|
|
962
1316
|
});
|
|
963
1317
|
this.trtc.on(this.TRTC_EVENT.REMOTE_USER_JOIN, function (event) {
|
|
964
1318
|
var userID = event.data.userID;
|
|
965
|
-
|
|
1319
|
+
_this3.emit('onRemoteUserEnterRoom', userID);
|
|
966
1320
|
});
|
|
967
1321
|
// 远端用户退出
|
|
968
1322
|
this.trtc.on(this.TRTC_EVENT.REMOTE_USER_LEAVE, function (event) {
|
|
969
1323
|
var _event$data2 = event.data,
|
|
970
1324
|
userID = _event$data2.userID;
|
|
971
1325
|
_event$data2.playerList;
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1326
|
+
_this3.InterfaceEventEmitter.emit('onRemoteUserLeaveRoom', userID, 0);
|
|
1327
|
+
_this3.emit('onUserVideoAvailable', userID, 0);
|
|
1328
|
+
_this3.emit('onUserSubStreamAvailable', userID, 0);
|
|
1329
|
+
_this3.emit('onRemoteUserLeaveRoom', userID, 0);
|
|
976
1330
|
});
|
|
977
1331
|
// 远端用户推送视频
|
|
978
1332
|
this.trtc.on(this.TRTC_EVENT.REMOTE_VIDEO_ADD, function (event) {
|
|
979
1333
|
var player = event.data.player;
|
|
980
|
-
|
|
1334
|
+
_this3.emit(player.streamType === 'aux' ? 'onUserSubStreamAvailable' : 'onUserVideoAvailable', player.userID, 1);
|
|
981
1335
|
});
|
|
982
1336
|
// 远端用户取消推送视频
|
|
983
1337
|
this.trtc.on(this.TRTC_EVENT.REMOTE_VIDEO_REMOVE, function (event) {
|
|
984
1338
|
var player = event.data.player;
|
|
985
|
-
|
|
1339
|
+
_this3.emit(player.streamType === 'aux' ? 'onUserSubStreamAvailable' : 'onUserVideoAvailable', player.userID, 0);
|
|
986
1340
|
});
|
|
987
1341
|
// 远端用户推送音频
|
|
988
1342
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_ADD, function (event) {
|
|
989
1343
|
var player = event.data.player;
|
|
990
|
-
|
|
991
|
-
|
|
1344
|
+
_this3.emit('onUserAudioAvailable', player.userID, 1);
|
|
1345
|
+
_this3.muteRemoteAudio(player.userID, false);
|
|
992
1346
|
});
|
|
993
1347
|
// 远端用户取消推送音频
|
|
994
1348
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_REMOVE, function (event) {
|
|
995
1349
|
var player = event.data.player;
|
|
996
|
-
|
|
1350
|
+
_this3.emit('onUserAudioAvailable', player.userID, 0);
|
|
997
1351
|
});
|
|
998
1352
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_VOLUME_UPDATE, function (event) {
|
|
999
1353
|
var playerList = event.data.playerList;
|
|
@@ -1003,7 +1357,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1003
1357
|
volume: player.volume
|
|
1004
1358
|
};
|
|
1005
1359
|
});
|
|
1006
|
-
|
|
1360
|
+
_this3.handleAudioVolumeUpdate(userVolumes);
|
|
1007
1361
|
});
|
|
1008
1362
|
this.trtc.on(this.TRTC_EVENT.LOCAL_AUDIO_VOLUME_UPDATE, function (event) {
|
|
1009
1363
|
var pusher = event.data.pusher;
|
|
@@ -1011,25 +1365,39 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1011
1365
|
userId: pusher.userID,
|
|
1012
1366
|
volume: pusher.volume
|
|
1013
1367
|
}];
|
|
1014
|
-
|
|
1368
|
+
_this3.handleAudioVolumeUpdate(userVolumes);
|
|
1015
1369
|
});
|
|
1016
1370
|
this.trtc.on(this.TRTC_EVENT.LOCAL_NET_STATE_UPDATE, function (event) {
|
|
1017
1371
|
var pusher = event.data.pusher;
|
|
1018
|
-
|
|
1372
|
+
_this3.handleNetworkQuality({
|
|
1019
1373
|
pusher: pusher
|
|
1020
1374
|
});
|
|
1021
1375
|
});
|
|
1022
1376
|
this.trtc.on(this.TRTC_EVENT.REMOTE_NET_STATE_UPDATE, function (event) {
|
|
1023
1377
|
var playerList = event.data.playerList;
|
|
1024
|
-
|
|
1378
|
+
_this3.handleNetworkQuality({
|
|
1025
1379
|
playerList: playerList
|
|
1026
1380
|
});
|
|
1027
1381
|
});
|
|
1028
1382
|
}
|
|
1383
|
+
}, {
|
|
1384
|
+
key: "offTRTCEvent",
|
|
1385
|
+
value: function offTRTCEvent() {
|
|
1386
|
+
this.trtc.off(this.TRTC_EVENT.LOCAL_LEAVE);
|
|
1387
|
+
this.trtc.off(this.TRTC_EVENT.ERROR);
|
|
1388
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_USER_JOIN);
|
|
1389
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_USER_LEAVE);
|
|
1390
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_VIDEO_ADD);
|
|
1391
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_VIDEO_REMOVE);
|
|
1392
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_AUDIO_ADD);
|
|
1393
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_AUDIO_REMOVE);
|
|
1394
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_AUDIO_VOLUME_UPDATE);
|
|
1395
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_NET_STATE_UPDATE);
|
|
1396
|
+
}
|
|
1029
1397
|
}, {
|
|
1030
1398
|
key: "getHandleAudioVolumeUpdate",
|
|
1031
1399
|
value: function getHandleAudioVolumeUpdate(interval) {
|
|
1032
|
-
var
|
|
1400
|
+
var _this4 = this;
|
|
1033
1401
|
var _a;
|
|
1034
1402
|
if ((_a = this.allTimer) === null || _a === void 0 ? void 0 : _a.AudioVolume) {
|
|
1035
1403
|
clearInterval(this.allTimer.AudioVolume);
|
|
@@ -1046,12 +1414,12 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1046
1414
|
this.InterfaceEventEmitter.on('onRemoteUserLeaveRoom', filterUselessItem, this.getHandleAudioVolumeUpdate);
|
|
1047
1415
|
return function (userVolumes) {
|
|
1048
1416
|
tempUserVolumes = uniqueFunc([].concat(_toConsumableArray(userVolumes), _toConsumableArray(tempUserVolumes)), 'userId');
|
|
1049
|
-
if (
|
|
1417
|
+
if (_this4.allTimer.AudioVolume) return;
|
|
1050
1418
|
var timer = setInterval(function () {
|
|
1051
|
-
|
|
1419
|
+
_this4.emit('onUserVoiceVolume', tempUserVolumes, tempUserVolumes.length, 0 // todo 此参数无用,暂时废弃
|
|
1052
1420
|
);
|
|
1053
1421
|
}, interval);
|
|
1054
|
-
|
|
1422
|
+
_this4.allTimer.AudioVolume = timer;
|
|
1055
1423
|
};
|
|
1056
1424
|
}
|
|
1057
1425
|
}, {
|
|
@@ -1060,7 +1428,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1060
1428
|
}, {
|
|
1061
1429
|
key: "getHandleNetworkQuality",
|
|
1062
1430
|
value: function getHandleNetworkQuality(interval) {
|
|
1063
|
-
var
|
|
1431
|
+
var _this5 = this;
|
|
1064
1432
|
var _a;
|
|
1065
1433
|
if ((_a = this.allTimer) === null || _a === void 0 ? void 0 : _a.networkQuality) {
|
|
1066
1434
|
clearInterval(this.allTimer.networkQuality);
|
|
@@ -1091,11 +1459,11 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1091
1459
|
};
|
|
1092
1460
|
});
|
|
1093
1461
|
}
|
|
1094
|
-
if (
|
|
1462
|
+
if (_this5.allTimer.networkQuality) return;
|
|
1095
1463
|
var timer = setInterval(function () {
|
|
1096
|
-
|
|
1464
|
+
_this5.emit('onNetworkQuality', resultQuality.localQuality, resultQuality.remoteQuality);
|
|
1097
1465
|
}, interval);
|
|
1098
|
-
|
|
1466
|
+
_this5.allTimer.networkQuality = timer;
|
|
1099
1467
|
};
|
|
1100
1468
|
}
|
|
1101
1469
|
}, {
|
|
@@ -1135,67 +1503,78 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1135
1503
|
}, {
|
|
1136
1504
|
key: "enterRoom",
|
|
1137
1505
|
value: function enterRoom(params, scene) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1506
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1507
|
+
var _this6 = this;
|
|
1508
|
+
var startTime, sdkAppId, userId, userSig, roomId, strRoomId, role, privateMapKey;
|
|
1509
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1510
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1511
|
+
case 0:
|
|
1512
|
+
startTime = new Date().getTime();
|
|
1513
|
+
sdkAppId = params.sdkAppId, userId = params.userId, userSig = params.userSig, roomId = params.roomId, strRoomId = params.strRoomId, role = params.role, privateMapKey = params.privateMapKey;
|
|
1514
|
+
logger.setInfo({
|
|
1515
|
+
sdkAppId: sdkAppId,
|
|
1516
|
+
userId: userId,
|
|
1517
|
+
roomId: strRoomId
|
|
1518
|
+
});
|
|
1519
|
+
logger.info('enterRoom with options: ', JSON.stringify(params), scene);
|
|
1520
|
+
this.userId = userId;
|
|
1521
|
+
this.isEnterRoom = true;
|
|
1522
|
+
_context2.next = 8;
|
|
1523
|
+
return this.setPusherAttributes({
|
|
1524
|
+
sdkAppID: sdkAppId,
|
|
1525
|
+
userID: userId,
|
|
1526
|
+
userSig: userSig,
|
|
1527
|
+
roomID: roomId,
|
|
1528
|
+
strRoomID: strRoomId,
|
|
1529
|
+
role: role,
|
|
1530
|
+
privateMapKey: privateMapKey,
|
|
1531
|
+
scene: translateTRTCAppScene(scene),
|
|
1532
|
+
enableMic: false,
|
|
1533
|
+
enableCamera: false,
|
|
1534
|
+
videoPreview: false
|
|
1535
|
+
}, 'enterRoom');
|
|
1536
|
+
case 8:
|
|
1537
|
+
this.trtc.getPusherInstance().start({
|
|
1538
|
+
success: function success() {
|
|
1539
|
+
return __awaiter(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1540
|
+
var endTime;
|
|
1541
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1542
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1543
|
+
case 0:
|
|
1544
|
+
logger.info('enterRoom success');
|
|
1545
|
+
this.scene = scene;
|
|
1546
|
+
endTime = new Date().getTime();
|
|
1547
|
+
this.emit('onEnterRoom', endTime - startTime);
|
|
1548
|
+
if (!(this.trtc.getPusherAttributes().videoPreview === true)) {
|
|
1549
|
+
_context.next = 8;
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
_context.next = 7;
|
|
1553
|
+
return this.setPusherAttributes({
|
|
1554
|
+
videoPreview: false,
|
|
1555
|
+
enableCamera: true
|
|
1556
|
+
}, 'other');
|
|
1557
|
+
case 7:
|
|
1558
|
+
this.emit('onSendFirstLocalVideoFrame', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1559
|
+
case 8:
|
|
1560
|
+
case "end":
|
|
1561
|
+
return _context.stop();
|
|
1562
|
+
}
|
|
1563
|
+
}, _callee, this);
|
|
1564
|
+
}));
|
|
1565
|
+
},
|
|
1566
|
+
fail: function fail() {
|
|
1567
|
+
_this6.isEnterRoom = false;
|
|
1568
|
+
logger.info('enterRoom fail');
|
|
1569
|
+
_this6.emit('onEnterRoom', -1);
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
case 9:
|
|
1573
|
+
case "end":
|
|
1574
|
+
return _context2.stop();
|
|
1575
|
+
}
|
|
1576
|
+
}, _callee2, this);
|
|
1577
|
+
}));
|
|
1199
1578
|
}
|
|
1200
1579
|
/**
|
|
1201
1580
|
* @category 房间
|
|
@@ -1203,7 +1582,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1203
1582
|
}, {
|
|
1204
1583
|
key: "exitRoom",
|
|
1205
1584
|
value: function exitRoom() {
|
|
1206
|
-
var
|
|
1585
|
+
var _this7 = this;
|
|
1207
1586
|
logger.info('exitRoom');
|
|
1208
1587
|
var _this$trtc$exitRoom = this.trtc.exitRoom(),
|
|
1209
1588
|
pusher = _this$trtc$exitRoom.pusher;
|
|
@@ -1211,8 +1590,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1211
1590
|
pusher: pusher,
|
|
1212
1591
|
callback: function callback() {
|
|
1213
1592
|
logger.info('exitRoom success');
|
|
1214
|
-
|
|
1215
|
-
|
|
1593
|
+
_this7.reset();
|
|
1594
|
+
_this7.emit('onExitRoom', 0);
|
|
1216
1595
|
}
|
|
1217
1596
|
});
|
|
1218
1597
|
}
|
|
@@ -1229,26 +1608,36 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1229
1608
|
}, {
|
|
1230
1609
|
key: "switchRole",
|
|
1231
1610
|
value: function switchRole(role) {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1611
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1612
|
+
var tempRole;
|
|
1613
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1614
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1615
|
+
case 0:
|
|
1616
|
+
logger.info('switchRole with options: ', role);
|
|
1617
|
+
tempRole = this.role;
|
|
1618
|
+
this.role = role;
|
|
1619
|
+
if (!(tempRole === role || role === exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
1620
|
+
_context3.next = 7;
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
logger.info('switchRole success');
|
|
1624
|
+
this.emit('onSwitchRole', 0, '');
|
|
1625
|
+
return _context3.abrupt("return");
|
|
1626
|
+
case 7:
|
|
1627
|
+
_context3.next = 9;
|
|
1628
|
+
return this.setPusherAttributes({
|
|
1629
|
+
enableCamera: false,
|
|
1630
|
+
enableMic: false
|
|
1631
|
+
}, 'switchRole');
|
|
1632
|
+
case 9:
|
|
1633
|
+
logger.info('switchRole success');
|
|
1634
|
+
this.emit('onSwitchRole', 0, '');
|
|
1635
|
+
case 11:
|
|
1636
|
+
case "end":
|
|
1637
|
+
return _context3.stop();
|
|
1638
|
+
}
|
|
1639
|
+
}, _callee3, this);
|
|
1640
|
+
}));
|
|
1252
1641
|
}
|
|
1253
1642
|
}, {
|
|
1254
1643
|
key: "connectOtherRoom",
|
|
@@ -1266,42 +1655,42 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1266
1655
|
}, {
|
|
1267
1656
|
key: "startLocalPreview",
|
|
1268
1657
|
value: function startLocalPreview() {
|
|
1269
|
-
var _this8 = this;
|
|
1270
1658
|
var frontCamera = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1659
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1660
|
+
var _this8 = this;
|
|
1661
|
+
var pusher;
|
|
1662
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1663
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1664
|
+
case 0:
|
|
1665
|
+
logger.info('startLocalPreview with options: ', frontCamera);
|
|
1666
|
+
if (!(this.role !== exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
1667
|
+
_context4.next = 3;
|
|
1668
|
+
break;
|
|
1669
|
+
}
|
|
1670
|
+
return _context4.abrupt("return");
|
|
1671
|
+
case 3:
|
|
1672
|
+
_context4.next = 5;
|
|
1673
|
+
return this.setPusherAttributes(function () {
|
|
1674
|
+
return {
|
|
1675
|
+
videoPreview: _this8.isEnterRoom ? _this8.isVideoMuted : true,
|
|
1676
|
+
enableCamera: _this8.isEnterRoom ? !_this8.isVideoMuted : false,
|
|
1677
|
+
frontCamera: frontCamera ? 'front' : 'back'
|
|
1678
|
+
};
|
|
1679
|
+
}, 'startLocalPreview');
|
|
1680
|
+
case 5:
|
|
1681
|
+
pusher = _context4.sent;
|
|
1682
|
+
logger.info('startLocalPreview success');
|
|
1683
|
+
this.emit('onFirstVideoFrame', '', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig, pusher.videoWidth, pusher.videoHeight);
|
|
1684
|
+
if (this.isEnterRoom) {
|
|
1685
|
+
this.emit('onSendFirstLocalVideoFrame', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1686
|
+
}
|
|
1687
|
+
this.isOpenCamera = true;
|
|
1688
|
+
case 10:
|
|
1689
|
+
case "end":
|
|
1690
|
+
return _context4.stop();
|
|
1302
1691
|
}
|
|
1303
|
-
});
|
|
1304
|
-
});
|
|
1692
|
+
}, _callee4, this);
|
|
1693
|
+
}));
|
|
1305
1694
|
}
|
|
1306
1695
|
/**
|
|
1307
1696
|
* 停止本地摄像头采集和预览
|
|
@@ -1310,20 +1699,26 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1310
1699
|
}, {
|
|
1311
1700
|
key: "stopLocalPreview",
|
|
1312
1701
|
value: function stopLocalPreview() {
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1702
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
1703
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1704
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1705
|
+
case 0:
|
|
1706
|
+
logger.info('stopLocalPreview');
|
|
1707
|
+
_context5.next = 3;
|
|
1708
|
+
return this.setPusherAttributes({
|
|
1709
|
+
videoPreview: false,
|
|
1710
|
+
enableCamera: false
|
|
1711
|
+
}, 'stopLocalPreview');
|
|
1712
|
+
case 3:
|
|
1713
|
+
logger.info('stopLocalPreview success');
|
|
1714
|
+
this.isOpenCamera = false;
|
|
1715
|
+
this.emit('onUserVideoAvailable', this.userId, 0);
|
|
1716
|
+
case 6:
|
|
1717
|
+
case "end":
|
|
1718
|
+
return _context5.stop();
|
|
1719
|
+
}
|
|
1720
|
+
}, _callee5, this);
|
|
1721
|
+
}));
|
|
1327
1722
|
}
|
|
1328
1723
|
/**
|
|
1329
1724
|
* 修改本地摄像头预览的 HTML 元素,小程序不支持
|
|
@@ -1348,34 +1743,36 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1348
1743
|
}, {
|
|
1349
1744
|
key: "muteLocalVideo",
|
|
1350
1745
|
value: function muteLocalVideo(mute, streamType) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
switch (streamType) {
|
|
1360
|
-
case exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig:
|
|
1361
|
-
case exports.TRTCVideoStreamType.TRTCVideoStreamTypeSub:
|
|
1362
|
-
_this10.isMuted = mute;
|
|
1363
|
-
pusher = _this10.trtc.setPusherAttributes({
|
|
1364
|
-
videoPreview: mute,
|
|
1365
|
-
enableCamera: !mute
|
|
1366
|
-
});
|
|
1367
|
-
_this10.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
1368
|
-
pusher: pusher,
|
|
1369
|
-
callback: function callback() {
|
|
1370
|
-
logger.info('muteLocalVideo success');
|
|
1371
|
-
resolve(null);
|
|
1746
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
1747
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1748
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1749
|
+
case 0:
|
|
1750
|
+
logger.info('muteLocalVideo with options: ', mute, streamType);
|
|
1751
|
+
if (this.isOpenCamera) {
|
|
1752
|
+
_context6.next = 3;
|
|
1753
|
+
break;
|
|
1372
1754
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1755
|
+
return _context6.abrupt("return");
|
|
1756
|
+
case 3:
|
|
1757
|
+
_context6.t0 = streamType;
|
|
1758
|
+
_context6.next = _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig ? 6 : _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeSub ? 6 : 11;
|
|
1759
|
+
break;
|
|
1760
|
+
case 6:
|
|
1761
|
+
this.isVideoMuted = mute;
|
|
1762
|
+
_context6.next = 9;
|
|
1763
|
+
return this.setPusherAttributes({
|
|
1764
|
+
videoPreview: mute,
|
|
1765
|
+
enableCamera: !mute
|
|
1766
|
+
}, 'muteLocalVideo');
|
|
1767
|
+
case 9:
|
|
1768
|
+
logger.info('muteLocalVideo success');
|
|
1769
|
+
return _context6.abrupt("break", 11);
|
|
1770
|
+
case 11:
|
|
1771
|
+
case "end":
|
|
1772
|
+
return _context6.stop();
|
|
1773
|
+
}
|
|
1774
|
+
}, _callee6, this);
|
|
1775
|
+
}));
|
|
1379
1776
|
}
|
|
1380
1777
|
/**
|
|
1381
1778
|
* 开始显示远端视频画面
|
|
@@ -1387,7 +1784,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1387
1784
|
}, {
|
|
1388
1785
|
key: "startRemoteView",
|
|
1389
1786
|
value: function startRemoteView(userId, view, streamType) {
|
|
1390
|
-
var
|
|
1787
|
+
var _this9 = this;
|
|
1391
1788
|
logger.info('startRemoteView with options: ', userId, view, streamType);
|
|
1392
1789
|
var streamId = translateTRTCStreamId(userId, streamType);
|
|
1393
1790
|
var playerAttributes = this.setTRTCPlayerAttributes(streamId, {
|
|
@@ -1401,7 +1798,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1401
1798
|
playerAttributes: playerAttributes,
|
|
1402
1799
|
callback: function callback() {
|
|
1403
1800
|
logger.info('startRemoteView success');
|
|
1404
|
-
|
|
1801
|
+
_this9.emit('onFirstVideoFrame', userId, streamType, 0, 0);
|
|
1405
1802
|
}
|
|
1406
1803
|
});
|
|
1407
1804
|
}
|
|
@@ -1451,18 +1848,18 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1451
1848
|
}, {
|
|
1452
1849
|
key: "stopAllRemoteView",
|
|
1453
1850
|
value: function stopAllRemoteView() {
|
|
1454
|
-
var
|
|
1851
|
+
var _this10 = this;
|
|
1455
1852
|
logger.info('stopAllRemoteView');
|
|
1456
1853
|
var playerList = this.trtc.getPlayerList();
|
|
1457
1854
|
playerList.forEach(function (player) {
|
|
1458
1855
|
var streamId = player.streamID;
|
|
1459
|
-
var playerAttributes =
|
|
1856
|
+
var playerAttributes = _this10.setTRTCPlayerAttributes(streamId, {
|
|
1460
1857
|
muteVideo: true,
|
|
1461
1858
|
stopVideo: true
|
|
1462
1859
|
});
|
|
1463
|
-
|
|
1860
|
+
_this10.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1464
1861
|
streamId: streamId,
|
|
1465
|
-
view:
|
|
1862
|
+
view: _this10.renderMap.get(streamId),
|
|
1466
1863
|
playerAttributes: playerAttributes,
|
|
1467
1864
|
callback: function callback() {
|
|
1468
1865
|
logger.info('stopAllRemoteView success');
|
|
@@ -1492,17 +1889,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1492
1889
|
}, {
|
|
1493
1890
|
key: "muteAllRemoteVideoStreams",
|
|
1494
1891
|
value: function muteAllRemoteVideoStreams(mute) {
|
|
1495
|
-
var
|
|
1892
|
+
var _this11 = this;
|
|
1496
1893
|
logger.info('muteAllRemoteVideoStreams with options: ', mute);
|
|
1497
1894
|
var playerList = this.trtc.getPlayerList();
|
|
1498
1895
|
playerList.forEach(function (player) {
|
|
1499
1896
|
var streamId = player.streamID;
|
|
1500
|
-
var playerAttributes =
|
|
1897
|
+
var playerAttributes = _this11.setTRTCPlayerAttributes(streamId, {
|
|
1501
1898
|
muteVideo: mute
|
|
1502
1899
|
});
|
|
1503
|
-
|
|
1900
|
+
_this11.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1504
1901
|
streamId: streamId,
|
|
1505
|
-
view:
|
|
1902
|
+
view: _this11.renderMap.get(streamId),
|
|
1506
1903
|
playerAttributes: playerAttributes,
|
|
1507
1904
|
callback: function callback() {
|
|
1508
1905
|
logger.info('muteAllRemoteVideoStreams success');
|
|
@@ -1521,49 +1918,56 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1521
1918
|
}, {
|
|
1522
1919
|
key: "setVideoEncoderParam",
|
|
1523
1920
|
value: function setVideoEncoderParam(params) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1921
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1922
|
+
var videoResolution, videoFps, minVideoBitrate, _translateTRTCVideoRe, videoWidth, videoHeight;
|
|
1923
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1924
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1925
|
+
case 0:
|
|
1926
|
+
logger.info('setVideoEncoderParam with options: ', JSON.stringify(params));
|
|
1927
|
+
videoResolution = params.videoResolution, params.resMode, videoFps = params.videoFps, params.videoBitrate, minVideoBitrate = params.minVideoBitrate;
|
|
1928
|
+
_translateTRTCVideoRe = translateTRTCVideoResolution(videoResolution), videoWidth = _translateTRTCVideoRe.videoWidth, videoHeight = _translateTRTCVideoRe.videoHeight; // const videoOrientation = translateTRTCVideoResolutionMode(resMode);
|
|
1929
|
+
_context7.next = 5;
|
|
1930
|
+
return this.setPusherAttributes({
|
|
1931
|
+
videoWidth: videoWidth,
|
|
1932
|
+
videoHeight: videoHeight,
|
|
1933
|
+
// videoOrientation,
|
|
1934
|
+
fps: videoFps,
|
|
1935
|
+
minBitrate: minVideoBitrate
|
|
1936
|
+
}, 'setVideoEncoderParam');
|
|
1937
|
+
case 5:
|
|
1938
|
+
logger.info('setVideoEncoderParam success');
|
|
1939
|
+
case 6:
|
|
1940
|
+
case "end":
|
|
1941
|
+
return _context7.stop();
|
|
1942
|
+
}
|
|
1943
|
+
}, _callee7, this);
|
|
1944
|
+
}));
|
|
1547
1945
|
}
|
|
1548
1946
|
}, {
|
|
1549
1947
|
key: "setLocalRenderParams",
|
|
1550
1948
|
value: function setLocalRenderParams(params) {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1949
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1950
|
+
var rotation, mirrorType, videoOrientation, localMirror;
|
|
1951
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1952
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1953
|
+
case 0:
|
|
1954
|
+
logger.info('setLocalRenderParams with options: ', JSON.stringify(params));
|
|
1955
|
+
rotation = params.rotation, params.fillMode, mirrorType = params.mirrorType;
|
|
1956
|
+
videoOrientation = translateTRTCVideoRotation(rotation);
|
|
1957
|
+
localMirror = translateTRTCVideoMirrorType(mirrorType);
|
|
1958
|
+
_context8.next = 6;
|
|
1959
|
+
return this.setPusherAttributes({
|
|
1960
|
+
videoOrientation: videoOrientation,
|
|
1961
|
+
localMirror: localMirror
|
|
1962
|
+
}, 'setLocalRenderParams');
|
|
1963
|
+
case 6:
|
|
1964
|
+
logger.info('setLocalRenderParams success');
|
|
1965
|
+
case 7:
|
|
1966
|
+
case "end":
|
|
1967
|
+
return _context8.stop();
|
|
1968
|
+
}
|
|
1969
|
+
}, _callee8, this);
|
|
1970
|
+
}));
|
|
1567
1971
|
}
|
|
1568
1972
|
/**
|
|
1569
1973
|
* 设置远端图像的渲染模式
|
|
@@ -1595,54 +1999,88 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1595
1999
|
}, {
|
|
1596
2000
|
key: "startLocalAudio",
|
|
1597
2001
|
value: function startLocalAudio(quality) {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
2002
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2003
|
+
var _this12 = this;
|
|
2004
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2005
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
2006
|
+
case 0:
|
|
2007
|
+
logger.info('startLocalAudio with options: ', quality);
|
|
2008
|
+
if (!(this.role !== exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
2009
|
+
_context9.next = 3;
|
|
2010
|
+
break;
|
|
2011
|
+
}
|
|
2012
|
+
throw new Error('Current role is audience, unable to access mic. Call switchRole to become a host.');
|
|
2013
|
+
case 3:
|
|
2014
|
+
if (!this.isMicMuted) {
|
|
2015
|
+
_context9.next = 5;
|
|
2016
|
+
break;
|
|
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
|
+
};
|
|
2025
|
+
}, 'startLocalAudio');
|
|
2026
|
+
case 7:
|
|
2027
|
+
logger.info('startLocalAudio success');
|
|
2028
|
+
this.emit('onMicDidReady');
|
|
2029
|
+
this.emit('onUserAudioAvailable', this.userId, 1);
|
|
2030
|
+
if (this.enterRoom) {
|
|
2031
|
+
this.emit('onSendFirstLocalAudioFrame');
|
|
2032
|
+
}
|
|
2033
|
+
case 11:
|
|
2034
|
+
case "end":
|
|
2035
|
+
return _context9.stop();
|
|
1611
2036
|
}
|
|
1612
|
-
}
|
|
1613
|
-
});
|
|
2037
|
+
}, _callee9, this);
|
|
2038
|
+
}));
|
|
1614
2039
|
}
|
|
1615
2040
|
}, {
|
|
1616
2041
|
key: "stopLocalAudio",
|
|
1617
2042
|
value: function stopLocalAudio() {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
2043
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
2044
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
2045
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
2046
|
+
case 0:
|
|
2047
|
+
logger.info('stopLocalAudio');
|
|
2048
|
+
_context10.next = 3;
|
|
2049
|
+
return this.setPusherAttributes({
|
|
2050
|
+
enableMic: false
|
|
2051
|
+
}, 'stopLocalAudio');
|
|
2052
|
+
case 3:
|
|
2053
|
+
logger.info('stopLocalAudio success');
|
|
2054
|
+
this.emit('onUserAudioAvailable', this.userId, 0);
|
|
2055
|
+
case 5:
|
|
2056
|
+
case "end":
|
|
2057
|
+
return _context10.stop();
|
|
2058
|
+
}
|
|
2059
|
+
}, _callee10, this);
|
|
2060
|
+
}));
|
|
1630
2061
|
}
|
|
1631
2062
|
}, {
|
|
1632
2063
|
key: "muteLocalAudio",
|
|
1633
2064
|
value: function muteLocalAudio(mute) {
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
2065
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2066
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2067
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2068
|
+
case 0:
|
|
2069
|
+
logger.info('muteLocalAudio with options: ', mute);
|
|
2070
|
+
_context11.next = 3;
|
|
2071
|
+
return this.setPusherAttributes({
|
|
2072
|
+
enableMic: !mute
|
|
2073
|
+
}, 'muteLocalAudio');
|
|
2074
|
+
case 3:
|
|
2075
|
+
this.isMicMuted = mute;
|
|
2076
|
+
logger.info('muteLocalAudio success');
|
|
2077
|
+
this.emit('onUserAudioAvailable', this.userId, mute === true ? 0 : 1);
|
|
2078
|
+
case 6:
|
|
2079
|
+
case "end":
|
|
2080
|
+
return _context11.stop();
|
|
2081
|
+
}
|
|
2082
|
+
}, _callee11, this);
|
|
2083
|
+
}));
|
|
1646
2084
|
}
|
|
1647
2085
|
}, {
|
|
1648
2086
|
key: "muteRemoteAudio",
|
|
@@ -1664,17 +2102,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1664
2102
|
}, {
|
|
1665
2103
|
key: "muteAllRemoteAudio",
|
|
1666
2104
|
value: function muteAllRemoteAudio(mute) {
|
|
1667
|
-
var
|
|
2105
|
+
var _this13 = this;
|
|
1668
2106
|
logger.info('muteAllRemoteAudio with options: ', mute);
|
|
1669
2107
|
var playerList = this.trtc.getPlayerList();
|
|
1670
2108
|
playerList.forEach(function (player) {
|
|
1671
2109
|
var streamId = player.streamID;
|
|
1672
|
-
var playerAttributes =
|
|
2110
|
+
var playerAttributes = _this13.setTRTCPlayerAttributes(streamId, {
|
|
1673
2111
|
muteAudio: mute
|
|
1674
2112
|
});
|
|
1675
|
-
|
|
2113
|
+
_this13.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1676
2114
|
streamId: streamId,
|
|
1677
|
-
view:
|
|
2115
|
+
view: _this13.renderMap.get(streamId),
|
|
1678
2116
|
playerAttributes: playerAttributes,
|
|
1679
2117
|
callback: function callback() {
|
|
1680
2118
|
logger.info('muteAllRemoteAudio success');
|
|
@@ -1694,23 +2132,30 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1694
2132
|
}, {
|
|
1695
2133
|
key: "switchCamera",
|
|
1696
2134
|
value: function switchCamera(frontCamera) {
|
|
1697
|
-
var
|
|
2135
|
+
var _this14 = this;
|
|
1698
2136
|
logger.info('switchCamera with options: ', frontCamera);
|
|
1699
2137
|
var pusher = this.trtc.getPusherInstance();
|
|
1700
2138
|
if (frontCamera === (pusher.pusherAttributes.frontCamera === 'front')) return Promise.resolve();
|
|
1701
2139
|
return new Promise(function (resolve, reject) {
|
|
1702
2140
|
wx.createLivePusherContext().switchCamera({
|
|
1703
2141
|
success: function success(event) {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
2142
|
+
return __awaiter(_this14, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2143
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2144
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2145
|
+
case 0:
|
|
2146
|
+
_context12.next = 2;
|
|
2147
|
+
return this.setPusherAttributes({
|
|
2148
|
+
frontCamera: frontCamera
|
|
2149
|
+
}, 'switchCamera');
|
|
2150
|
+
case 2:
|
|
2151
|
+
logger.info('switchCamera success');
|
|
2152
|
+
resolve(event);
|
|
2153
|
+
case 4:
|
|
2154
|
+
case "end":
|
|
2155
|
+
return _context12.stop();
|
|
2156
|
+
}
|
|
2157
|
+
}, _callee12, this);
|
|
2158
|
+
}));
|
|
1714
2159
|
},
|
|
1715
2160
|
fail: function fail(error) {
|
|
1716
2161
|
logger.info('switchCamera fail');
|
|
@@ -1722,18 +2167,25 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1722
2167
|
}, {
|
|
1723
2168
|
key: "setBeautyStyle",
|
|
1724
2169
|
value: function setBeautyStyle(style, beauty, white, ruddiness) {
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
2170
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2171
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2172
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2173
|
+
case 0:
|
|
2174
|
+
logger.info('setBeautyStyle with options: ', style, beauty, white, ruddiness);
|
|
2175
|
+
_context13.next = 3;
|
|
2176
|
+
return this.setPusherAttributes({
|
|
2177
|
+
beautyStyle: style,
|
|
2178
|
+
beautyLevel: beauty,
|
|
2179
|
+
whitenessLevel: white
|
|
2180
|
+
}, 'setBeautyStyle');
|
|
2181
|
+
case 3:
|
|
2182
|
+
logger.info('setBeautyStyle success');
|
|
2183
|
+
case 4:
|
|
2184
|
+
case "end":
|
|
2185
|
+
return _context13.stop();
|
|
2186
|
+
}
|
|
2187
|
+
}, _callee13, this);
|
|
2188
|
+
}));
|
|
1737
2189
|
}
|
|
1738
2190
|
}, {
|
|
1739
2191
|
key: "sendSEIMsg",
|
|
@@ -1897,6 +2349,40 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1897
2349
|
}
|
|
1898
2350
|
}
|
|
1899
2351
|
}
|
|
2352
|
+
}, {
|
|
2353
|
+
key: "setPusherAttributes",
|
|
2354
|
+
value: function setPusherAttributes(params, funName) {
|
|
2355
|
+
var _this15 = this;
|
|
2356
|
+
// 定义一个超时时间(以毫秒为单位)
|
|
2357
|
+
var timeoutDuration = 2000;
|
|
2358
|
+
var timeoutPromise = new Promise(function (resolve, reject) {
|
|
2359
|
+
setTimeout(function () {
|
|
2360
|
+
reject(new Error('setPusherAttributes timed out'));
|
|
2361
|
+
}, timeoutDuration);
|
|
2362
|
+
});
|
|
2363
|
+
var originalPromise = new Promise(function (resolve, reject) {
|
|
2364
|
+
try {
|
|
2365
|
+
var pusher = {};
|
|
2366
|
+
switch (funName) {
|
|
2367
|
+
case 'enterRoom':
|
|
2368
|
+
pusher = _this15.trtc.enterRoom(params);
|
|
2369
|
+
break;
|
|
2370
|
+
default:
|
|
2371
|
+
pusher = _this15.trtc.setPusherAttributes(params);
|
|
2372
|
+
break;
|
|
2373
|
+
}
|
|
2374
|
+
_this15.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
2375
|
+
pusher: pusher,
|
|
2376
|
+
callback: function callback() {
|
|
2377
|
+
resolve(pusher);
|
|
2378
|
+
}
|
|
2379
|
+
});
|
|
2380
|
+
} catch (err) {
|
|
2381
|
+
reject(err);
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
return Promise.race([originalPromise, timeoutPromise]);
|
|
2385
|
+
}
|
|
1900
2386
|
}], [{
|
|
1901
2387
|
key: "getTRTCShareInstance",
|
|
1902
2388
|
value: function getTRTCShareInstance() {
|
|
@@ -1919,6 +2405,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1919
2405
|
}]);
|
|
1920
2406
|
return TRTCCloud;
|
|
1921
2407
|
}();
|
|
2408
|
+
__decorate([setHandle], TRTCCloud.prototype, "setPusherAttributes", null);
|
|
1922
2409
|
|
|
1923
2410
|
exports.TRTCCloud = TRTCCloud;
|
|
1924
2411
|
exports.default = TRTCCloud;
|