MediaManagerApe.js
45.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
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
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
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
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import FlashToolComponet from "libs/FlashToolComponet";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import HLSPlayer from 'tinyhls';
import H5Seting from "libs/H5Seting";
import ErrorApe from './ErrorApe';
let loger = Loger.getLoger('PC-MediaManagerApe');
const FLASH_MEDIA_BOX = 'medioBox';//flashViewBoxV和flashViewBoxH
const H5_MEDIA_BOX = 'h5VideoBox';
const FLASH_VIEW_DIV_VERTICAL_RIGHT = "flashViewDivVertical";//垂直布局的flash容器div (1路和2路流) (老师的推和拉都显示在这里)
const FLASH_VIEW_DIV_VERTICAL_MIDDLE = "media1v1BoxView_flash_content";//垂直布局的flash容器div (1路和2路流) (老师的推和拉都显示在这里)
const FLASH_VIEW_DIV_HORIZONTAL = "flashViewDivHorizontal";//水平布局的flash容器div(底部学生的端的推流和拉流传窗口)
const FLASH_PATH = './FlashVideoPlayer.swf';//flash路径
class MediaManagerApe extends Ape {
constructor() {
super();
this.publishTimer = 0;
//水平方向的小视屏尺寸 FLASH
this.smallVideoW = 160//174;//HLS的也是同样大小
this.smallVideoH = 120//130;
//水平方向的小视屏尺寸 H5
this.smallVideoW_H5 = 174//174;//HLS的也是同样大小
this.smallVideoH_H5 = 130//130;
this.h5HlsPlayerList = [];//H5播放器数组,多个视图的时候开头第一个显示老师的
this.flashPlayerList = [];//flash播放器数组,多个视图的时候开头第一个显示老师的
this.flashPlayerMain;
this.minFlashViewWidth = 800;
this.minH5ViewWidth = 800;
this.creatH5Seting();
//获取本地存储的设置信息
FlashToolComponet.getLocalStore();
this.addEvent();
//默认隐藏底部的视频区域
this.hideBottomVideoViewBox();
this.hideInvisibleSpeakerUI();
this.init();
}
//事件监听
addEvent() {
$(window).on('resize', this.onWindowResize.bind(this));
xdysdk.on("error_event", this._classErrorHandler.bind(this));
xdysdk.on("class_join_success", this._classJoinSuccessHandler.bind(this));
xdysdk.on("class_get_info_success", this._classGetInfoSuccessHandler.bind(this));
xdysdk.on("media_stop_publish", this._mediaStopPublishHandler.bind(this));//停止推流
/// 视频消息
xdysdk.on("video_broadcast", this._videoBroadcastHandler.bind(this));
xdysdk.on("video_play", this._videoPlayHandler.bind(this));
xdysdk.on("video_stop", this._videoStopHandler.bind(this));
/// 音频消息
xdysdk.on("audio_broadcast", this._audioBroadcastHandler.bind(this));
xdysdk.on("audio_play", this._audioPlayHandler.bind(this));
xdysdk.on("audio_stop", this._audioStopHandler.bind(this));
xdysdk.on("class_insert_roster", this._classInsertRosterHandler.bind(this));//会议有用户加入
xdysdk.on("class_update_roster", this._updateRosterHandler.bind(this)); //人员信息更新
$('.tabCon').on("click", '.setUpInfo', this._settingTheirHandler.bind(this));//打开设置
//底部创建多个视频播放器的时候如果显示不全,需要左右切换显示
$('#nextStep').on("click", this._clickNextStepHandler.bind(this));//
$('#prevStep').on("click", this._clickPrevStepHandler.bind(this));//
$("#invisible_speakBtnOpen").on("click", this._clickInvisiblePublishVideo.bind(this));
$("#invisible_speakBtnClose").on("click", this._clickInvisibleStopPublishVideo.bind(this));
}
init() {
//打开H5设置面板按钮
$('.setting').on("click", this._settingHandler.bind(this));
//播放器列表
this.flashPlayerList = [];//flash播放器列表
this.h5HlsPlayerList = [];//HLS播放器列表
if (ClassDataProxy.isRecordPlayBack) {
//录制回放-创建HLS播放器
this.creatH5HlsPlayerListView();
} else {
//直播互动-创建flash播放器
this.creatFlashPlayerListView();
}
}
//创建HLS播放器
creatH5HlsPlayerListView() {
//直播时使用的推流和播流 flash播放器
//1路流时只创建右侧聊天区域头部的视频
//2路流时创建中间的视频区域
//大于2路时,现在右侧的区域和底部的区域
switch (ClassDataProxy.maxMediaChannels) {
case 1:
//创建1路流 右侧播放器
this.creatRightMainH5Player();
break
case 2:
//2路流播放器
this.creatMiddleMainH5Player();
break
default:
//大于2路流 需要创建2个flash
//创建老师的
this.creatRightMainH5Player();
//学生的
this.creatBottomH5Player();
break
}
}
//创建媒体播放器 直播时使用
creatFlashPlayerListView() {
loger.log('创建flash播放器列表', ClassDataProxy.maxMediaChannels);
//直播时使用的推流和播流 flash播放器
//1路流时只创建右侧聊天区域头部的视频
//2路流时创建中间的视频区域
//大于2路时,现在右侧的区域和底部的区域
switch (ClassDataProxy.maxMediaChannels) {
case 1:
//创建1路流 右侧播放器
this.creatRightMainFlash();
break
case 2:
//显示监课的语音控制
if (ClassDataProxy.userRole == ClassDataProxy.USER_INVISIBLE) {
this.showInvisibleSpeakerUI();
}
//2路流播放器
this.creatMiddleMainFlash();
break
default:
//大于2路流 需要创建2个flash
//创建老师的
this.creatRightMainFlash();
//学生的
this.creatBottomFlash();
break
}
}
//创建FLASH---------------------------------------
//创建右侧老师的flash窗口
creatRightMainFlash() {
let flashBoxDiv = document.createElement("div");
flashBoxDiv.id = FLASH_VIEW_DIV_VERTICAL_RIGHT;
let isShowPublishBtn = false;
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
//老师需要显示推流和停止推流的按钮
isShowPublishBtn = true;
}
$("#videoDivBox").append(flashBoxDiv);
let flashPlayerMain = new FlashToolComponet();
flashPlayerMain.init({
swfUrl: FLASH_PATH,
divName: FLASH_VIEW_DIV_VERTICAL_RIGHT,
mediaId: 0,
layoutType: FlashToolComponet.LAYOUT_V,
type: FlashToolComponet.VIDEO,//audio 或video
callBack: this._flashPlayerCallback.bind(this),
playersDataList: [
{
mediaType: FlashToolComponet.VIDEO,
width: 320,
height: 240,
showFullBtn: false,
showPublishBtn: isShowPublishBtn,
level: 1
}
],
videoImage: 'images/waiting.png',
audioImage: 'images/waitingAudio.png',
audioBtnImage: 'images/audioBtnImage.png',
videoBtnImage: 'images/videoBtnImage.png',
stopPublishImage: 'images/stopPublishImage.png',
backgroundColor: 0x353536
});
this.flashPlayerList.push(flashPlayerMain);
//设置为主flash,提供给监课和设置面板获取数据(有多个flash的时候,需要设置一个)
this.flashPlayerMain = flashPlayerMain;
this.flashPlayerMain.isMainFlash = true;
}
//创建中间的1V1flash窗口 (老师和学生)
creatMiddleMainFlash() {
//显示中部的1V1的视频区域
this.showMiddleFlashVideoViewBox();
let flashBoxDiv = document.createElement("div");
flashBoxDiv.id = FLASH_VIEW_DIV_VERTICAL_MIDDLE;
let isShowPublishBtn = false;
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
//老师需要显示推流和停止推流的按钮
isShowPublishBtn = true;
}
$("#media1v1BoxView_flash").append(flashBoxDiv);
let flashPlayerMain = new FlashToolComponet();
flashPlayerMain.layoutGapV = 10;//flash播放器之间垂直间隔
flashPlayerMain.myUserRole = ClassDataProxy.userRole;//这个需要指定
flashPlayerMain.init({
swfUrl: FLASH_PATH,
divName: FLASH_VIEW_DIV_VERTICAL_MIDDLE,
mediaId: 0,
layoutType: FlashToolComponet.LAYOUT_V,
type: FlashToolComponet.VIDEO,//audio 或video
callBack: this._flashPlayerCallback.bind(this),
playersDataList: [
{
mediaType: FlashToolComponet.VIDEO,
width: 320,
height: 240,
showFullBtn: false,
showPublishBtn: isShowPublishBtn,
level: 1,
usePermission: "host" //****指定使用者的身份只能老师使用****
},
{
mediaType: FlashToolComponet.VIDEO,
width: 320,
height: 240,
showFullBtn: false,
showPublishBtn: false,
level: 0,
usePermission: "normal" //****指定使用者的身份只能老师使用****
},
{
mediaType: FlashToolComponet.AUDIO,
width: 1,
height: 1,
showFullBtn: false,
showPublishBtn: false,
showUserName:false,
level: 0,
usePermission: "invisible" //****指定使用者的身份只能老师使用****
}
],
videoImage: 'images/waiting.png',
audioImage: 'images/waitingAudio.png',
audioBtnImage: 'images/audioBtnImage.png',
videoBtnImage: 'images/videoBtnImage.png',
stopPublishImage: 'images/stopPublishImage.png',
backgroundColor: 0x353536
});
this.flashPlayerList.push(flashPlayerMain);
//设置为主flash,提供给监课和设置面板获取数据(有多个flash的时候,需要设置一个)
this.flashPlayerMain = flashPlayerMain;
this.flashPlayerMain.isMainFlash = true;
loger.log('创建中部1V1播放器列表', ClassDataProxy.maxMediaChannels);
}
//创建底部的FLASH列表
creatBottomFlash() {
loger.log('创建底部flash播放器列表', ClassDataProxy.maxMediaChannels);
//大于2路流的时候底部也需要创建一个flash播放器
let flashBoxDiv = document.createElement("div");
flashBoxDiv.id = FLASH_VIEW_DIV_HORIZONTAL;
$("#botFlashVideoBox").append(flashBoxDiv);
//显示底部的视频区域
this.showBottomFlashVideoViewBox();
let playersDataList = [];
//播放器中的布局的数据,计数从1开始
for (let i = 1; i < ClassDataProxy.maxMediaChannels; i++) {
playersDataList.push({
mediaType: FlashToolComponet.VIDEO,
width: this.smallVideoW,
height: this.smallVideoH,
showFullBtn: false,
showPublishBtn: false,
level: 0
});
}
//创建播放器
let flashPlayerMain = new FlashToolComponet();
flashPlayerMain.topGap = 6;
flashPlayerMain.leftGap = 10;
flashPlayerMain.layoutGapH = 10;
flashPlayerMain.init({
swfUrl: FLASH_PATH,
divName: FLASH_VIEW_DIV_HORIZONTAL,
mediaId: 0,
autoShowLayout: true,//自动调整播放器显示布局(推流的排最前-播放-未播放的)
layoutType: FlashToolComponet.LAYOUT_H,
type: FlashToolComponet.VIDEO,//audio 或video
playersDataList: playersDataList,
callBack: this._flashPlayerCallback.bind(this),
videoImage: 'images/waiting.png',
audioImage: 'images/waitingAudio.png',
audioBtnImage: 'images/audioBtnImage.png',
videoBtnImage: 'images/videoBtnImage.png',
stopPublishImage: 'images/stopPublishImage.png',
backgroundColor: 0x262626
});
this.flashPlayerList.push(flashPlayerMain);
//console.log('flashPlayerList->', this.flashPlayerList);
}
//创建H5播放器
//创建右侧老师的H5窗口
creatRightMainH5Player() {
//录制回放时使用的m3u8点播播放器
//根据最多音视频路数创建播放器
let hlsPlayer = new HLSPlayer(document.getElementById('replayVideo'));
hlsPlayer.divName = 'replayVideo';
$("#" + hlsPlayer.divName)[0].poster = "images/waiting.png";
this.h5HlsPlayerList.push(hlsPlayer);
}
//创建中间的1V1flash窗口 (老师和学生)
creatMiddleMainH5Player() {
//显示中部的1V1的视频区域
if (ClassDataProxy.maxMediaChannels > 1) {
//显示中部的视频区域
this.showMiddleH5VideoViewBox();
let hlsPlayerTop = new HLSPlayer(document.getElementById('media1v1BoxView_top_video'));
hlsPlayerTop.divName = 'media1v1BoxView_top_video';
$("#" + hlsPlayerTop.divName)[0].poster = "images/waiting.png";
this.h5HlsPlayerList.push(hlsPlayerTop);
let hlsPlayerBottom = new HLSPlayer(document.getElementById('media1v1BoxView_bottom_video'));
hlsPlayerBottom.divName = 'media1v1BoxView_bottom_video';
$("#" + hlsPlayerBottom.divName)[0].poster = "images/waiting.png";
this.h5HlsPlayerList.push(hlsPlayerBottom);
console.log('h5HlsPlayerList->', this.h5HlsPlayerList)
}
}
//创建底部的FLASH列表
creatBottomH5Player() {
if (ClassDataProxy.maxMediaChannels > 1) {
//显示底部的视频区域
this.showBottomH5VideoViewBox();
//最多可以创建7个
for (let i = 1; i < ClassDataProxy.maxMediaChannels; i++) {
//创建flash视图 -->divName->h5VideoBox_X_X
let divName = 'botH5VideoSingleBox_' + i;
let hlsPlayer = new HLSPlayer(document.getElementById(divName));
hlsPlayer.divName = divName;
$("#" + divName).show();
$("#" + divName).css("width", this.smallVideoW_H5 + "px");
$("#" + divName).css("height", this.smallVideoH_H5 + "px");
$("#" + divName)[0].poster = "images/waiting.png";
this.h5HlsPlayerList.push(hlsPlayer);
}
//console.log('h5HlsPlayerList->', this.h5HlsPlayerList)
}
}
//-------------界面UI-----------------------------
//显示底部播放器模块-flash
showBottomFlashVideoViewBox() {
//底部显示时 高度计算 底部隐藏时高度为100%
//let view = document.documentElement.clientHeight || document.body.clientHeight;
//$('.leftWarp_top').height(view - $('.botVideoWindow').height() - $('.header').height() - 7 + 'px');//底部盒子往上偏移7 显示滚动条
$("#botVideoWindow").show();
$("#botFlashVideoBox").show();
$("#nextStep").show();
$("#prevStep").show();
//$("#botFlashVideoBox").css("min-width",(this.smallVideoW+4)*(ClassDataProxy.maxMediaChannels-1)+'px');
this.updateLeftWarpBottomVideoView();
this.updateLeftWarpTop();
}
//显示中部1v1的flash视图
showMiddleFlashVideoViewBox() {
$("#media1v1BoxView").show();
$("#media1v1BoxView_flash").show();
$("#media1v1BoxView_h5").hide();
}
//显示1v1中部的H5视图
showMiddleH5VideoViewBox() {
$("#media1v1BoxView").show();
$("#media1v1BoxView_flash").hide();
$("#media1v1BoxView_h5").show();
}
//显示底部播放器模块-H5
showBottomH5VideoViewBox() {
//底部显示时 高度计算 底部隐藏时高度为100%
//let view = document.documentElement.clientHeight || document.body.clientHeight;
//$('.leftWarp_top').height(view - $('.botVideoWindow').height() - $('.header').height() - 7 + 'px');//底部盒子往上偏移7 显示滚动条
$("#botVideoWindow").show();
$("#nextStep").show();
$("#prevStep").show();
$("#botH5VideoBox").show();
if (ClassDataProxy.isRecordPlayBack) {
this.minH5ViewWidth = (this.smallVideoW_H5 + 10) * (ClassDataProxy.maxMediaChannels - 1);
$("#botH5VideoBox").css("min-width", this.minH5ViewWidth + 'px');
}
/*else {
$("#botH5VideoBox").css("min-width",(this.smallVideoW+10)*(ClassDataProxy.maxMediaChannels-1)+'px');
}
*/
this.updateLeftWarpTop();
this.updateLeftWarpBottomVideoView();
}
//隐藏底部播放器模块
hideBottomVideoViewBox() {
$('.leftWarp_top').height("100%");
$("#botVideoWindow").hide();
$("#nextStep").hide();
$("#prevStep").hide();
$("#botFlashVideoBox").hide();
$("#botH5VideoBox").hide();
}
//左侧底部的视频列表区域设置
updateLeftWarpBottomVideoView() {
this.minFlashViewWidth = (this.smallVideoW + 10) * (ClassDataProxy.maxMediaChannels - 1);
this.minH5ViewWidth = (this.smallVideoW_H5 + 10) * (ClassDataProxy.maxMediaChannels - 1);
$("#botFlashVideoBox").css("min-width", this.minFlashViewWidth + 'px');
if (ClassDataProxy.isRecordPlayBack) {
$("#botH5VideoBox").css("min-width", this.minH5ViewWidth + 'px');
}
}
//更新左侧文档区域的高度
updateLeftWarpTop() {
let view = document.documentElement.clientHeight || document.body.clientHeight;
////底部盒子往上偏移7 显示滚动条
let bottomHeight = 2;
//大于2路流的时候才显示底部的视频区域
if (ClassDataProxy.maxMediaChannels > 2) {
bottomHeight = $('.botVideoWindow').height();
}
//如果是录制回放,不需要减去头部的高度,正在上课状态下才需要减去头部的高度
if (ClassDataProxy.isRecordPlayBack) {
$('.leftWarp_top').height(view - bottomHeight - 7 + 'px');//底部盒子往上偏移7 显示滚动条
} else {
$('.leftWarp_top').height(view - bottomHeight - $('.header').height() - 7 + 'px');//底部盒子往上偏移7 显示滚动条
}
if ($("#botH5VideoBox").width() < this.minH5ViewWidth || $("#botFlashVideoBox").width() < this.minFlashViewWidth) {
//console.log("有滚动条");
//两路流以上的才显示箭头
if (ClassDataProxy.maxMediaChannels > 2) {
$('#nextStep').show();
$('#prevStep').show();
}
} else {
// console.log("没有滚动条");
$('#nextStep').hide();
$('#prevStep').hide();
}
}
//显示监课的音频控制界面
showInvisibleSpeakerUI() {
$("#invisible_speak").show();
$("#invisible_speakBtnClose").hide();
$("#invisible_speakBtnOpen").show();
this.updateInvisibleSpeakerVollume(0);
}
//隐藏监课的音频控制界面
hideInvisibleSpeakerUI() {
$("#invisible_speak").hide();
$("#invisible_speakBtnClose").hide();
$("#invisible_speakBtnOpen").hide();
this.updateInvisibleSpeakerVollume(0);
}
//监课说话音量
updateInvisibleSpeakerVollume(_activeVolume) {
let percent = parseInt(_activeVolume) + "%";
$("#invisible_speakVolumePlan").css("width", percent);
}
//-------------------事件监听处理--------------------
//监听舞台大小变化
onWindowResize() {
//设置左侧上部分的高度
this.updateLeftWarpTop();
}
_flashPlayerCallback(_data) {
//loger.log("_flashSetingToolsrCallback->", _data);
if (_data) {
switch (_data.type) {
case FlashToolComponet.TYPE_16:
//flash点击检测网速
loger.log("收到测速的消息", _data);
xdysdk.api("sendVideoBroadcastMsg", {
"actionType": 4,
"toNodeId": ClassDataProxy.curUserInfoTeaOrStu.nodeId, //发给老师或者学生
"data": _data.msg
});
break;
case FlashToolComponet.TYPE_17:
//flash点击检测网速
loger.log("收到测速完成的消息", _data);
xdysdk.api("sendVideoBroadcastMsg", {
"actionType": 5,
"toNodeId": ClassDataProxy.curRosterInvisibleNodeId, //发给监课
"data": _data
});
break;
case FlashToolComponet.TYPE_21:
// loger.log("监课的音量=========->", _data);
if (_data && _data.data) {
this.updateInvisibleSpeakerVollume(_data.data.volumeLevel);
}
break;
case FlashToolComponet.TYPE_24:
ErrorApe.showWarnError(ClassDataProxy.localConfig.cameraAccessFailed);//摄像头获取失败
break;
case FlashToolComponet.TYPE_25:
ErrorApe.showWarnError(ClassDataProxy.localConfig.microphoneAccessFailed);//麦克风获取失败
break;
case FlashToolComponet.TYPE_26:
ErrorApe.showWarnError(ClassDataProxy.localConfig.noCamera);//没有摄像头
break;
case FlashToolComponet.TYPE_27:
ErrorApe.showWarnError(ClassDataProxy.localConfig.cameraOccupied);//摄像头被占用
break;
case FlashToolComponet.TYPE_28:
ErrorApe.showWarnError(ClassDataProxy.localConfig.noMicrophone);//没有麦克风
break;
case FlashToolComponet.TYPE_29:
ErrorApe.showWarnError(ClassDataProxy.localConfig.microphoneOccupied);//麦克风被占用
break;
case FlashToolComponet.TYPE_30:
let exploerObj = ClassDataProxy.getBrowserInfo();
if (exploerObj && exploerObj.explorer == "firefox") {
//火狐浏览器提示去下载flash
ErrorApe.showError(ErrorApe.TYPE_8, "");
} else {
//其他浏览器flash被禁用,可以去下载
ErrorApe.showError(ErrorApe.TYPE_9, "");
}
break;
case FlashToolComponet.TYPE_105:
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.noFreePlayer);//推流->没有空闲的播放器使用
break;
case FlashToolComponet.TYPE_106:
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.cantOpenDevice);
break;
default:
break;
}
}
}
//停止当前的所有推流
_mediaStopPublishHandler() {
loger.log('停止当前的所有推流->')
this.stopAllPublishMedia();
}
//监听视频控制消息
_videoBroadcastHandler(_data) {
loger.log("收到视频控制消息->", _data);
//PC-MediaApe -> ["_videoBroadcastHandler",{"fromNodeId":324363995,"toNodeId":324344157,"actionType":1,"data":"0"}
if (_data) {
if (_data.toNodeId != ClassDataProxy.nodeId) {
loger.log("收到视频控制消息->不需要处理", _data);
return;
}
switch (_data.actionType) {
case 1:
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickPublish({
mediaType: FlashToolComponet.VIDEO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
})
}
break;
case 2:
//2(停止推流关闭摄像头)
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickStopPublish({
mediaType: FlashToolComponet.VIDEO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
});
}
break;
case 3:
if (ClassDataProxy.nodeId == _data.data.nodeId) {
loger.log("收到监听监课的设置面板更新====>", _data.data);
if (_data.data.actionType == H5Seting.CHANGE_MS_LIST) {
xdysdk.api("switchMediaServer", _data.data.ipPort);
//MS服务被切换之后,如果当前正在推流,需要停止然后重新推流
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.changeMsAndRePublish({
mediaType: FlashToolComponet.VIDEO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
});
}
//MS服务被切换之后,如果当前正在推流,需要停止然后重新推流
/*if (this.isPublish) {
loger.warn("MS被手动切换,停止当前的推流,2秒后重新推流====>");
this.stopAllPublishMedia();
let _this = this;
this.publishTimer = setTimeout(function () {
clearTimeout(_this.publishTimer);
loger.warn("MS切换后开始重新推流====>");
_this._publishVideo();
}, 2000);
}*/
} else {
//这里传输给flash的三个字段:actionType deviceInfo nodeData
FlashToolComponet.flashSettingChangeSelf(_data.data);
}
}
break;
case 4:
ClassDataProxy.curRosterInvisibleNodeId = _data.fromNodeId;
loger.log("收到测速信息====>", _data, _data.fromNodeId, ClassDataProxy.curRosterInvisibleNodeId);
if (this.flashPlayerMain) {
this.flashPlayerMain.flashTestMsBW(_data);
}
break;
case 5:
loger.log("收到测速返回结果信息====>", _data);
if (this.flashPlayerMain) {
this.flashPlayerMain.flashShowMsTestBWcallBack(_data);
}
break;
default :
break;
}
}
}
//监听音频控制消息
_audioBroadcastHandler(_data) {
loger.log("收到音频控制消息->", _data);
//PC-MediaApe -> ["_videoBroadcastHandler",{"fromNodeId":324363995,"toNodeId":324344157,"actionType":1,"data":"0"}
if (_data) {
if (_data.toNodeId != ClassDataProxy.nodeId) {
loger.log("收到音频控制消息->不需要处理", _data);
return;
}
switch (_data.actionType) {
case 1:
//1(开启音频推流)
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickPublish({
mediaType: FlashToolComponet.AUDIO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
});
}
break;
case 2:
//2(停止音频推流)
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickStopPublish({
mediaType: FlashToolComponet.AUDIO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
});
}
break;
default :
break;
}
}
}
_videoPlayHandler(_data) {
let publiserDeviceType = this.getUserDeviceType(_data.fromNodeId);
if (ClassDataProxy.isRecordPlayBack) {
$("#replayVideo")[0].poster = "images/waiting.png";
let seek = parseInt(_data.seek);
if (seek < 1) {
seek = 1;
}
loger.log("录制回放->播放视频->", _data.replay, seek);
this.playHLSMedia({
replay: _data.replay,
modeType: HLSPlayer.MODE_VOD,
seek: seek,
mediaId: _data.mediaId,
mediaType: FlashToolComponet.VIDEO,
nodeId: _data.fromNodeId,
userRole: _data.userRole,
deviceType: publiserDeviceType,
optionJsonData: _data.optionJsonData
});
} else {
loger.log("播放视频->", _data.rtmpUrl);
this.playMedia({
rtmpUrl: _data.rtmpUrl,
mediaId: _data.mediaId,
mediaType: FlashToolComponet.VIDEO,
nodeId: _data.fromNodeId,
userRole: _data.userRole,
userName: _data.userName,
deviceType: publiserDeviceType,
optionJsonData: _data.optionJsonData
});
}
}
_videoStopHandler(_data) {
if (ClassDataProxy.isRecordPlayBack) {
loger.log("录制回放->停止播放视频->", _data);
this.stopHLSMedia({
replay: _data.replay,
modeType: HLSPlayer.MODE_VOD,
seek: _data.seek,
mediaId: _data.mediaId,
mediaType: FlashToolComponet.VIDEO,
nodeId: _data.fromNodeId,
userRole: _data.userRole
});
} else {
loger.log("停止播放视频->", _data);
this.stopMedia({
mediaId: _data.mediaId,
mediaType: FlashToolComponet.VIDEO,
nodeId: _data.fromNodeId,
userRole: _data.userRole
});
}
}
_flashPlayerMainCallback(_data) {
loger.log("_flashPlayerMainCallback->");
}
_audioPlayHandler(_data) {
let publiserDeviceType = this.getUserDeviceType(_data.fromNodeId);
if (ClassDataProxy.isRecordPlayBack) {
$("#replayVideo")[0].poster = "images/waitingAudio.png";
let seek = parseInt(_data.seek);
if (seek < 1) {
seek = 1;
}
loger.log("录制回放->播放视频->", _data.replay, seek);
this.playHLSMedia({
replay: _data.replay,
modeType: HLSPlayer.MODE_VOD,
seek: seek,
mediaId: _data.mediaId,
mediaType: FlashToolComponet.AUDIO,
nodeId: _data.fromNodeId,
userRole: _data.userRole,
deviceType: publiserDeviceType,
optionJsonData: _data.optionJsonData
});
} else {
loger.log("播放音频->", _data);
this.playMedia({
rtmpUrl: _data.rtmpUrl,
mediaId: _data.mediaId,
mediaType: FlashToolComponet.AUDIO,
nodeId: _data.fromNodeId,
userRole: _data.userRole,
userName: _data.userName,
deviceType: publiserDeviceType,
optionJsonData: _data.optionJsonData
});
}
}
_audioStopHandler(_data) {
loger.log("停止播放音频->", _data);
if (ClassDataProxy.isRecordPlayBack) {
this.stopHLSMedia({
replay: _data.replay,
modeType: HLSPlayer.MODE_VOD,
seek: _data.seek,
mediaId: _data.mediaId,
mediaType: FlashToolComponet.AUDIO,
nodeId: _data.fromNodeId,
userRole: _data.userRole
});
$("#replayVideo")[0].poster = "images/waiting.png";
} else {
this.stopMedia({
mediaId: _data.mediaId,
mediaType: FlashToolComponet.AUDIO,
nodeId: _data.fromNodeId,
userRole: _data.userRole
});
}
}
//根据nodeI获取当前用户的设备类型
getUserDeviceType(_nodeId) {
let deviceType = 0;
let user = ClassDataProxy.rosterList[_nodeId];
if (user && user.nodeData) {
deviceType = user.nodeData.deviceType || 0;
}
return deviceType;
}
//用户加入
_classInsertRosterHandler(_data) {
if (_data) {
if (_data.nodeData.userRole == ClassDataProxy.USER_HOST) {
//loger.log("用户进入->如果是老师->设置名称");
ClassDataProxy.curRosterHostInfo = _data;
}
this.updateInvisibleMediaUI(_data);
}
}
//用户数据更新
_updateRosterHandler(_data) {
//console.log("人员信息的更新===============",_data);
if (_data) {
if (_data.nodeData.userRole == ClassDataProxy.USER_HOST) {
ClassDataProxy.curRosterHostInfo = _data;
}
this.updateInvisibleMediaUI(_data);
}
}
//更新监课的推流状态按钮
updateInvisibleMediaUI(_data) {
if (_data) {
if (_data.nodeData.userRole == ClassDataProxy.USER_INVISIBLE&&ClassDataProxy.maxMediaChannels==2) {
if (_data.nodeData.openCamera || _data.nodeData.openMicrophones) {
$("#invisible_speakBtnClose").show();
$("#invisible_speakBtnOpen").hide();
} else {
this.showInvisibleSpeakerUI();
}
}
}
}
_classErrorHandler(_data) {
switch (_data.code) {
case 20000:
//只处理网络端口的情况,如果当前正在推流或播放,需要停止
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
this.stopAllPublishMedia({
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole,
mediaType: FlashToolComponet.VIDEO
});
} else {
this._videoStopHandler({"mediaId": 0});
}
break;
default:
break;
}
}
_classGetInfoSuccessHandler(_data) {
//loger.log("获取课堂信息完成", new Date().getTime(), _data);
ClassDataProxy.maxAudioChannels = _data.maxAudioChannels || 0;//最大音频路数
ClassDataProxy.maxVideoChannels = _data.maxVideoChannels || 0;//最大视频路数
ClassDataProxy.maxMediaChannels = _data.maxMediaChannels || 0;//最大音视频路数,以音视频路数中的最大值为准
//this.init();
}
_classJoinSuccessHandler(_data) {
//视频质量相关设置
ClassDataProxy.fps = _data.fps || 15;
ClassDataProxy.gop = _data.gop || 3;
ClassDataProxy.videoQuality = parseInt(_data.videoQuality);
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
this.stopAllPublishMedia({
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole,
mediaType: FlashToolComponet.VIDEO
});
} else {
this._videoStopHandler({"mediaId": 0});
}
$('.videoControl').show();
//如果自己是老师,视频区域的名字显示自己的
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
$('.curUserName').text(ClassDataProxy.userName);
}
//录制回放和非录制回放的处理
if (ClassDataProxy.isRecordPlayBack) {
$('.videoDivBox').hide();
$('.replayVideo').show();
} else {
$('.videoDivBox').show();
$('#replayVideo').hide();
//不需要当flash设置,全局设置即可
FlashToolComponet.setMediaVideoConfig(ClassDataProxy.fps, ClassDataProxy.gop, ClassDataProxy.videoQuality);
}
}
//--------------------HLS 播放器-----------------------------
//播放HLS
playHLSMedia(_data) {
if (!_data) {
loger.warn('playHLSMedia->参数错误--->', _data);
return;
}
let hlsPlayer = this.getfreeH5Player(_data.userRole);
if (hlsPlayer) {
if (_data.mediaType == FlashToolComponet.AUDIO) {
$("#" + hlsPlayer.divName)[0].poster = "images/waitingAudio.png";
hlsPlayer.IS_VIDEO = false;
} else {
$("#" + hlsPlayer.divName)[0].poster = "images/waiting.png";
hlsPlayer.IS_VIDEO = true;
}
loger.log('playHLSMedia->开始HLS播放', _data);
hlsPlayer.rtmpURL = _data.replay;
hlsPlayer.nodeId = _data.nodeId;
hlsPlayer.mediaId = _data.mediaId;
hlsPlayer.play(_data.replay, HLSPlayer.MODE_VOD, _data.seek);
} else {
loger.log('playHLSMedia->没有找到对应的播放器');
}
}
//停止HLS
stopHLSMedia(_data) {
if (!_data) {
loger.warn('stopHLSMedia->参数错误', _data);
return;
}
let hlsPlayer = this.getH5PlayerForNodeId(_data.nodeId);
if (hlsPlayer) {
$("#" + hlsPlayer.divName)[0].poster = "images/waiting.png"
hlsPlayer.rtmpURL = '';
hlsPlayer.nodeId = 0;
hlsPlayer.mediaId = 0;
hlsPlayer.stop();
} else {
loger.log('stopHLSMedia->没有找到对应的播放器', _data);
}
}
//根据nodeId查找正在使用的播放器
getH5PlayerForNodeId(_nodeId) {
if (!_nodeId) {
loger.warn('根据nodeId查找正在使用的播放器->没有播放器->_nodeId', _nodeId);
return null;
}
//console.log(this.h5HlsPlayerList);
loger.warn('根据nodeId查找正在使用的播放器->_nodeId', _nodeId);
let playerItem = null;
for (let i = 0; i < this.h5HlsPlayerList.length; i++) {
playerItem = this.h5HlsPlayerList[i];
//播放器存在并且播放器使用者的nodeId一致
if (playerItem && playerItem.nodeId == _nodeId) {
return playerItem;
}
}
return null;
}
//获取空闲的HLS播放器
getfreeH5Player(_userRole) {
if (!this.h5HlsPlayerList || this.h5HlsPlayerList.length < 1) {
loger.warn('getfreeH5Player->没有播放器');
return null;
}
loger.warn("获取空闲的HLS播放器->_userRole:" + _userRole);
//获取当前空闲的播放器
if (ClassDataProxy.maxMediaChannels < 2) {
//如果只有1路流,默认也取第一个
return this.h5HlsPlayerList[0];
} else if (_userRole == ClassDataProxy.USER_HOST) {
//数组中的第一个是老师自己的
console.warn("获取空闲的HLS播放器->返回老师播放器:" + this.h5HlsPlayerList[0]);
return this.h5HlsPlayerList[0];
} else {
let playerItem;
//从第二个播放器开始查找,第一个是老师用的
for (let i = 1; i < this.h5HlsPlayerList.length; i++) {
playerItem = this.h5HlsPlayerList[i];
//播放器存在并且播放器没有被使用
if (playerItem && !playerItem.rtmpURL) {
return playerItem;
}
}
return playerItem;
}
}
//---------------调用FLASH接口--------------------------------
//播放音视频
playMedia(_data) {
if (!_data) {
loger.warn('playMedia->参数错误--->', _data);
return;
}
let player = this.getFlashPlayer(_data.userRole);
console.log("player", player);
if (player) {
player.playMedia(_data);
} else {
loger.log('playMedia->没有找到对应的播放器');
}
}
//停止音视频
stopMedia(_data) {
if (!_data) {
loger.warn('stopMedia->参数错误', _data);
return;
}
let flashPlayItem = null;
for (let i = 0; i < this.flashPlayerList.length; i++) {
flashPlayItem = this.flashPlayerList[i];
flashPlayItem.stopFlashPlay(_data);
}
}
//停止当前的所有流
stopAllPublishMedia() {
clearTimeout(this.publishTimer);
//停止视频推流
//停止音频推流
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickStopPublish({
mediaType: FlashToolComponet.VIDEO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
});
}
}
//根据角色身份从播放器列表中获取一个播放器
getFlashPlayer(_userRole) {
if (!this.flashPlayerList || this.flashPlayerList.length < 1) {
loger.warn('getFlashPlayer->没有播放器');
return null;
}
if (ClassDataProxy.maxMediaChannels < 3) {
//如果只有1路流,默认也取第一个
return this.flashPlayerList[0];
} else {
if (_userRole == ClassDataProxy.USER_HOST) {
return this.flashPlayerList[0];
} else {
return this.flashPlayerList[1];
}
}
return null;
}
//---------------------设置面板接口------------------
//设置面板
creatH5Seting() {
loger.log("初始化H5设置面板");
var box = $("#H5settingBox")[0];
H5Seting.init(box, 222, this.setingEventCallback.bind(this));
}
setingEventCallback(_data) {
console.log('H5设置面板返回->', _data);
let info = {};
if (_data) {
if (_data.isSelf) {
//自己的设置面板发生数据变更
switch (_data.actionType) {
case H5Seting.CHANGE_CAMERA_TEST:
console.log("打开摄像头->");
if (this.flashPlayerMain) {
this.flashPlayerMain.closeMicrophone();
this.flashPlayerMain.closeSpeakerTest();
this.flashPlayerMain.openCamera();
}
break;
case H5Seting.CHANGE_MICROPHONE_TEST:
console.log("打开麦克风->");
if (this.flashPlayerMain) {
this.flashPlayerMain.closeSpeakerTest();
this.flashPlayerMain.closeCamera();
this.flashPlayerMain.openMicrophone();
}
break;
case H5Seting.CHANGE_SPEAKER_TEST_STOP:
console.log("停止麦克风测试音->");
if (this.flashPlayerMain) {
this.flashPlayerMain.closeSpeakerTest();
}
break;
case H5Seting.CHANGE_SPEAKER_TEST:
//扬声器测试
if (this.flashPlayerMain) {
this.flashPlayerMain.closeMicrophone();
this.flashPlayerMain.closeCamera();
this.flashPlayerMain.openSpeakerTest("sound.mp3");
}
break;
case H5Seting.CHANGE_SPEAKER_SCENE:
if (this.flashPlayerMain) {
this.flashPlayerMain.closeMicrophone();
this.flashPlayerMain.closeSpeakerTest();
this.flashPlayerMain.closeCamera();
}
break;
case H5Seting.CHANGE_SETING_CLOSE:
//设置面板关闭
if (this.flashPlayerMain) {
this.flashPlayerMain.closeMicrophone();
this.flashPlayerMain.closeSpeakerTest();
this.flashPlayerMain.closeCamera();
}
break;
case H5Seting.CHANGE_CAMERA:
case H5Seting.CHANGE_MICROPHONE:
case H5Seting.CHANGE_MICROPHONE_CODE:
case H5Seting.CHANGE_MICROPHONE_GAIN:
case H5Seting.CHANGE_MICROPHONE_NOISE:
case H5Seting.CHANGE_MICROPHONE_AUTO_GAIN:
case H5Seting.CHANGE_RESOLUTION:
case H5Seting.CHANGE_SPEAKER_VOLUME:
//设置数据改变
FlashToolComponet.flashSettingChangeSelf(_data.paramData);
break;
default:
break;
}
} else {
//别人的设置面板发生数据变更
switch (_data.actionType) {
case H5Seting.CHANGE_CAMERA:
case H5Seting.CHANGE_MICROPHONE:
case H5Seting.CHANGE_MICROPHONE_CODE:
case H5Seting.CHANGE_MICROPHONE_GAIN:
case H5Seting.CHANGE_MICROPHONE_NOISE:
case H5Seting.CHANGE_MICROPHONE_AUTO_GAIN:
case H5Seting.CHANGE_RESOLUTION:
case H5Seting.CHANGE_SPEAKER_VOLUME:
case H5Seting.CHANGE_MS_LIST:
this.sendSetingDataToNodeId(_data.paramData, 3);
break;
case H5Seting.CHANGE_MS_DETECTION:
//MS网速测试
loger.log("发送MS网速测试->")
this.sendSetingDataToNodeId(_data.paramData, 4);
break;
default:
break;
}
}
}
}
//发送别人的设置面板数据 _actionType 3设备切换信息; 4MS测速;5.返回MS测速
sendSetingDataToNodeId(_data, _actionType) {
loger.log("发送别人的设置面板数据", _data);
xdysdk.api("sendVideoBroadcastMsg", {
"actionType": _actionType,
"toNodeId": _data.nodeId,
"data": _data
});
}
//显示设置面板
_settingHandler() {
//显示自己的设置面板
H5Seting.showSeting(ClassDataProxy.rosterList[ClassDataProxy.nodeId].nodeData);
}
//显示他人的设置
_settingTheirHandler(evt) {
let setId = $(evt.target).attr('data');
//显示别人的设置面板
//console.log("显示别人的设置面板", ClassDataProxy.rosterList[setId])
ClassDataProxy.curUserInfoTeaOrStu = ClassDataProxy.rosterList[setId];
let userInfo = ClassDataProxy.rosterList[setId].nodeData;
userInfo.className = ClassDataProxy.className;
userInfo.classId = ClassDataProxy.classId;
H5Seting.showSeting(userInfo, false);
}
_clickNextStepHandler(evt) {
let left = $("#botVideoWindow").scrollLeft()
let width = $('#botVideoWindow').width();
$("#botVideoWindow").scrollLeft(left + 160)
}
_clickPrevStepHandler(evt) {
let left = $("#botVideoWindow").scrollLeft()
let width = $('#botVideoWindow').width();
$("#botVideoWindow").scrollLeft(left - 160)
}
//监课的点击推流和停止推流-----------------
_clickInvisiblePublishVideo() {
loger.log("监课点击音频推流");
if (ClassDataProxy.userRole == ClassDataProxy.USER_INVISIBLE) {
//监课点击开启推流
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickPublish({
mediaType: FlashToolComponet.AUDIO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
})
}
}
}
_clickInvisibleStopPublishVideo() {
loger.log("监课点击停止音频推流");
if (ClassDataProxy.userRole == ClassDataProxy.USER_INVISIBLE) {
var player = this.getFlashPlayer(ClassDataProxy.userRole);
if (player) {
player.dispatchClickStopPublish({
mediaType: FlashToolComponet.AUDIO,
userId: ClassDataProxy.userId,
userName: ClassDataProxy.userName,
nodeId: ClassDataProxy.nodeId,
userRole: ClassDataProxy.userRole
});
}
this.updateInvisibleSpeakerVollume(0);
}
}
//---------录制回放控制接口----------------------------
clear() {
loger.log("clear");
try {
if (this.h5HlsPlayerList) {
for (let i = 0; i < this.h5HlsPlayerList.length; i++) {
let player = this.h5HlsPlayerList[i];
if (player) {
$("#" + player.divName)[0].poster = "images/waiting.png";
player.rtmpURL = '';
player.mediaId = 0;
player.nodeId = 0;
player.stop()
}
}
}
} catch (err) {
loger.warn("clear", err.message);
}
}
play() {
loger.log("play");
try {
if (this.h5HlsPlayerList) {
for (let i = 0; i < this.h5HlsPlayerList.length; i++) {
let player = this.h5HlsPlayerList[i];
if (player) {
player.resume()
}
}
}
} catch (err) {
loger.warn("clear", err.message);
}
}
pause() {
loger.log("pause");
try {
if (this.h5HlsPlayerList) {
for (let i = 0; i < this.h5HlsPlayerList.length; i++) {
let player = this.h5HlsPlayerList[i];
if (player) {
player.pause()
}
}
}
} catch (err) {
loger.warn("clear", err.message);
}
}
stop() {
loger.log("stop");
try {
if (this.h5HlsPlayerList) {
for (let i = 0; i < this.h5HlsPlayerList.length; i++) {
let player = this.h5HlsPlayerList[i];
if (player) {
$("#" + player.divName)[0].poster = "images/waiting.png";
player.rtmpURL = '';
player.mediaId = 0;
player.nodeId = 0;
player.stop()
}
}
}
} catch (err) {
loger.warn("clear", err.message);
}
}
}
MediaManagerApe.prototype.FLASH_LOADED = MediaManagerApe.FLASH_LOADED = "flash_loaded";
export default MediaManagerApe;