张桐

音视频模块修改

@@ -258,6 +258,15 @@ height: 1080px; @@ -258,6 +258,15 @@ height: 1080px;
258 color: #333; 258 color: #333;
259 font-size: 12px; 259 font-size: 12px;
260 } 260 }
  261 +
  262 +.classCurId{
  263 + float: left;
  264 + margin-left: 20px;
  265 + color: #333;
  266 + font-size: 12px;
  267 + width: 40px;
  268 + height: 20px;
  269 +}
261 /*直播中*/ 270 /*直播中*/
262 .cur-status { 271 .cur-status {
263 float: left; 272 float: left;
@@ -962,6 +971,43 @@ height: 1080px; @@ -962,6 +971,43 @@ height: 1080px;
962 971
963 972
964 } 973 }
  974 +.spinner1 {
  975 + display: none;
  976 + z-index: 10;
  977 + position: absolute;
  978 + top: 190px;
  979 + left: 231px;
  980 + margin: 100px auto 0;
  981 + width: 150px;
  982 + text-align: center;
  983 +}
  984 +
  985 +.spinner1 > div {
  986 + width: 30px;
  987 + height: 30px;
  988 + background-color: #3498db;
  989 +
  990 + border-radius: 100%;
  991 + display: inline-block;
  992 + -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
  993 + animation: bouncedelay 1.4s infinite ease-in-out;
  994 + /* Prevent first frame from flickering when animation starts */
  995 + -webkit-animation-fill-mode: both;
  996 + animation-fill-mode: both;
  997 +}
  998 +
  999 +.spinner1 .bounce1 {
  1000 + -webkit-animation-delay: -0.32s;
  1001 + animation-delay: -0.32s;
  1002 +}
  1003 +
  1004 +.spinner1 .bounce2 {
  1005 + -webkit-animation-delay: -0.16s;
  1006 + animation-delay: -0.16s;
  1007 +}
  1008 +
  1009 +
  1010 +
965 1011
966 .spinner > div { 1012 .spinner > div {
967 width: 30px; 1013 width: 30px;
@@ -1198,16 +1244,17 @@ height: 1080px; @@ -1198,16 +1244,17 @@ height: 1080px;
1198 .stuVideo-video{ 1244 .stuVideo-video{
1199 position: absolute; 1245 position: absolute;
1200 left: 3px; 1246 left: 3px;
1201 - bottom: 0px; 1247 + bottom: -5px;
1202 cursor: pointer; 1248 cursor: pointer;
1203 color: #333333; 1249 color: #333333;
1204 - margin: 5px 5px 0px 5px; 1250 + margin: 0px 5px 0px 5px;
1205 1251
1206 } 1252 }
1207 .stuVideo-videoBg{ 1253 .stuVideo-videoBg{
  1254 + display: none;
1208 position: absolute; 1255 position: absolute;
1209 left: 3px; 1256 left: 3px;
1210 - bottom: 5px; 1257 + bottom: 1px;
1211 width: 16px; 1258 width: 16px;
1212 height: 16px; 1259 height: 16px;
1213 cursor: pointer; 1260 cursor: pointer;
@@ -1224,19 +1271,20 @@ height: 1080px; @@ -1224,19 +1271,20 @@ height: 1080px;
1224 .stuVideo-voice{ 1271 .stuVideo-voice{
1225 position: absolute; 1272 position: absolute;
1226 left:23px; 1273 left:23px;
1227 - bottom: 10px; 1274 + bottom: 4px;
1228 width: 16px; 1275 width: 16px;
1229 height: 16px; 1276 height: 16px;
1230 font-size: 16px; 1277 font-size: 16px;
1231 cursor: pointer; 1278 cursor: pointer;
1232 color: #333333; 1279 color: #333333;
1233 - margin: 5px 5px 0px 5px; 1280 + margin: 0px 5px 0px 5px;
1234 1281
1235 } 1282 }
1236 .stuVideo-voiceBg{ 1283 .stuVideo-voiceBg{
  1284 + display: none;
1237 position: absolute; 1285 position: absolute;
1238 left:23px; 1286 left:23px;
1239 - bottom: 5px; 1287 + bottom: 0px;
1240 width: 16px; 1288 width: 16px;
1241 height: 16px; 1289 height: 16px;
1242 font-size: 16px; 1290 font-size: 16px;
@@ -1264,13 +1312,25 @@ height: 1080px; @@ -1264,13 +1312,25 @@ height: 1080px;
1264 } 1312 }
1265 .teacherVideo .teacherVideoBg{ 1313 .teacherVideo .teacherVideoBg{
1266 1314
  1315 + position: absolute;
  1316 + left: 0;
  1317 + top: 0;
  1318 + width: 100%;
  1319 + height: 100%;
  1320 + background: url("../images/none-video-tea.png") no-repeat center center;
  1321 + }
  1322 +.teacherVideo .teacherVoicing{
  1323 + display: none;
1267 position: absolute; 1324 position: absolute;
1268 left: 0; 1325 left: 0;
1269 top: 0; 1326 top: 0;
1270 width: 100%; 1327 width: 100%;
1271 height: 100%; 1328 height: 100%;
1272 - background: url("../images/none-video-tea.png") no-repeat center center; 1329 + background: url("../images/voicing.gif") no-repeat center center;
1273 } 1330 }
  1331 +
  1332 +
  1333 +
1274 .teacherVideo .teacherVideoInfo{ 1334 .teacherVideo .teacherVideoInfo{
1275 height: 100%; 1335 height: 100%;
1276 width: 100%; 1336 width: 100%;
@@ -1316,9 +1376,10 @@ height: 1080px; @@ -1316,9 +1376,10 @@ height: 1080px;
1316 1376
1317 } 1377 }
1318 .teacherVideo-voiceBg{ 1378 .teacherVideo-voiceBg{
  1379 + display:none;
1319 position: absolute; 1380 position: absolute;
1320 left:23px; 1381 left:23px;
1321 - bottom: 5px; 1382 + bottom: 0px;
1322 width: 16px; 1383 width: 16px;
1323 height: 16px; 1384 height: 16px;
1324 font-size: 16px; 1385 font-size: 16px;
@@ -2389,6 +2450,7 @@ canvas { @@ -2389,6 +2450,7 @@ canvas {
2389 } 2450 }
2390 2451
2391 .loginContent li:nth-of-type(5){ 2452 .loginContent li:nth-of-type(5){
  2453 + display: none;
2392 height: 40px; 2454 height: 40px;
2393 line-height: 40px; 2455 line-height: 40px;
2394 width: 270px; 2456 width: 270px;
@@ -16,8 +16,8 @@ @@ -16,8 +16,8 @@
16 <script type="text/javascript" src="js/xdyEvent.js"></script> 16 <script type="text/javascript" src="js/xdyEvent.js"></script>
17 <script type="text/javascript" src="js/drag.js"></script> 17 <script type="text/javascript" src="js/drag.js"></script>
18 18
19 - <script type="text/javascript" src="js/McuClient.js?v=1.0.228.14"></script>  
20 - <!--<script type="text/javascript" src="http://192.168.1.140/McuClient/McuClient.js?729903213236"></script>--> 19 + <!--<script type="text/javascript" src="js/McuClient.js?v=1.0.228.14"></script>-->
  20 + <script type="text/javascript" src="http://192.168.1.140/McuClient/McuClient.js?7213236"></script>
21 <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script> 21 <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
22 22
23 <script type="text/javascript" src="src/main.js"></script> 23 <script type="text/javascript" src="src/main.js"></script>
@@ -81,8 +81,8 @@ @@ -81,8 +81,8 @@
81 </div> 81 </div>
82 <a id="a-status" href="javascript: void(0)">未开始</a></li> 82 <a id="a-status" href="javascript: void(0)">未开始</a></li>
83 83
84 - <li class="classroom"><a href="javascript: void(0)">[少儿英语口语]第四节</a></li>  
85 - 84 + <li class="classroom"><a id="classCurName" href="javascript: void(0)"></a></li>
  85 + <li class="classCurId"><a id="classCurId" href="javascript: void(0)"></a></li>
86 86
87 <!--设置--> 87 <!--设置-->
88 <div class="am-dropdown" data-am-dropdown> 88 <div class="am-dropdown" data-am-dropdown>
@@ -245,10 +245,15 @@ @@ -245,10 +245,15 @@
245 <!--<div class="am-tabs" data-am-tabs>--> 245 <!--<div class="am-tabs" data-am-tabs>-->
246 <!--<div id="tab-box" class="am-tabs-bd">--> 246 <!--<div id="tab-box" class="am-tabs-bd">-->
247 <!--<div class="am-tab-panel am-fade am-in am-active" id="tab1">--> 247 <!--<div class="am-tab-panel am-fade am-in am-active" id="tab1">-->
248 - 248 + <div class="spinner1">
  249 + <div class="bounce1"></div>
  250 + <div class="bounce2"></div>
  251 + <div class="bounce3"></div>
  252 + </div>
249 <!--引入canvas画板--> 253 <!--引入canvas画板-->
250 <div id="draw" class="clear"> 254 <div id="draw" class="clear">
251 <div class="canvas_container"> 255 <div class="canvas_container">
  256 +
252 <canvas id="canvas"> 257 <canvas id="canvas">
253 浏览器不支持 258 浏览器不支持
254 </canvas> 259 </canvas>
@@ -376,9 +381,17 @@ @@ -376,9 +381,17 @@
376 <!--右侧--> 381 <!--右侧-->
377 <div id="right" class="right"> 382 <div id="right" class="right">
378 <div class="studentVideo"> 383 <div class="studentVideo">
379 - <img> 384 + <div class="stuPublish" style="position:absolute;top: 0; width:240px;height:180px">
  385 + <div id="stuPublish"></div>
  386 + </div>
  387 + <div class="stuPlay" style="position:absolute;top: 0; width:240px;height:180px">
  388 + <div id="stuPlay"></div>
  389 + </div>
  390 + <img class="stuVideoBg"/>
380 <div id="stuVideo-video" class="stuVideo-video iconfont">&#xe62e;</div> 391 <div id="stuVideo-video" class="stuVideo-video iconfont">&#xe62e;</div>
  392 + <div id="stuVideo-videoBg" class="stuVideo-videoBg iconfont"></div>
381 <div id="stuVideo-voice" class="stuVideo-voice iconfont">&#xe62d;</div> 393 <div id="stuVideo-voice" class="stuVideo-voice iconfont">&#xe62d;</div>
  394 + <div id="stuVideo-voiceBg" class="stuVideo-voiceBg iconfont"></div>
382 <!--<span>lucy</span>--> 395 <!--<span>lucy</span>-->
383 </div> 396 </div>
384 <div class="teacherVideo"> 397 <div class="teacherVideo">
@@ -389,9 +402,11 @@ @@ -389,9 +402,11 @@
389 <div id="play"></div> 402 <div id="play"></div>
390 </div> 403 </div>
391 <img class="teacherVideoBg"/> 404 <img class="teacherVideoBg"/>
  405 + <img class="teacherVoicing"/>
392 <div id="teacherVideo-video" class="teacherVideo-video iconfont">&#xe62e;</div> 406 <div id="teacherVideo-video" class="teacherVideo-video iconfont">&#xe62e;</div>
393 <div id="teacherVideo-videoBg" class="teacherVideo-videoBg iconfont"></div> 407 <div id="teacherVideo-videoBg" class="teacherVideo-videoBg iconfont"></div>
394 <div id="teacherVideo-voice" class="teacherVideo-voice iconfont">&#xe62d;</div> 408 <div id="teacherVideo-voice" class="teacherVideo-voice iconfont">&#xe62d;</div>
  409 + <div id="teacherVideo-voiceBg" class="teacherVideo-voiceBg iconfont"></div>
395 410
396 </div> 411 </div>
397 412
@@ -575,7 +590,7 @@ @@ -575,7 +590,7 @@
575 590
576 <div class="fourParamsOut"> 591 <div class="fourParamsOut">
577 <ul class="fourParams clear"> 592 <ul class="fourParams clear">
578 - <li><span>classId:</span><input class="classId" type="text" value="2028061409"></li> 593 + <li><span>classId:</span><input class="classId" type="text" value="120394398"></li>
579 <!--<li><span>userRole:</span><input class="userRole" type="text" value=""></li>--> 594 <!--<li><span>userRole:</span><input class="userRole" type="text" value=""></li>-->
580 <!--<li><span>portal:</span><input class="portal" type="text" value=""></li>--> 595 <!--<li><span>portal:</span><input class="portal" type="text" value=""></li>-->
581 <li><span>userId:</span><input class="userId" type="text" value=""></li> 596 <li><span>userId:</span><input class="userId" type="text" value=""></li>
@@ -584,7 +599,6 @@ @@ -584,7 +599,6 @@
584 </li> 599 </li>
585 </ul> 600 </ul>
586 <div class="permission"> 601 <div class="permission">
587 -  
588 <div class="permissionIn"> 602 <div class="permissionIn">
589 <input id="host" type="radio" name="userRole" value="host" onclick="getValue(this.value)"><label for="host">老师</label> 603 <input id="host" type="radio" name="userRole" value="host" onclick="getValue(this.value)"><label for="host">老师</label>
590 <input id="normal" type="radio" name="userRole" value="normal" onclick="getValue(this.value)"><label 604 <input id="normal" type="radio" name="userRole" value="normal" onclick="getValue(this.value)"><label
此 diff 太大无法显示。
@@ -3,69 +3,22 @@ @@ -3,69 +3,22 @@
3 3
4 var client; 4 var client;
5 var MessageTypes; 5 var MessageTypes;
6 -var canvasInfo;  
7 -var canvasInfoUpdate;  
8 -var canvasInfoArr=[];  
9 -var canvasInfoUpArr=[];  
10 -  
11 var classLoadInfo; //3个参数 课堂号/用户角色/ip 的对象 6 var classLoadInfo; //3个参数 课堂号/用户角色/ip 的对象
12 -  
13 var classAllInfo={}; 7 var classAllInfo={};
14 -  
15 var fourParams={}; 8 var fourParams={};
16 -  
17 var fileInfo={}; //传递给底层的对象 9 var fileInfo={}; //传递给底层的对象
18 -  
19 -var fileDeleteInfo={}; //删除的文件对象  
20 -  
21 var thisFileName; //当前点击的文件名称 10 var thisFileName; //当前点击的文件名称
22 -  
23 var thisFileId;//当前点击的文件ID 11 var thisFileId;//当前点击的文件ID
24 -  
25 var thisDocId; 12 var thisDocId;
26 var thisClassId; 13 var thisClassId;
27 -  
28 -var thisFileParent;//当前元素的父级  
29 -  
30 var fileFromArr=[]; //存储底层返回的文件,放到该数组 14 var fileFromArr=[]; //存储底层返回的文件,放到该数组
31 -  
32 -var fileFromUpArr=[];//存储上传返回的文件,,放到该数组  
33 -  
34 -  
35 var classParamInfo={} 15 var classParamInfo={}
36 -  
37 -var pdfUrl;  
38 var docfullPath; 16 var docfullPath;
39 var imgUrl; 17 var imgUrl;
40 -  
41 -  
42 -var switchArr=[];  
43 -  
44 -  
45 -  
46 -var pdfFile;  
47 -var currPageNumber;  
48 -  
49 -var fileShowArr=[]; //存储显示的文档  
50 -  
51 -var pdfArr=[];  
52 -  
53 -var openPage;  
54 -  
55 -var pdfUrlArr=[];  
56 -  
57 -var docfullPathArr=[];  
58 -  
59 -var imgUrlSingle;  
60 -  
61 -  
62 var curPageNum; 18 var curPageNum;
63 var pageNum; 19 var pageNum;
64 -  
65 var fileItemIdx; 20 var fileItemIdx;
66 21
67 -  
68 -  
69 //画布 22 //画布
70 var canvas ; 23 var canvas ;
71 var context ; 24 var context ;
@@ -92,21 +45,11 @@ function mainTimeStamp() { @@ -92,21 +45,11 @@ function mainTimeStamp() {
92 } 45 }
93 46
94 $(function () { 47 $(function () {
95 -  
96 -  
97 -  
98 -  
99 - // FastClick.attach(document.body);  
100 -  
101 initEngine();//加载MCUClientEngine; 48 initEngine();//加载MCUClientEngine;
  49 + listenClass();
102 loading(); 50 loading();
103 51
104 urlParamsJudge();//对地址栏参数的数据进行判断 52 urlParamsJudge();//对地址栏参数的数据进行判断
105 -  
106 -  
107 -  
108 -  
109 -  
110 }); 53 });
111 54
112 function initEngine(){ 55 function initEngine(){
@@ -115,26 +58,63 @@ function initEngine(){ @@ -115,26 +58,63 @@ function initEngine(){
115 client=MCUClientEngine.createMcuClient(); 58 client=MCUClientEngine.createMcuClient();
116 //获取事件监听消息定义 59 //获取事件监听消息定义
117 MessageTypes=MCUClientEngine.MessageTypes; 60 MessageTypes=MCUClientEngine.MessageTypes;
  61 + //McuClient版本号
118 console.log(client.sdkInfo.version); 62 console.log(client.sdkInfo.version);
119 63
120 videoWithFlash.flashInit(client); 64 videoWithFlash.flashInit(client);
121 // nativeVideo.nativeInit(client); 65 // nativeVideo.nativeInit(client);
  66 +}
122 67
  68 +//监听课堂
  69 +function listenClass() {
  70 + if(client){
  71 + // client.on(MessageTypes.UPDATE_CLASS_TIMER,updateClassTime);// 监听会议时间更新
123 72
  73 + client.on(MessageTypes.CLASS_UPTATE_STATUS,classUpdateStatus);//监听会议状态更新
  74 + client.on(MessageTypes.CHAT_RECEIVE,chatReceive); //监听到聊天信息
  75 + client.on(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,whiteboardUpdate);//监听白板更新
  76 + client.on(MessageTypes.DOC_DELETE,docDelete);//监听删除文档
  77 + client.on(MessageTypes.DOC_UPDATE,docUpdate);//监听更新文档
124 78
  79 + // // //点击开始上课
  80 + //
  81 + // if($("#classes-status-1").html()=="开始上课"){
  82 + // $("#classes-status-1").click(function (e){
  83 + // client.sendStartClass();
  84 + // });
  85 + // }
  86 + // if($("#classes-status-1").html()=="课间休息"){
  87 + // $("#classes-status-1").click(function (e){
  88 + // client.sendPauseClass();
  89 + // });
  90 + // }
  91 + // if($("#classes-status-1").html()=="继续上课"){
  92 + // $("#classes-status-1").click(function (e){
  93 + // client.sendStartClass();
  94 + // });
  95 + // }
  96 + //
  97 + //
  98 + //
  99 + // //结束课堂
  100 + // $("#classes-status-2").click(function (e) {
  101 + // if($("#classes-status-2").html()=="结束课堂"){
  102 + // client.sendCloseClass();
  103 + // }
  104 + // });
  105 + //
  106 + //
  107 + //
  108 + // if($("#class-now").html()=="结束"){
  109 + // $("#class-now").unbind("click");
  110 + // }
125 111
126 -  
127 -  
128 - 112 + }
129 } 113 }
130 114
131 //在窗口关闭前提示用户 115 //在窗口关闭前提示用户
132 window.onbeforeunload = function() { 116 window.onbeforeunload = function() {
133 - if(client){  
134 - console.log("11111111111111111111111")  
135 - }else {  
136 - console.log("11111111111111111111111")  
137 - } 117 +
138 return false; // 可以阻止关闭 118 return false; // 可以阻止关闭
139 } 119 }
140 //窗口关闭,退出课堂 120 //窗口关闭,退出课堂
@@ -341,13 +321,13 @@ function uploadFile(msg){ @@ -341,13 +321,13 @@ function uploadFile(msg){
341 321
342 //监听文档更新 322 //监听文档更新
343 function docUpdate(callbackData){ 323 function docUpdate(callbackData){
344 -  
345 console.log("监听文档更新=========================>"); 324 console.log("监听文档更新=========================>");
346 console.log(callbackData); 325 console.log(callbackData);
347 if(callbackData==null){ 326 if(callbackData==null){
348 return; 327 return;
349 } 328 }
350 if (callbackData.visible===true){ 329 if (callbackData.visible===true){
  330 +
351 showInter(callbackData,2); 331 showInter(callbackData,2);
352 } 332 }
353 //操作数据 333 //操作数据
@@ -879,21 +859,9 @@ if (callbackData.userRole=="normal"){ @@ -879,21 +859,9 @@ if (callbackData.userRole=="normal"){
879 859
880 //准备主页面 860 //准备主页面
881 layoutView(); 861 layoutView();
882 - //开始课堂  
883 - startClass();  
884 } 862 }
885 863
886 -//开始课堂  
887 -function startClass() {  
888 - if(client){  
889 864
890 - //监听到聊天信息  
891 - client.on(MessageTypes.CHAT_RECEIVE,chatReceive);  
892 - client.on(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,whiteboardUpdate);//监听白板更新  
893 - client.on(MessageTypes.DOC_DELETE,docDelete);//监听删除文档  
894 - client.on(MessageTypes.DOC_UPDATE,docUpdate);//监听更新文档  
895 - }  
896 -}  
897 865
898 //登录成功后,登录页隐藏,主页面显示 866 //登录成功后,登录页隐藏,主页面显示
899 function layoutView( ) { 867 function layoutView( ) {
@@ -927,6 +895,9 @@ function layoutView( ) { @@ -927,6 +895,9 @@ function layoutView( ) {
927 895
928 896
929 897
  898 +
  899 +
  900 +
930 //发送聊天消息 901 //发送聊天消息
931 $("#btn_send").click(function (e) { 902 $("#btn_send").click(function (e) {
932 console.log("点击了发送消息按钮------->"); 903 console.log("点击了发送消息按钮------->");
@@ -941,6 +912,7 @@ function layoutView( ) { @@ -941,6 +912,7 @@ function layoutView( ) {
941 912
942 //点击下一页 913 //点击下一页
943 $("#nextPage").on("click",function (e) { 914 $("#nextPage").on("click",function (e) {
  915 + $(".spinner1").css("display","block");
944 console.log(curPageNum); 916 console.log(curPageNum);
945 917
946 var paramInfo={ 918 var paramInfo={
@@ -966,6 +938,7 @@ function layoutView( ) { @@ -966,6 +938,7 @@ function layoutView( ) {
966 938
967 //点击上一页 939 //点击上一页
968 $("#prevPage").on("click",function (e) { 940 $("#prevPage").on("click",function (e) {
  941 + $(".spinner1").css("display","block");
969 if (curPageNum>1){ 942 if (curPageNum>1){
970 console.log("curPageNum",curPageNum); 943 console.log("curPageNum",curPageNum);
971 for (var i=0;i<docfullPath.length;i++){ 944 for (var i=0;i<docfullPath.length;i++){
@@ -985,15 +958,32 @@ function layoutView( ) { @@ -985,15 +958,32 @@ function layoutView( ) {
985 958
986 }); 959 });
987 960
  961 +
  962 + //获取课堂信息
  963 + var classCurInfo=client.getClassStatusInfo();
  964 + $("#classCurName").html(classCurInfo.className);
  965 +
  966 + $("#classCurId").html(classAllInfo.nodeId);
  967 +
988 } 968 }
989 function whiteboardUpdate(callbackData) { 969 function whiteboardUpdate(callbackData) {
990 console.log("同步canvas消息"); 970 console.log("同步canvas消息");
991 console.log(callbackData); 971 console.log(callbackData);
992 draw.drawCanvas(callbackData); 972 draw.drawCanvas(callbackData);
993 $(".spinner").css("display","none"); 973 $(".spinner").css("display","none");
  974 + $(".spinner1").css("display","none");
994 $(".doc-headline-a").trigger("click"); 975 $(".doc-headline-a").trigger("click");
995 } 976 }
996 977
  978 +
  979 +// function updateClassTime(callbackData){
  980 +//
  981 +// }
  982 +//监听会议状态更新
  983 +function classUpdateStatus(callbackData) {
  984 + console.log(callbackData);
  985 +}
  986 +
997 //接收聊天消息 987 //接收聊天消息
998 function chatReceive(callbackData){ 988 function chatReceive(callbackData){
999 console.log(callbackData); 989 console.log(callbackData);
@@ -1071,8 +1061,6 @@ function loading() { @@ -1071,8 +1061,6 @@ function loading() {
1071 $(".permission").css("display","none"); 1061 $(".permission").css("display","none");
1072 $(".fourParams").css("display","none"); 1062 $(".fourParams").css("display","none");
1073 $(".loginBg").css("display","none"); 1063 $(".loginBg").css("display","none");
1074 -  
1075 -  
1076 } 1064 }
1077 1065
1078 //在页面loading时,提交验证,传给底层 1066 //在页面loading时,提交验证,传给底层
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 var client; //客户端 7 var client; //客户端
8 8
9 - 9 +var stuNodeId;
10 10
11 11
12 var videoWithFlash={}; 12 var videoWithFlash={};
@@ -17,7 +17,6 @@ videoWithFlash.flashInit=function (_client){ @@ -17,7 +17,6 @@ videoWithFlash.flashInit=function (_client){
17 client=_client; 17 client=_client;
18 18
19 }; 19 };
20 -  
21 function teaTimeStamp() { 20 function teaTimeStamp() {
22 var _teatimestamp= Date.parse(new Date()); 21 var _teatimestamp= Date.parse(new Date());
23 return _teatimestamp; 22 return _teatimestamp;
@@ -26,74 +25,122 @@ $(function () { @@ -26,74 +25,122 @@ $(function () {
26 25
27 //根据传进来的消息,创建老师NativeVideo窗口,进行播流 26 //根据传进来的消息,创建老师NativeVideo窗口,进行播流
28 client.on(MessageTypes.VIDEO_UPDATE,_videoUpdate); 27 client.on(MessageTypes.VIDEO_UPDATE,_videoUpdate);
  28 + client.on(MessageTypes.AUDIO_UPDATE,_audioUpdate)
  29 + client.on(MessageTypes.CLASS_INSERT_ROSTER,userListUpdate)
  30 + client.on(MessageTypes.VIDEO_BROADCAST,stuBroadcast)
  31 + client.on(MessageTypes.AUDIO_BROADCAST,stuAudioBroadcast)
  32 +
  33 +
  34 +
  35 + //学生视频按钮点击
  36 + $("#stuVideo-video").click(function (e) {
  37 + console.log("stuVideo-video点击");
  38 + $(".stuVideoBg").css("display","none");
  39 + $(".stuVideo-videoBg").css("display","block");
  40 + $(".stuVideo-video").css("display","none");
  41 + $(".studentVideo").css("background", "#CCCCCC");
  42 + $(".stuVideo-voice").css("bottom","4px");
  43 +
  44 + var paramInfo={
  45 + "actionType":1,
  46 + "toNodeId":stuNodeId,
  47 + "data":"0"
  48 + };
  49 + console.log("stuNodeId",stuNodeId);
  50 + client.sendVideoBroadcastMsg(paramInfo);
  51 + if (classAllInfo.userRole=="normal"){
  52 + $(".stuVideo-voice").css("display","none");
  53 + $(".stuVideo-video").css("display","none");
  54 + }
  55 +
  56 + });
  57 +
  58 + //学生视频关闭按钮点击
  59 + $("#stuVideo-videoBg").click(function (e) {
  60 +
  61 + var paramInfo={
  62 + "actionType":2,
  63 + "toNodeId":stuNodeId,
  64 + "data":"0"
  65 + };
  66 + client.sendVideoBroadcastMsg(paramInfo);
  67 + $("#stuVideo-video").css("display","block");
  68 + $("#stuVideo-videoBg").css("display","none");
  69 +
  70 +});
  71 +
  72 +
  73 + //学生音频按钮点击
  74 + $("#stuVideo-voice").click(function (e) {
  75 +
  76 + console.log("stuVideo-voice点击");
  77 + var stuVideoDisplay= $(".stuVideo-videoBg").css("display");
  78 + if(stuVideoDisplay=="block"){
  79 + $("#stuVideo-videoBg").trigger("click");
  80 + }
  81 + $("#stuVideo-voice").css("display","none");
  82 + $("#stuVideo-voiceBg").css("display","block");
  83 + $(".stuPublish").css("display","none");
  84 + $(".studentVideoBg").css("display","none");
  85 +
  86 + var paramInfo={
  87 + "actionType":1,
  88 + "toNodeId":stuNodeId,
  89 + "data":"0"
  90 + };
  91 + console.log("stuNodeId",stuNodeId);
  92 + client.sendAudioBroadcastMsg(paramInfo);
  93 + if (classAllInfo.userRole=="normal"){
  94 + $(".stuVideo-voice").css("display","none");
  95 + $(".stuVideo-video").css("display","none");
  96 + }
  97 +
  98 +
  99 + });
  100 +
  101 +
  102 + //学生音频关闭按钮点击
  103 + $("#stuVideo-voiceBg").click(function(e){
  104 + var paramInfo={
  105 + "actionType":2,
  106 + "toNodeId":stuNodeId,
  107 + "data":"0"
  108 + };
  109 + client.sendAudioBroadcastMsg(paramInfo);
  110 + $("#stuVideo-voice").css("display","block");
  111 + $("#stuVideo-voiceBg").css("display","none");
  112 + if (classAllInfo.userRole=="normal"){
  113 + $(".stuVideo-voice").css("display","none");
  114 + $(".stuVideo-video").css("display","none");
  115 + }
  116 +
  117 + });
29 118
30 - // //学生视频按钮点击  
31 - // $("#stuVideo-video").click(function (e) {  
32 - // console.log("teacherVideo-video点击");  
33 - // $("#stuVideo-video").html(" ");  
34 - // $("#stuVideo-video").removeClass("stuVideo-video");  
35 - // $("#stuVideo-video").addClass("stuVideo-videoBg");  
36 - //  
37 - //  
38 - // $("#stuVideo-voice").html("&#xe62d;");  
39 - // $("#stuVideo-voice").addClass("stuVideo-voice");  
40 - // $("#stuVideo-voice").removeClass("stuVideo-voiceBg");  
41 - //  
42 - //  
43 - // //获取推流地址  
44 - // achieveStupPushStream();  
45 - //  
46 - //  
47 - // });  
48 - //  
49 - // //学生音频按钮点击  
50 - // $("#stuVideo-voice").click(function (e) {  
51 - //  
52 - // console.log("stuVideo-voice点击");  
53 - // $("#stuVideo-video").html("&#xe62e;");  
54 - // $("#stuVideo-video").removeClass("stuVideo-videoBg");  
55 - // $("#stuVideo-video").addClass("stuVideo-video");  
56 - //  
57 - // $("#stuVideo-voice").html("");  
58 - // $("#stuVideo-voice").removeClass("stuVideo-voice");  
59 - // $("#stuVideo-voice").addClass("stuVideo-voiceBg");  
60 - // });  
61 119
62 //老师视频按钮点击 120 //老师视频按钮点击
63 $("#teacherVideo-video").click(function (e) { 121 $("#teacherVideo-video").click(function (e) {
64 console.log("teacherVideo-video点击"); 122 console.log("teacherVideo-video点击");
65 - $("#teacherVideo-video").html(" ");  
66 - // $("#teacherVideo-video").removeClass("teacherVideo-video");  
67 - // $("#teacherVideo-video").addClass("teacherVideo-videoBg");  
68 - $(".teacherVideo-videoBg").css("display","block");  
69 - $(".teacherVideo-video").css("display","none");  
70 - 123 + var teaVoiceDisplay= $(".teacherVideo-voiceBg").css("display");
  124 + if(teaVoiceDisplay=="block"){
  125 + $("#teacherVideo-voiceBg").trigger("click");
  126 + }
71 127
72 128
  129 + $(".teacherVideo-videoBg").css("display","block");
  130 + $(".teacherVideo-video").css("display","none");
73 $("#teacherVideo-voice").html("&#xe62d;"); 131 $("#teacherVideo-voice").html("&#xe62d;");
74 $("#teacherVideo-voice").addClass("teacherVideo-voice"); 132 $("#teacherVideo-voice").addClass("teacherVideo-voice");
75 $("#teacherVideo-voice").removeClass("teacherVideo-voiceBg"); 133 $("#teacherVideo-voice").removeClass("teacherVideo-voiceBg");
76 $(".teacherVideoBg").css("display","none"); 134 $(".teacherVideoBg").css("display","none");
77 $(".teacherVideo").css("background", "#CCCCCC"); 135 $(".teacherVideo").css("background", "#CCCCCC");
78 $(".teacherVideo-voice").css("bottom","4px"); 136 $(".teacherVideo-voice").css("bottom","4px");
  137 + $(".teacherVoicing").css("display","none");
79 138
80 //获取推流地址 139 //获取推流地址
81 achieveTeaStream(); 140 achieveTeaStream();
82 141
83 }); 142 });
84 143
85 - //老师音频按钮点击  
86 - $(".teacherVideo-voice").click(function (e) {  
87 - console.log("teacherVideo-voice点击");  
88 - $("#teacherVideo-video").html("&#xe62e;");  
89 - $("#teacherVideo-video").removeClass("teacherVideo-videoBg");  
90 - $("#teacherVideo-video").addClass("teacherVideo-video");  
91 -  
92 - $("#teacherVideo-voice").html("");  
93 - $("#teacherVideo-voice").removeClass("teacherVideo-voice");  
94 - $("#teacherVideo-voice").addClass("teacherVideo-voiceBg");  
95 - });  
96 -  
97 //老师视频关闭按钮点击 144 //老师视频关闭按钮点击
98 $("#teacherVideo-videoBg").click(function (e) { 145 $("#teacherVideo-videoBg").click(function (e) {
99 if(window.publishflash) { 146 if(window.publishflash) {
@@ -101,12 +148,14 @@ $(function () { @@ -101,12 +148,14 @@ $(function () {
101 type: 5, 148 type: 5,
102 videoId: publishflashVideoId, 149 videoId: publishflashVideoId,
103 }); 150 });
  151 + console.log("publishflashVideoId",publishflashVideoId);
104 console.log(publishflash._js2native(stopInfo)); 152 console.log(publishflash._js2native(stopInfo));
105 } 153 }
106 154
107 var paramInfo={ 155 var paramInfo={
108 "nodeId": Number(classAllInfo.nodeId)//用户的nodeId 156 "nodeId": Number(classAllInfo.nodeId)//用户的nodeId
109 }; 157 };
  158 + console.log(classAllInfo.nodeId);
110 client.stopPublishVideo(paramInfo); 159 client.stopPublishVideo(paramInfo);
111 160
112 $(".publish").css("display","none"); 161 $(".publish").css("display","none");
@@ -114,35 +163,535 @@ $(function () { @@ -114,35 +163,535 @@ $(function () {
114 $(".teacherVideoBg").css("display","block"); 163 $(".teacherVideoBg").css("display","block");
115 $("#teacherVideo-video").css("display","block"); 164 $("#teacherVideo-video").css("display","block");
116 $("#teacherVideo-videoBg").css("display","none"); 165 $("#teacherVideo-videoBg").css("display","none");
  166 + });
  167 +
  168 + //老师音频按钮点击
  169 + $("#teacherVideo-voice").click(function (e) {
  170 + console.log("teacherVideo-voice点击");
  171 + var teaVideoDisplay= $(".teacherVideo-videoBg").css("display");
  172 + if(teaVideoDisplay=="block"){
  173 + $("#teacherVideo-videoBg").trigger("click");
  174 + }
  175 + $("#teacherVideo-voice").css("display","none");
  176 + $("#teacherVideo-voiceBg").css("display","block");
  177 + $(".publish").css("display","none");
  178 + $(".teacherVideoBg").css("display","none");
  179 +
  180 + // /获取老师只推音频地址
  181 + achieveTeaVoice();
  182 +
  183 + });
  184 +
  185 + //老师音频关闭按钮点击
  186 + $("#teacherVideo-voiceBg").click(function (e) {
  187 + console.log("teacherVideo-voice点击");
  188 + $(".publish").css("display","none");
  189 + $(".teacherVideo").css("background", "#f5f9fb");
  190 + $(".teacherVoicing").css("display","none");
  191 + $(".teacherVideo-voiceBg").css("display","none");
  192 + $(".teacherVideo-voice").css("display","block");
117 193
  194 + var paramInfo={
  195 + "nodeId": Number(classAllInfo.nodeId)//用户的nodeId
  196 + };
  197 + client.stopPublishAudio(paramInfo);
118 198
119 199
  200 + if(window.publishflashVoice) {
  201 + const stopTeaInfo = JSON.stringify({
  202 + type: 5,
  203 + videoId: publishflashVoiceId,
  204 + });
  205 + console.log(publishflashVoice._js2native(stopTeaInfo));
  206 + }
120 207
121 208
122 209
  210 + $(".publish").css("display","none");
  211 + $(".teacherVideo").css("background", "#f5f9fb");
  212 + $(".teacherVideoBg").css("display","block");
  213 + $("#teacherVideo-video").css("display","block");
  214 + $("#teacherVideo-videoBg").css("display","none");
  215 + $("#teacherVideo-voice").css("display","block");
  216 + $("#teacherVideo-voiceBg").css("display","none");
  217 +
  218 +
123 }); 219 });
124 220
  221 +
125 }); 222 });
  223 +//监听学生视频更新
  224 +function stuBroadcast(callbackDate){
  225 + if (callbackDate.actionType==1){
  226 + $(".stuVideoBg").css("display","none");
  227 + if(classAllInfo.userRole=="normal"){
  228 + //获取推流地址
  229 + achieveStuPushStream();
  230 + }
  231 + }
  232 + if(callbackDate.actionType==2){
  233 + if(window.publishStuflash) {
  234 + const stopStuInfo = JSON.stringify({
  235 + type: 5,
  236 + videoId: publishflashStuVideoId,
  237 + });
  238 + console.log(publishStuflash._js2native(stopStuInfo));
  239 + }
126 240
127 - //获取推流地址  
128 - function achieveTeaStream(){  
129 - $(".publish").css("display","block");  
130 - $(".play").css("display","none"); 241 + var paramInfo={
  242 + "nodeId": Number(stuNodeId)//用户的nodeId
  243 + };
  244 + client.stopPublishVideo(paramInfo);
  245 + $(".stuPlay").css("display","none");
  246 + $(".stuPublish").css("display","none");
  247 + $(".studentVideo").css("background", "#f5f9fb");
  248 + $(".stuVideoBg").css("display","block");
  249 + $("#stuVideo-voice").css("display","block");
  250 + $("#stuVideo-voiceBg").css("display","none");
  251 +
  252 + if (classAllInfo.userRole=="normal"){
  253 + $(".stuVideo-video").css("display","none");
  254 + }
  255 + }
  256 +
  257 +
  258 +
  259 +}
131 260
  261 +//监听学生音频更新
  262 +function stuAudioBroadcast(callbackDate){
  263 + if (callbackDate.actionType==1){
  264 + $(".stuVideoBg").css("display","none");
  265 + $(".stuPlay").css("display","none");
  266 + if(classAllInfo.userRole=="normal"){
  267 + //获取学生只推音频地址
  268 + achieveStuVoice();
  269 + }
  270 + }
  271 + if(callbackDate.actionType==2){
  272 + if(window.publishflashStuVoice) {
  273 + const stopStuInfo = JSON.stringify({
  274 + type: 5,
  275 + videoId: publishflashStuVoiceId,
  276 + });
  277 + console.log(publishflashStuVoice._js2native(stopStuInfo));
  278 + }
132 279
133 var paramInfo={ 280 var paramInfo={
134 - "type": "flash" 281 + "nodeId": Number(stuNodeId)//用户的nodeId
135 }; 282 };
136 - var pubResult=client.getVideoPublishPath(paramInfo); 283 + client.stopPublishAudio(paramInfo);
  284 +
  285 + $(".stuPlay").css("display","none");
  286 + $(".stuPublish").css("display","none");
  287 + $(".studentVideo").css("background", "#f5f9fb");
  288 + $(".stuVideoBg").css("display","block");
  289 + $("#stuVideo-video").css("display","block");
  290 + $("#stuVideo-videoBg").css("display","none");
  291 +
  292 + if (classAllInfo.userRole=="normal"){
  293 + $(".stuVideo-voice").css("display","none");
  294 + $(".stuVideo-video").css("display","none");
  295 + }
  296 + }
  297 +}
  298 +
  299 +
  300 +//人员进入
  301 +function userListUpdate(callbackData) {
  302 +
  303 + console.log("人员进入",callbackData);
  304 + if (classAllInfo.nodeId==callbackData.nodeId){
  305 +
  306 + }else{
  307 + console.log("callbackData.nodeId================>",callbackData.nodeId)
  308 + stuNodeId=callbackData.nodeId;
  309 + }
  310 +
  311 +
  312 +}
  313 +
  314 +// 监听当前是否有视频流更新
  315 +function _videoUpdate(callbackDate){
  316 +
  317 + console.log("videoUpdate==============>",callbackDate);
  318 +
  319 + // alert((classAllInfo.userRole=="host")&&(callbackDate.status==1)&&(callbackDate.fromNodeId==stuNodeId));
  320 +
  321 + if((classAllInfo.userRole=="host")&&(callbackDate.status==1)&&(callbackDate.fromNodeId==stuNodeId)){
  322 + //获取学生播流地址
  323 + achieveStuPlayStream(callbackDate);
  324 +
  325 + $(".teacherVideo").css("background","#f5f9fb");
  326 + $(".teacherVideoBg").css("display","block");
  327 +
  328 + }
  329 +
  330 +
  331 +
  332 + if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
  333 +
  334 + achievePlayStream(callbackDate);
  335 +
  336 + }
  337 +
  338 + //流的状态为0
  339 +
  340 + if(callbackDate.status==0){
  341 +
  342 + console.log("callbackDate.fromNodeId,stuNodeId");
  343 + console.log(callbackDate.fromNodeId,stuNodeId);
  344 + if(callbackDate.fromNodeId==stuNodeId){
  345 + if (classAllInfo.userRole=="normal"){
  346 + // $(".play").css("display","none");
  347 + }
  348 +
  349 + // $(".play").css("display","none");
  350 + $(".teacherVideoBg").css("display","block");
  351 + $(".teacherVideo").css("background", "#f5f9fb");
  352 + if(window.playflash){
  353 + console.log("playflashVideoId",playflashVideoId);
  354 + const stopPlayInfo = JSON.stringify({
  355 + type: 5,
  356 + videoId: playflashVideoId
  357 + });
  358 + console.log(playflash._js2native(stopPlayInfo));
  359 + }
  360 + }
  361 + }
  362 +
  363 +}
  364 +// 监听当前是否有音频流更新
  365 +function _audioUpdate(callbackDate){
  366 +
  367 + if((classAllInfo.userRole=="host")&&(callbackDate.status==1)&&(callbackDate.fromNodeId==stuNodeId)){
  368 + //获取学生播流地址
  369 + achieveStuPlayStream(callbackDate);
  370 + $(".stuPlay").css("display","block");
  371 +
  372 + $(".teacherVideo").css("background","#f5f9fb");
  373 + $(".teacherVideoBg").css("display","block");
  374 +
  375 + }
  376 +
  377 +
  378 + if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
  379 + achievePlayVoiceStream(callbackDate);
  380 +
  381 + }
  382 + if(callbackDate.status==0){
  383 + $(".teacherVideoBg").css("display","block");
  384 + $(".teacherVideo").css("background", "#f5f9fb");
  385 + if(window.playflashVoice) {
  386 + console.log("playflashVoiceId", playflashVoiceId);
  387 +
  388 + if (callbackDate.fromNodeId == stuNodeId) {
  389 + if (classAllInfo.userRole=="normal"){
  390 + $(".play").css("display","none");
  391 + }
  392 + const stopPlayInfo = JSON.stringify({
  393 + type: 5,
  394 + videoId: playflashVoiceId
  395 + });
  396 + console.log(playflashVoice._js2native(stopPlayInfo));
  397 + }
  398 + }
  399 + }
  400 +
  401 +
  402 +
  403 +}
  404 +
  405 +// //获取学生推流地址
  406 +function achieveStuPushStream() {
  407 + $(".stuPublish").css("display","block");
  408 + $(".stuPlay").css("display","none");
  409 + var paramInfo={
  410 + "type": "flash"
  411 + };
  412 + var pubStuResult=client.getVideoPublishPath(paramInfo);
  413 +
  414 + console.log("执行getPublishVideoPath,返回的结果",pubStuResult);
  415 +
  416 + //code为0,代表成功
  417 + if (pubStuResult.code==0){
  418 + if(! window.publishStuflash) {
  419 + flashvideo(
  420 + 'stuPublish',
  421 + '100%',
  422 + '100%',
  423 + function (error, publishflash) {
  424 + if (error) {
  425 + return console.error(error);
  426 + }
  427 + window.publishStuflash = publishflash;
  428 + window.publishflashStuVideoId = teaTimeStamp();
  429 +
  430 + publishStuURL(pubStuResult.publishUrl);
  431 + },
  432 + function (msg) {
  433 +
  434 + console.log(' [stuPublish] native 2 js', msg);
  435 + var _msg=JSON.parse(msg);
  436 + console.log("_msg===========>",_msg);
  437 + if(_msg.data.result == 0){
  438 + //将之前底层取的推流结果传递给底层
  439 + var _successErrorResult= client.publishVideo(pubStuResult);
  440 + console.log("_successErrorResult======>",_successErrorResult)
  441 + if(_successErrorResult.code==0){
  442 + console.log("底层广播推流成功");
  443 +
  444 + } else if(_successErrorResult.code==1){
  445 + console.log("底层广播推流失败,关闭推流");
  446 + }
  447 +
  448 + }else {
  449 + console.error('stuPublish error');
  450 + }
  451 + }
  452 + )
  453 +
  454 + }
  455 + else {
  456 + publishStuURL(pubStuResult.publishUrl);
  457 + }
  458 +
  459 + }else if(pubStuResult.code==1){
  460 +
  461 + }
  462 +}
  463 +
  464 +function publishStuURL(rtmpStuURL){
  465 + const msg = JSON.stringify({
  466 + type: 10,
  467 + videoId: publishflashStuVideoId,
  468 + data: {
  469 + video:true,
  470 + audio:true,
  471 + url: rtmpStuURL
  472 + }
  473 + });
  474 + console.log(publishStuflash._js2native(msg));
  475 +}
  476 +
  477 +//获取学生播流地址
  478 +function achieveStuPlayStream(_pubResultObj) {
  479 + console.log("_pubResultObj==========>",_pubResultObj)
  480 + var _paramInfo={
  481 + "type": "rtmp",
  482 + "channelId": _pubResultObj.channelId,//频道号
  483 + "classId": _pubResultObj.classId,//课堂号
  484 + "siteId": _pubResultObj.siteId,//站点号
  485 + "timestamp":_pubResultObj.timestamp,//时间戳
  486 + "userId": _pubResultObj.userId,//userId
  487 + };
  488 + var streamInfo=client.getVideoPlayPath(_paramInfo);
  489 + console.log("result是=============>",streamInfo);
  490 + // $(".play").css("display","block");
  491 + $(".teacherVideoBg").css("display","none");
  492 + $(".teacherVideo").css("background", "#CCCCCC");
  493 + $(".teacherVideo-voice").css("bottom","4px");
  494 +
  495 + if(! window.playflashStu) {
  496 + flashvideo(
  497 + 'stuPlay',
  498 + '100%',
  499 + '100%',
  500 + function createPlayReady(error, playflash) {
  501 + if (error) {
  502 + return console.error(error);
  503 + }
  504 + window.playflashStu = playflash;
  505 + window.playflashStuVideoId = teaTimeStamp();
  506 +
  507 + playStuURL(streamInfo.playUrl);
  508 + },
  509 + function (msg) {
  510 + console.log(' [play] native 2 js', msg);
  511 + }
  512 + )
  513 + }
  514 + else {
  515 + playStuURL(streamInfo.playUrl);
  516 + }
  517 +
  518 +
  519 +}
  520 +
  521 +function playStuURL(rtmpURL){
  522 + const msg = JSON.stringify({
  523 + type: 2,
  524 + videoId: playflashStuVideoId,
  525 + data: {
  526 + url: rtmpURL
  527 + // url:'rtmp://123.56.205.116:1935/live/alexwang'
  528 + }
  529 + });
  530 + console.log(playflashStu._js2native(msg));
  531 +}
  532 +
  533 +//获取学生只推音频
  534 +function achieveStuVoice() {
  535 +
  536 + var paramInfo={
  537 + "type": "flash"
  538 + };
  539 + var pubResult=client.getAudioPublishPath(paramInfo);
  540 + console.log("执行getAudioPublishPath,返回的结果",pubResult);
  541 +
  542 + //code为0,代表成功
  543 + if (pubResult.code==0){
  544 + if(! window.publishflashStuVoice) {
  545 + flashvideo(
  546 + 'stuPublish',
  547 + '100%',
  548 + '100%',
  549 + function (error, publishflash) {
  550 + if (error) {
  551 + return console.error(error);
  552 + }
  553 + window.publishflashStuVoice = publishflash;
  554 + window.publishflashStuVoiceId = teaTimeStamp();
  555 +
  556 + publishStuVoiceURL(pubResult.publishUrl);
  557 + },
  558 + function (msg) {
  559 +
  560 + console.log(' [publish] native 2 js', msg);
  561 + var _msg=JSON.parse(msg);
  562 + console.log("_msg===========>",_msg);
  563 + if(_msg.data.result == 0){
  564 +
  565 + //将之前底层取的推流结果传递给底层
  566 + var _successErrorResult= client.publishAudio(pubResult);
  567 + console.log("_successErrorResult======>",_successErrorResult)
  568 + if(_successErrorResult.code==0){
  569 + console.log("底层广播推流成功");
  570 +
  571 + } else if(_successErrorResult.code==1){
  572 + console.log("底层广播推流失败,关闭推流");
  573 + }
  574 +
  575 + }else {
  576 + console.error('publish error');
  577 + }
  578 + }
  579 + )
  580 +
  581 + }
  582 + else {
  583 + publishStuVoiceURL(pubResult.publishUrl);
  584 + }
  585 +
  586 + }else if(pubResult.code==1){
  587 +
  588 + }
  589 +
  590 +}
  591 +function publishStuVoiceURL(rtmpURL) {
  592 + const msg = JSON.stringify({
  593 + type: 10,
  594 + videoId: publishflashStuVoiceId,
  595 + data: {
  596 + video:false,
  597 + audio:true,
  598 + url: rtmpURL
  599 + }
  600 + });
  601 + console.log(publishflashStuVoice._js2native(msg));
  602 +}
137 603
138 - console.log("执行getPublishVideoPath,返回的结果",pubResult);  
139 604
140 605
  606 +//获取老师只推音频
  607 +function achieveTeaVoice() {
  608 + $(".publish").css("display","block");
  609 + $(".play").css("display","none");
  610 + var paramInfo={
  611 + "type": "flash"
  612 + };
  613 + var pubResult=client.getAudioPublishPath(paramInfo);
  614 + console.log("执行getAudioPublishPath,返回的结果",pubResult);
  615 +
  616 + //code为0,代表成功
  617 + if (pubResult.code==0){
  618 + if(! window.publishflashVoice) {
  619 + flashvideo(
  620 + 'publish',
  621 + '100%',
  622 + '100%',
  623 + function (error, publishflash) {
  624 + if (error) {
  625 + return console.error(error);
  626 + }
  627 + window.publishflashVoice = publishflash;
  628 + window.publishflashVoiceId = teaTimeStamp();
  629 +
  630 + publishTeaVoiceURL(pubResult.publishUrl);
  631 + },
  632 + function (msg) {
  633 +
  634 + console.log(' [publish] native 2 js', msg);
  635 + var _msg=JSON.parse(msg);
  636 + console.log("_msg===========>",_msg);
  637 + if(_msg.data.result == 0){
  638 +
  639 + //将之前底层取的推流结果传递给底层
  640 + var _successErrorResult= client.publishAudio(pubResult);
  641 + console.log("_successErrorResult======>",_successErrorResult)
  642 + if(_successErrorResult.code==0){
  643 + console.log("底层广播推流成功");
  644 +
  645 + } else if(_successErrorResult.code==1){
  646 + console.log("底层广播推流失败,关闭推流");
  647 + }
  648 +
  649 + }else {
  650 + console.error('publish error');
  651 + }
  652 + }
  653 + )
  654 +
  655 + }
  656 + else {
  657 + publishTeaVoiceURL(pubResult.publishUrl);
  658 + }
  659 +
  660 + }else if(pubResult.code==1){
  661 +
  662 + }
141 663
142 664
  665 +}
  666 +
  667 +function publishTeaVoiceURL(rtmpURL) {
  668 + const msg = JSON.stringify({
  669 + type: 10,
  670 + videoId: publishflashVoiceId,
  671 + data: {
  672 + video:false,
  673 + audio:true,
  674 + url: rtmpURL
  675 + }
  676 + });
  677 + console.log(publishflashVoice._js2native(msg));
  678 +}
  679 +
  680 +
  681 + //获取老师推流音视频地址
  682 +function achieveTeaStream(){
  683 + $(".publish").css("display","block");
  684 + $(".play").css("display","none");
  685 + var paramInfo={
  686 + "type": "flash"
  687 + };
  688 + var pubResult=client.getVideoPublishPath(paramInfo);
  689 + console.log("执行getPublishVideoPath,返回的结果",pubResult);
  690 +
143 //code为0,代表成功 691 //code为0,代表成功
144 if (pubResult.code==0){ 692 if (pubResult.code==0){
145 if(! window.publishflash) { 693 if(! window.publishflash) {
  694 + console.log("if==================>");
146 flashvideo( 695 flashvideo(
147 'publish', 696 'publish',
148 '100%', 697 '100%',
@@ -157,7 +706,6 @@ $(function () { @@ -157,7 +706,6 @@ $(function () {
157 publishURL(pubResult.publishUrl); 706 publishURL(pubResult.publishUrl);
158 }, 707 },
159 function (msg) { 708 function (msg) {
160 -  
161 console.log(' [publish] native 2 js', msg); 709 console.log(' [publish] native 2 js', msg);
162 var _msg=JSON.parse(msg); 710 var _msg=JSON.parse(msg);
163 console.log("_msg===========>",_msg); 711 console.log("_msg===========>",_msg);
@@ -169,71 +717,98 @@ $(function () { @@ -169,71 +717,98 @@ $(function () {
169 console.log("底层广播推流成功"); 717 console.log("底层广播推流成功");
170 } else if(_successErrorResult.code==1){ 718 } else if(_successErrorResult.code==1){
171 console.log("底层广播推流失败,关闭推流"); 719 console.log("底层广播推流失败,关闭推流");
172 -  
173 } 720 }
174 721
175 }else { 722 }else {
176 console.error('publish error'); 723 console.error('publish error');
177 -  
178 -  
179 -  
180 } 724 }
181 } 725 }
182 ) 726 )
183 -  
184 } 727 }
185 else { 728 else {
  729 + console.log("else=============>");
186 publishURL(pubResult.publishUrl); 730 publishURL(pubResult.publishUrl);
187 } 731 }
188 732
189 }else if(pubResult.code==1){ 733 }else if(pubResult.code==1){
190 734
  735 + console.log("pubResult.code==1");
191 } 736 }
192 } 737 }
  738 + //推音视频 js2native
193 function publishURL(rtmpURL) { 739 function publishURL(rtmpURL) {
194 const msg = JSON.stringify({ 740 const msg = JSON.stringify({
195 type: 10, 741 type: 10,
196 videoId: publishflashVideoId, 742 videoId: publishflashVideoId,
197 data: { 743 data: {
  744 + video:true,
  745 + audio:true,
198 url: rtmpURL 746 url: rtmpURL
199 } 747 }
200 }); 748 });
  749 + console.log("publishflashVideoId======>",publishflashVideoId);
  750 + console.log(publishflash);
201 console.log(publishflash._js2native(msg)); 751 console.log(publishflash._js2native(msg));
202 } 752 }
203 753
204 - // 监听当前是否有视频流更新  
205 - function _videoUpdate(callbackDate){  
206 - playCallbackDate=callbackDate;  
207 - console.log("videoUpdate==============>",playCallbackDate);  
208 -  
209 -  
210 - if ((callbackDate.status==1)&&(callbackDate.channelId!=='')){  
211 -  
212 - achievePlayStream(playCallbackDate); 754 + //获取播放音频地址
  755 +function achievePlayVoiceStream(_pubResultObj){
  756 +
  757 + console.log("_pubResultObj==========>",_pubResultObj)
  758 + var _paramInfo={
  759 + "type": "rtmp",
  760 + "channelId": _pubResultObj.channelId,//频道号
  761 + "classId": _pubResultObj.classId,//课堂号
  762 + "siteId": _pubResultObj.siteId,//站点号
  763 + "timestamp":_pubResultObj.timestamp,//时间戳
  764 + "userId": _pubResultObj.userId,//userId
  765 + };
  766 + var streamInfo=client.getAudioPlayPath(_paramInfo);
  767 + console.log("result是=============>",streamInfo);
  768 + $(".play").css("display","block");
  769 + $(".teacherVideoBg").css("display","none");
  770 + $(".teacherVideo").css("background", "#CCCCCC");
  771 + $(".teacherVideo-voice").css("bottom","4px");
  772 +
  773 + if(! window.playflashVoice) {
  774 + flashvideo(
  775 + 'play',
  776 + '100%',
  777 + '100%',
  778 + function createPlayReady(error, playflash) {
  779 + if (error) {
  780 + return console.error(error);
  781 + }
  782 + window.playflashVoice = playflash;
  783 + window.playflashVoiceId = teaTimeStamp();
213 784
  785 + playVoiceURL(streamInfo.playUrl);
  786 + },
  787 + function (msg) {
  788 + console.log(' [play] native 2 js', msg);
  789 + }
  790 + )
  791 + }
  792 + else {
  793 + playVoiceURL(streamInfo.playUrl);
214 } 794 }
215 - if(callbackDate.status==0){  
216 - if(window.playflash){  
217 - console.log("playflashVideoId",playflashVideoId);  
218 - const stopPlayInfo = JSON.stringify({  
219 - type: 5,  
220 - videoId: playflashVideoId  
221 - });  
222 - console.log(playflash._js2native(stopPlayInfo));  
223 - }  
224 - $("#teacherVideo-videoBg").css("display","none");  
225 - $("#teacherVideo-video").html("&#xe62e;");  
226 - $(".play").css("display","none");  
227 - $(".teacherVideo").css("background", "#f5f9fb");  
228 - $(".teacherVideoBg").css("display","block");  
229 -  
230 795
231 796
232 - } 797 +}
233 798
  799 +function playVoiceURL(rtmpURL){
  800 + const msg = JSON.stringify({
  801 + type: 2,
  802 + videoId: playflashVoiceId,
  803 + data: {
  804 + url: rtmpURL
  805 + // url:'rtmp://123.56.205.116:1935/live/alexwang'
  806 + }
  807 + });
  808 + console.log(playflashVoice._js2native(msg));
234 } 809 }
235 810
236 - //获取播流地址 811 + //获取音视频播流地址
237 function achievePlayStream(_pubResultObj){ 812 function achievePlayStream(_pubResultObj){
238 console.log("_pubResultObj==========>",_pubResultObj) 813 console.log("_pubResultObj==========>",_pubResultObj)
239 var _paramInfo={ 814 var _paramInfo={
@@ -246,9 +821,8 @@ function publishURL(rtmpURL) { @@ -246,9 +821,8 @@ function publishURL(rtmpURL) {
246 }; 821 };
247 var streamInfo=client.getVideoPlayPath(_paramInfo); 822 var streamInfo=client.getVideoPlayPath(_paramInfo);
248 console.log("result是=============>",streamInfo); 823 console.log("result是=============>",streamInfo);
249 - $(".play").css("display","block"); 824 + // $(".play").css("display","block");
250 $(".teacherVideoBg").css("display","none"); 825 $(".teacherVideoBg").css("display","none");
251 -  
252 $(".teacherVideo").css("background", "#CCCCCC"); 826 $(".teacherVideo").css("background", "#CCCCCC");
253 $(".teacherVideo-voice").css("bottom","4px"); 827 $(".teacherVideo-voice").css("bottom","4px");
254 828
@@ -285,6 +859,7 @@ function publishURL(rtmpURL) { @@ -285,6 +859,7 @@ function publishURL(rtmpURL) {
285 // url:'rtmp://123.56.205.116:1935/live/alexwang' 859 // url:'rtmp://123.56.205.116:1935/live/alexwang'
286 } 860 }
287 }); 861 });
  862 +
288 console.log(playflash._js2native(msg)); 863 console.log(playflash._js2native(msg));
289 } 864 }
290 865