@tencentcloud/trtc-cloud-wx 0.0.17 → 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 +789 -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";
|
|
@@ -827,7 +1163,7 @@ var scripts = {
|
|
|
827
1163
|
doc: "npx typedoc --tsconfig typedoc.json",
|
|
828
1164
|
"doc:watch": "typedoc --watch",
|
|
829
1165
|
"doc:build": "jsdoc -c jsdoc.json",
|
|
830
|
-
publish: "
|
|
1166
|
+
publish: "bash ./sdk_publish.bash"
|
|
831
1167
|
};
|
|
832
1168
|
var keywords = [
|
|
833
1169
|
];
|
|
@@ -899,7 +1235,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
899
1235
|
this.role = exports.TRTCRoleType.TRTCRoleAnchor;
|
|
900
1236
|
this.userId = '';
|
|
901
1237
|
this.isEnterRoom = false;
|
|
902
|
-
this.
|
|
1238
|
+
this.isVideoMuted = false;
|
|
1239
|
+
this.isMicMuted = false;
|
|
903
1240
|
this.isOpenCamera = false;
|
|
904
1241
|
this.audioVolumeEvaluation = 0;
|
|
905
1242
|
this.allTimer = {};
|
|
@@ -919,6 +1256,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
919
1256
|
}, {
|
|
920
1257
|
key: "destroy",
|
|
921
1258
|
value: function destroy() {
|
|
1259
|
+
this.offTRTCEvent();
|
|
922
1260
|
this.EventEmitter.removeAllListeners();
|
|
923
1261
|
this.InterfaceEventEmitter.removeAllListeners();
|
|
924
1262
|
this.trtc.exitRoom();
|
|
@@ -929,8 +1267,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
929
1267
|
this.trtc = new TRTC(this);
|
|
930
1268
|
this.trtc.setLogLevel(3);
|
|
931
1269
|
this.TRTC_EVENT = this.trtc.EVENT;
|
|
932
|
-
this.trtc.createPusher({});
|
|
933
1270
|
this.bindTRTCEvent();
|
|
1271
|
+
this.bindComponentEvent();
|
|
934
1272
|
this.handleNetworkQuality = this.getHandleNetworkQuality(2000);
|
|
935
1273
|
}
|
|
936
1274
|
}, {
|
|
@@ -940,17 +1278,32 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
940
1278
|
this.role = exports.TRTCRoleType.TRTCRoleAnchor;
|
|
941
1279
|
this.userId = '';
|
|
942
1280
|
this.isEnterRoom = false;
|
|
943
|
-
this.
|
|
1281
|
+
this.isVideoMuted = false;
|
|
1282
|
+
this.isMicMuted = false;
|
|
944
1283
|
this.isOpenCamera = false;
|
|
945
1284
|
Object.keys(this.allTimer).forEach(function (key) {
|
|
946
1285
|
clearInterval(_this.allTimer[key]);
|
|
947
1286
|
_this.allTimer[key] = null;
|
|
948
1287
|
});
|
|
949
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
|
+
}
|
|
950
1303
|
}, {
|
|
951
1304
|
key: "bindTRTCEvent",
|
|
952
1305
|
value: function bindTRTCEvent() {
|
|
953
|
-
var
|
|
1306
|
+
var _this3 = this;
|
|
954
1307
|
this.trtc.on(this.TRTC_EVENT.LOCAL_LEAVE, function (event) {
|
|
955
1308
|
// todo 第二个参数为进房耗时 此处调用start的时候处理
|
|
956
1309
|
// this.emit('onEnterRoom', 0)
|
|
@@ -959,42 +1312,42 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
959
1312
|
var _event$data = event.data,
|
|
960
1313
|
code = _event$data.code,
|
|
961
1314
|
message = _event$data.message;
|
|
962
|
-
|
|
1315
|
+
_this3.emit('onError', code, message);
|
|
963
1316
|
});
|
|
964
1317
|
this.trtc.on(this.TRTC_EVENT.REMOTE_USER_JOIN, function (event) {
|
|
965
1318
|
var userID = event.data.userID;
|
|
966
|
-
|
|
1319
|
+
_this3.emit('onRemoteUserEnterRoom', userID);
|
|
967
1320
|
});
|
|
968
1321
|
// 远端用户退出
|
|
969
1322
|
this.trtc.on(this.TRTC_EVENT.REMOTE_USER_LEAVE, function (event) {
|
|
970
1323
|
var _event$data2 = event.data,
|
|
971
1324
|
userID = _event$data2.userID;
|
|
972
1325
|
_event$data2.playerList;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
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);
|
|
977
1330
|
});
|
|
978
1331
|
// 远端用户推送视频
|
|
979
1332
|
this.trtc.on(this.TRTC_EVENT.REMOTE_VIDEO_ADD, function (event) {
|
|
980
1333
|
var player = event.data.player;
|
|
981
|
-
|
|
1334
|
+
_this3.emit(player.streamType === 'aux' ? 'onUserSubStreamAvailable' : 'onUserVideoAvailable', player.userID, 1);
|
|
982
1335
|
});
|
|
983
1336
|
// 远端用户取消推送视频
|
|
984
1337
|
this.trtc.on(this.TRTC_EVENT.REMOTE_VIDEO_REMOVE, function (event) {
|
|
985
1338
|
var player = event.data.player;
|
|
986
|
-
|
|
1339
|
+
_this3.emit(player.streamType === 'aux' ? 'onUserSubStreamAvailable' : 'onUserVideoAvailable', player.userID, 0);
|
|
987
1340
|
});
|
|
988
1341
|
// 远端用户推送音频
|
|
989
1342
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_ADD, function (event) {
|
|
990
1343
|
var player = event.data.player;
|
|
991
|
-
|
|
992
|
-
|
|
1344
|
+
_this3.emit('onUserAudioAvailable', player.userID, 1);
|
|
1345
|
+
_this3.muteRemoteAudio(player.userID, false);
|
|
993
1346
|
});
|
|
994
1347
|
// 远端用户取消推送音频
|
|
995
1348
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_REMOVE, function (event) {
|
|
996
1349
|
var player = event.data.player;
|
|
997
|
-
|
|
1350
|
+
_this3.emit('onUserAudioAvailable', player.userID, 0);
|
|
998
1351
|
});
|
|
999
1352
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_VOLUME_UPDATE, function (event) {
|
|
1000
1353
|
var playerList = event.data.playerList;
|
|
@@ -1004,7 +1357,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1004
1357
|
volume: player.volume
|
|
1005
1358
|
};
|
|
1006
1359
|
});
|
|
1007
|
-
|
|
1360
|
+
_this3.handleAudioVolumeUpdate(userVolumes);
|
|
1008
1361
|
});
|
|
1009
1362
|
this.trtc.on(this.TRTC_EVENT.LOCAL_AUDIO_VOLUME_UPDATE, function (event) {
|
|
1010
1363
|
var pusher = event.data.pusher;
|
|
@@ -1012,25 +1365,39 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1012
1365
|
userId: pusher.userID,
|
|
1013
1366
|
volume: pusher.volume
|
|
1014
1367
|
}];
|
|
1015
|
-
|
|
1368
|
+
_this3.handleAudioVolumeUpdate(userVolumes);
|
|
1016
1369
|
});
|
|
1017
1370
|
this.trtc.on(this.TRTC_EVENT.LOCAL_NET_STATE_UPDATE, function (event) {
|
|
1018
1371
|
var pusher = event.data.pusher;
|
|
1019
|
-
|
|
1372
|
+
_this3.handleNetworkQuality({
|
|
1020
1373
|
pusher: pusher
|
|
1021
1374
|
});
|
|
1022
1375
|
});
|
|
1023
1376
|
this.trtc.on(this.TRTC_EVENT.REMOTE_NET_STATE_UPDATE, function (event) {
|
|
1024
1377
|
var playerList = event.data.playerList;
|
|
1025
|
-
|
|
1378
|
+
_this3.handleNetworkQuality({
|
|
1026
1379
|
playerList: playerList
|
|
1027
1380
|
});
|
|
1028
1381
|
});
|
|
1029
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
|
+
}
|
|
1030
1397
|
}, {
|
|
1031
1398
|
key: "getHandleAudioVolumeUpdate",
|
|
1032
1399
|
value: function getHandleAudioVolumeUpdate(interval) {
|
|
1033
|
-
var
|
|
1400
|
+
var _this4 = this;
|
|
1034
1401
|
var _a;
|
|
1035
1402
|
if ((_a = this.allTimer) === null || _a === void 0 ? void 0 : _a.AudioVolume) {
|
|
1036
1403
|
clearInterval(this.allTimer.AudioVolume);
|
|
@@ -1047,12 +1414,12 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1047
1414
|
this.InterfaceEventEmitter.on('onRemoteUserLeaveRoom', filterUselessItem, this.getHandleAudioVolumeUpdate);
|
|
1048
1415
|
return function (userVolumes) {
|
|
1049
1416
|
tempUserVolumes = uniqueFunc([].concat(_toConsumableArray(userVolumes), _toConsumableArray(tempUserVolumes)), 'userId');
|
|
1050
|
-
if (
|
|
1417
|
+
if (_this4.allTimer.AudioVolume) return;
|
|
1051
1418
|
var timer = setInterval(function () {
|
|
1052
|
-
|
|
1419
|
+
_this4.emit('onUserVoiceVolume', tempUserVolumes, tempUserVolumes.length, 0 // todo 此参数无用,暂时废弃
|
|
1053
1420
|
);
|
|
1054
1421
|
}, interval);
|
|
1055
|
-
|
|
1422
|
+
_this4.allTimer.AudioVolume = timer;
|
|
1056
1423
|
};
|
|
1057
1424
|
}
|
|
1058
1425
|
}, {
|
|
@@ -1061,7 +1428,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1061
1428
|
}, {
|
|
1062
1429
|
key: "getHandleNetworkQuality",
|
|
1063
1430
|
value: function getHandleNetworkQuality(interval) {
|
|
1064
|
-
var
|
|
1431
|
+
var _this5 = this;
|
|
1065
1432
|
var _a;
|
|
1066
1433
|
if ((_a = this.allTimer) === null || _a === void 0 ? void 0 : _a.networkQuality) {
|
|
1067
1434
|
clearInterval(this.allTimer.networkQuality);
|
|
@@ -1092,11 +1459,11 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1092
1459
|
};
|
|
1093
1460
|
});
|
|
1094
1461
|
}
|
|
1095
|
-
if (
|
|
1462
|
+
if (_this5.allTimer.networkQuality) return;
|
|
1096
1463
|
var timer = setInterval(function () {
|
|
1097
|
-
|
|
1464
|
+
_this5.emit('onNetworkQuality', resultQuality.localQuality, resultQuality.remoteQuality);
|
|
1098
1465
|
}, interval);
|
|
1099
|
-
|
|
1466
|
+
_this5.allTimer.networkQuality = timer;
|
|
1100
1467
|
};
|
|
1101
1468
|
}
|
|
1102
1469
|
}, {
|
|
@@ -1136,67 +1503,78 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1136
1503
|
}, {
|
|
1137
1504
|
key: "enterRoom",
|
|
1138
1505
|
value: function enterRoom(params, scene) {
|
|
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
|
-
|
|
1199
|
-
|
|
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
|
+
}));
|
|
1200
1578
|
}
|
|
1201
1579
|
/**
|
|
1202
1580
|
* @category 房间
|
|
@@ -1204,7 +1582,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1204
1582
|
}, {
|
|
1205
1583
|
key: "exitRoom",
|
|
1206
1584
|
value: function exitRoom() {
|
|
1207
|
-
var
|
|
1585
|
+
var _this7 = this;
|
|
1208
1586
|
logger.info('exitRoom');
|
|
1209
1587
|
var _this$trtc$exitRoom = this.trtc.exitRoom(),
|
|
1210
1588
|
pusher = _this$trtc$exitRoom.pusher;
|
|
@@ -1212,8 +1590,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1212
1590
|
pusher: pusher,
|
|
1213
1591
|
callback: function callback() {
|
|
1214
1592
|
logger.info('exitRoom success');
|
|
1215
|
-
|
|
1216
|
-
|
|
1593
|
+
_this7.reset();
|
|
1594
|
+
_this7.emit('onExitRoom', 0);
|
|
1217
1595
|
}
|
|
1218
1596
|
});
|
|
1219
1597
|
}
|
|
@@ -1230,26 +1608,36 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1230
1608
|
}, {
|
|
1231
1609
|
key: "switchRole",
|
|
1232
1610
|
value: function switchRole(role) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
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
|
+
}));
|
|
1253
1641
|
}
|
|
1254
1642
|
}, {
|
|
1255
1643
|
key: "connectOtherRoom",
|
|
@@ -1267,42 +1655,42 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1267
1655
|
}, {
|
|
1268
1656
|
key: "startLocalPreview",
|
|
1269
1657
|
value: function startLocalPreview() {
|
|
1270
|
-
var _this8 = this;
|
|
1271
1658
|
var frontCamera = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
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
|
-
|
|
1302
|
-
|
|
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();
|
|
1303
1691
|
}
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1692
|
+
}, _callee4, this);
|
|
1693
|
+
}));
|
|
1306
1694
|
}
|
|
1307
1695
|
/**
|
|
1308
1696
|
* 停止本地摄像头采集和预览
|
|
@@ -1311,20 +1699,26 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1311
1699
|
}, {
|
|
1312
1700
|
key: "stopLocalPreview",
|
|
1313
1701
|
value: function stopLocalPreview() {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
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
|
+
}));
|
|
1328
1722
|
}
|
|
1329
1723
|
/**
|
|
1330
1724
|
* 修改本地摄像头预览的 HTML 元素,小程序不支持
|
|
@@ -1349,34 +1743,36 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1349
1743
|
}, {
|
|
1350
1744
|
key: "muteLocalVideo",
|
|
1351
1745
|
value: function muteLocalVideo(mute, streamType) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
switch (streamType) {
|
|
1361
|
-
case exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig:
|
|
1362
|
-
case exports.TRTCVideoStreamType.TRTCVideoStreamTypeSub:
|
|
1363
|
-
_this10.isMuted = mute;
|
|
1364
|
-
pusher = _this10.trtc.setPusherAttributes({
|
|
1365
|
-
videoPreview: mute,
|
|
1366
|
-
enableCamera: !mute
|
|
1367
|
-
});
|
|
1368
|
-
_this10.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
1369
|
-
pusher: pusher,
|
|
1370
|
-
callback: function callback() {
|
|
1371
|
-
logger.info('muteLocalVideo success');
|
|
1372
|
-
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;
|
|
1373
1754
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
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
|
+
}));
|
|
1380
1776
|
}
|
|
1381
1777
|
/**
|
|
1382
1778
|
* 开始显示远端视频画面
|
|
@@ -1388,7 +1784,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1388
1784
|
}, {
|
|
1389
1785
|
key: "startRemoteView",
|
|
1390
1786
|
value: function startRemoteView(userId, view, streamType) {
|
|
1391
|
-
var
|
|
1787
|
+
var _this9 = this;
|
|
1392
1788
|
logger.info('startRemoteView with options: ', userId, view, streamType);
|
|
1393
1789
|
var streamId = translateTRTCStreamId(userId, streamType);
|
|
1394
1790
|
var playerAttributes = this.setTRTCPlayerAttributes(streamId, {
|
|
@@ -1402,7 +1798,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1402
1798
|
playerAttributes: playerAttributes,
|
|
1403
1799
|
callback: function callback() {
|
|
1404
1800
|
logger.info('startRemoteView success');
|
|
1405
|
-
|
|
1801
|
+
_this9.emit('onFirstVideoFrame', userId, streamType, 0, 0);
|
|
1406
1802
|
}
|
|
1407
1803
|
});
|
|
1408
1804
|
}
|
|
@@ -1452,18 +1848,18 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1452
1848
|
}, {
|
|
1453
1849
|
key: "stopAllRemoteView",
|
|
1454
1850
|
value: function stopAllRemoteView() {
|
|
1455
|
-
var
|
|
1851
|
+
var _this10 = this;
|
|
1456
1852
|
logger.info('stopAllRemoteView');
|
|
1457
1853
|
var playerList = this.trtc.getPlayerList();
|
|
1458
1854
|
playerList.forEach(function (player) {
|
|
1459
1855
|
var streamId = player.streamID;
|
|
1460
|
-
var playerAttributes =
|
|
1856
|
+
var playerAttributes = _this10.setTRTCPlayerAttributes(streamId, {
|
|
1461
1857
|
muteVideo: true,
|
|
1462
1858
|
stopVideo: true
|
|
1463
1859
|
});
|
|
1464
|
-
|
|
1860
|
+
_this10.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1465
1861
|
streamId: streamId,
|
|
1466
|
-
view:
|
|
1862
|
+
view: _this10.renderMap.get(streamId),
|
|
1467
1863
|
playerAttributes: playerAttributes,
|
|
1468
1864
|
callback: function callback() {
|
|
1469
1865
|
logger.info('stopAllRemoteView success');
|
|
@@ -1493,17 +1889,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1493
1889
|
}, {
|
|
1494
1890
|
key: "muteAllRemoteVideoStreams",
|
|
1495
1891
|
value: function muteAllRemoteVideoStreams(mute) {
|
|
1496
|
-
var
|
|
1892
|
+
var _this11 = this;
|
|
1497
1893
|
logger.info('muteAllRemoteVideoStreams with options: ', mute);
|
|
1498
1894
|
var playerList = this.trtc.getPlayerList();
|
|
1499
1895
|
playerList.forEach(function (player) {
|
|
1500
1896
|
var streamId = player.streamID;
|
|
1501
|
-
var playerAttributes =
|
|
1897
|
+
var playerAttributes = _this11.setTRTCPlayerAttributes(streamId, {
|
|
1502
1898
|
muteVideo: mute
|
|
1503
1899
|
});
|
|
1504
|
-
|
|
1900
|
+
_this11.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1505
1901
|
streamId: streamId,
|
|
1506
|
-
view:
|
|
1902
|
+
view: _this11.renderMap.get(streamId),
|
|
1507
1903
|
playerAttributes: playerAttributes,
|
|
1508
1904
|
callback: function callback() {
|
|
1509
1905
|
logger.info('muteAllRemoteVideoStreams success');
|
|
@@ -1522,49 +1918,56 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1522
1918
|
}, {
|
|
1523
1919
|
key: "setVideoEncoderParam",
|
|
1524
1920
|
value: function setVideoEncoderParam(params) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
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
|
+
}));
|
|
1548
1945
|
}
|
|
1549
1946
|
}, {
|
|
1550
1947
|
key: "setLocalRenderParams",
|
|
1551
1948
|
value: function setLocalRenderParams(params) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
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
|
+
}));
|
|
1568
1971
|
}
|
|
1569
1972
|
/**
|
|
1570
1973
|
* 设置远端图像的渲染模式
|
|
@@ -1596,54 +1999,88 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1596
1999
|
}, {
|
|
1597
2000
|
key: "startLocalAudio",
|
|
1598
2001
|
value: function startLocalAudio(quality) {
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
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();
|
|
1612
2036
|
}
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
2037
|
+
}, _callee9, this);
|
|
2038
|
+
}));
|
|
1615
2039
|
}
|
|
1616
2040
|
}, {
|
|
1617
2041
|
key: "stopLocalAudio",
|
|
1618
2042
|
value: function stopLocalAudio() {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
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
|
+
}));
|
|
1631
2061
|
}
|
|
1632
2062
|
}, {
|
|
1633
2063
|
key: "muteLocalAudio",
|
|
1634
2064
|
value: function muteLocalAudio(mute) {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
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
|
+
}));
|
|
1647
2084
|
}
|
|
1648
2085
|
}, {
|
|
1649
2086
|
key: "muteRemoteAudio",
|
|
@@ -1665,17 +2102,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1665
2102
|
}, {
|
|
1666
2103
|
key: "muteAllRemoteAudio",
|
|
1667
2104
|
value: function muteAllRemoteAudio(mute) {
|
|
1668
|
-
var
|
|
2105
|
+
var _this13 = this;
|
|
1669
2106
|
logger.info('muteAllRemoteAudio with options: ', mute);
|
|
1670
2107
|
var playerList = this.trtc.getPlayerList();
|
|
1671
2108
|
playerList.forEach(function (player) {
|
|
1672
2109
|
var streamId = player.streamID;
|
|
1673
|
-
var playerAttributes =
|
|
2110
|
+
var playerAttributes = _this13.setTRTCPlayerAttributes(streamId, {
|
|
1674
2111
|
muteAudio: mute
|
|
1675
2112
|
});
|
|
1676
|
-
|
|
2113
|
+
_this13.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1677
2114
|
streamId: streamId,
|
|
1678
|
-
view:
|
|
2115
|
+
view: _this13.renderMap.get(streamId),
|
|
1679
2116
|
playerAttributes: playerAttributes,
|
|
1680
2117
|
callback: function callback() {
|
|
1681
2118
|
logger.info('muteAllRemoteAudio success');
|
|
@@ -1695,23 +2132,30 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1695
2132
|
}, {
|
|
1696
2133
|
key: "switchCamera",
|
|
1697
2134
|
value: function switchCamera(frontCamera) {
|
|
1698
|
-
var
|
|
2135
|
+
var _this14 = this;
|
|
1699
2136
|
logger.info('switchCamera with options: ', frontCamera);
|
|
1700
2137
|
var pusher = this.trtc.getPusherInstance();
|
|
1701
2138
|
if (frontCamera === (pusher.pusherAttributes.frontCamera === 'front')) return Promise.resolve();
|
|
1702
2139
|
return new Promise(function (resolve, reject) {
|
|
1703
2140
|
wx.createLivePusherContext().switchCamera({
|
|
1704
2141
|
success: function success(event) {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
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
|
+
}));
|
|
1715
2159
|
},
|
|
1716
2160
|
fail: function fail(error) {
|
|
1717
2161
|
logger.info('switchCamera fail');
|
|
@@ -1723,18 +2167,25 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1723
2167
|
}, {
|
|
1724
2168
|
key: "setBeautyStyle",
|
|
1725
2169
|
value: function setBeautyStyle(style, beauty, white, ruddiness) {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
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
|
+
}));
|
|
1738
2189
|
}
|
|
1739
2190
|
}, {
|
|
1740
2191
|
key: "sendSEIMsg",
|
|
@@ -1898,6 +2349,40 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1898
2349
|
}
|
|
1899
2350
|
}
|
|
1900
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
|
+
}
|
|
1901
2386
|
}], [{
|
|
1902
2387
|
key: "getTRTCShareInstance",
|
|
1903
2388
|
value: function getTRTCShareInstance() {
|
|
@@ -1920,6 +2405,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1920
2405
|
}]);
|
|
1921
2406
|
return TRTCCloud;
|
|
1922
2407
|
}();
|
|
2408
|
+
__decorate([setHandle], TRTCCloud.prototype, "setPusherAttributes", null);
|
|
1923
2409
|
|
|
1924
2410
|
exports.TRTCCloud = TRTCCloud;
|
|
1925
2411
|
exports.default = TRTCCloud;
|