张桐

老师多次开关自己音视频OK 学生正常播放

@@ -590,7 +590,7 @@ @@ -590,7 +590,7 @@
590 590
591 <div class="fourParamsOut"> 591 <div class="fourParamsOut">
592 <ul class="fourParams clear"> 592 <ul class="fourParams clear">
593 - <li><span>classId:</span><input class="classId" type="text" value="120394398"></li> 593 + <li><span>classId:</span><input class="classId" type="text" value="1154006572"></li>
594 <!--<li><span>userRole:</span><input class="userRole" type="text" value=""></li>--> 594 <!--<li><span>userRole:</span><input class="userRole" type="text" value=""></li>-->
595 <!--<li><span>portal:</span><input class="portal" type="text" value=""></li>--> 595 <!--<li><span>portal:</span><input class="portal" type="text" value=""></li>-->
596 <li><span>userId:</span><input class="userId" type="text" value=""></li> 596 <li><span>userId:</span><input class="userId" type="text" value=""></li>
@@ -8,9 +8,14 @@ var client; //客户端 @@ -8,9 +8,14 @@ var client; //客户端
8 8
9 var stuNodeId; 9 var stuNodeId;
10 10
11 -  
12 var videoWithFlash={}; 11 var videoWithFlash={};
13 12
  13 +
  14 +var pushTeaResult; //推老师音视频结果
  15 +
  16 +var pushTeaAudioResult; //推老师音频结果
  17 +
  18 +
14 window.videoWithFlash=videoWithFlash; 19 window.videoWithFlash=videoWithFlash;
15 20
16 videoWithFlash.flashInit=function (_client){ 21 videoWithFlash.flashInit=function (_client){
@@ -124,8 +129,7 @@ $(function () { @@ -124,8 +129,7 @@ $(function () {
124 if(teaVoiceDisplay=="block"){ 129 if(teaVoiceDisplay=="block"){
125 $("#teacherVideo-voiceBg").trigger("click"); 130 $("#teacherVideo-voiceBg").trigger("click");
126 } 131 }
127 -  
128 - 132 + if (classAllInfo.userRole=="host"){
129 $(".teacherVideo-videoBg").css("display","block"); 133 $(".teacherVideo-videoBg").css("display","block");
130 $(".teacherVideo-video").css("display","none"); 134 $(".teacherVideo-video").css("display","none");
131 $("#teacherVideo-voice").html("&#xe62d;"); 135 $("#teacherVideo-voice").html("&#xe62d;");
@@ -135,9 +139,10 @@ $(function () { @@ -135,9 +139,10 @@ $(function () {
135 $(".teacherVideo").css("background", "#CCCCCC"); 139 $(".teacherVideo").css("background", "#CCCCCC");
136 $(".teacherVideo-voice").css("bottom","4px"); 140 $(".teacherVideo-voice").css("bottom","4px");
137 $(".teacherVoicing").css("display","none"); 141 $(".teacherVoicing").css("display","none");
  142 + }
138 143
139 //获取推流地址 144 //获取推流地址
140 - achieveTeaStream(); 145 + achieveTeaVideoStream();
141 146
142 }); 147 });
143 148
@@ -148,7 +153,6 @@ $(function () { @@ -148,7 +153,6 @@ $(function () {
148 type: 5, 153 type: 5,
149 videoId: publishflashVideoId, 154 videoId: publishflashVideoId,
150 }); 155 });
151 - console.log("publishflashVideoId",publishflashVideoId);  
152 console.log(publishflash._js2native(stopInfo)); 156 console.log(publishflash._js2native(stopInfo));
153 } 157 }
154 158
@@ -158,11 +162,20 @@ $(function () { @@ -158,11 +162,20 @@ $(function () {
158 console.log(classAllInfo.nodeId); 162 console.log(classAllInfo.nodeId);
159 client.stopPublishVideo(paramInfo); 163 client.stopPublishVideo(paramInfo);
160 164
161 - $(".publish").css("display","none"); 165 + if (classAllInfo.userRole=="host"){
  166 + $(".publish").css({"width":"1px","height":"1px"});
162 $(".teacherVideo").css("background", "#f5f9fb"); 167 $(".teacherVideo").css("background", "#f5f9fb");
163 $(".teacherVideoBg").css("display","block"); 168 $(".teacherVideoBg").css("display","block");
164 $("#teacherVideo-video").css("display","block"); 169 $("#teacherVideo-video").css("display","block");
165 $("#teacherVideo-videoBg").css("display","none"); 170 $("#teacherVideo-videoBg").css("display","none");
  171 + }
  172 + if (classAllInfo.userRole=="normal"){
  173 + $(".play").css({"width":"1px","height":"1px"});
  174 + }
  175 +
  176 +
  177 +
  178 +
166 }); 179 });
167 180
168 //老师音频按钮点击 181 //老师音频按钮点击
@@ -172,50 +185,44 @@ $(function () { @@ -172,50 +185,44 @@ $(function () {
172 if(teaVideoDisplay=="block"){ 185 if(teaVideoDisplay=="block"){
173 $("#teacherVideo-videoBg").trigger("click"); 186 $("#teacherVideo-videoBg").trigger("click");
174 } 187 }
  188 +
  189 + if (classAllInfo.userRole=="host"){
  190 + $(".publish").css({"width":"240px","height":"180px"});
  191 + $(".play").css({"width":"1px","height":"1px"});
175 $("#teacherVideo-voice").css("display","none"); 192 $("#teacherVideo-voice").css("display","none");
176 $("#teacherVideo-voiceBg").css("display","block"); 193 $("#teacherVideo-voiceBg").css("display","block");
177 - $(".publish").css("display","none");  
178 $(".teacherVideoBg").css("display","none"); 194 $(".teacherVideoBg").css("display","none");
  195 + }
179 196
180 // /获取老师只推音频地址 197 // /获取老师只推音频地址
181 - achieveTeaVoice(); 198 + achieveTeaAudioStream();
182 199
183 }); 200 });
184 201
185 //老师音频关闭按钮点击 202 //老师音频关闭按钮点击
186 $("#teacherVideo-voiceBg").click(function (e) { 203 $("#teacherVideo-voiceBg").click(function (e) {
  204 +
187 console.log("teacherVideo-voice点击"); 205 console.log("teacherVideo-voice点击");
188 - $(".publish").css("display","none"); 206 +
  207 + if (classAllInfo.userRole=="host"){
  208 + $(".publish").css({"width":"1px","height":"1px"});
189 $(".teacherVideo").css("background", "#f5f9fb"); 209 $(".teacherVideo").css("background", "#f5f9fb");
190 $(".teacherVoicing").css("display","none"); 210 $(".teacherVoicing").css("display","none");
191 $(".teacherVideo-voiceBg").css("display","none"); 211 $(".teacherVideo-voiceBg").css("display","none");
192 $(".teacherVideo-voice").css("display","block"); 212 $(".teacherVideo-voice").css("display","block");
193 - 213 + }
194 var paramInfo={ 214 var paramInfo={
195 "nodeId": Number(classAllInfo.nodeId)//用户的nodeId 215 "nodeId": Number(classAllInfo.nodeId)//用户的nodeId
196 }; 216 };
197 client.stopPublishAudio(paramInfo); 217 client.stopPublishAudio(paramInfo);
198 218
199 -  
200 - if(window.publishflashVoice) { 219 + if(window.publishflashAudio) {
201 const stopTeaInfo = JSON.stringify({ 220 const stopTeaInfo = JSON.stringify({
202 type: 5, 221 type: 5,
203 - videoId: publishflashVoiceId, 222 + videoId: publishflashAudioId,
204 }); 223 });
205 - console.log(publishflashVoice._js2native(stopTeaInfo)); 224 + console.log(publishflashAudio._js2native(stopTeaInfo));
206 } 225 }
207 -  
208 -  
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 -  
219 }); 226 });
220 227
221 228
@@ -327,8 +334,6 @@ function _videoUpdate(callbackDate){ @@ -327,8 +334,6 @@ function _videoUpdate(callbackDate){
327 334
328 } 335 }
329 336
330 -  
331 -  
332 if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){ 337 if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
333 338
334 achievePlayStream(callbackDate); 339 achievePlayStream(callbackDate);
@@ -343,7 +348,7 @@ function _videoUpdate(callbackDate){ @@ -343,7 +348,7 @@ function _videoUpdate(callbackDate){
343 console.log(callbackDate.fromNodeId,stuNodeId); 348 console.log(callbackDate.fromNodeId,stuNodeId);
344 if(callbackDate.fromNodeId==stuNodeId){ 349 if(callbackDate.fromNodeId==stuNodeId){
345 if (classAllInfo.userRole=="normal"){ 350 if (classAllInfo.userRole=="normal"){
346 - // $(".play").css("display","none"); 351 + $(".play").css({"width":"1px","height":"1px"});
347 } 352 }
348 353
349 // $(".play").css("display","none"); 354 // $(".play").css("display","none");
@@ -376,24 +381,27 @@ function _audioUpdate(callbackDate){ @@ -376,24 +381,27 @@ function _audioUpdate(callbackDate){
376 381
377 382
378 if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){ 383 if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
379 - achievePlayVoiceStream(callbackDate); 384 + achievePlayAudioStream(callbackDate);
380 385
381 } 386 }
382 if(callbackDate.status==0){ 387 if(callbackDate.status==0){
383 $(".teacherVideoBg").css("display","block"); 388 $(".teacherVideoBg").css("display","block");
384 $(".teacherVideo").css("background", "#f5f9fb"); 389 $(".teacherVideo").css("background", "#f5f9fb");
385 - if(window.playflashVoice) {  
386 - console.log("playflashVoiceId", playflashVoiceId); 390 +
  391 +
  392 + if(window.playflashAudio) {
  393 + console.log("playflashVoiceId", playflashAudioId);
387 394
388 if (callbackDate.fromNodeId == stuNodeId) { 395 if (callbackDate.fromNodeId == stuNodeId) {
  396 +
389 if (classAllInfo.userRole=="normal"){ 397 if (classAllInfo.userRole=="normal"){
390 - $(".play").css("display","none"); 398 + $(".play").css({"width":"1px","height":"1px"});
391 } 399 }
392 const stopPlayInfo = JSON.stringify({ 400 const stopPlayInfo = JSON.stringify({
393 type: 5, 401 type: 5,
394 - videoId: playflashVoiceId 402 + videoId: playflashAudioId
395 }); 403 });
396 - console.log(playflashVoice._js2native(stopPlayInfo)); 404 + console.log(playflashAudio._js2native(stopPlayInfo));
397 } 405 }
398 } 406 }
399 } 407 }
@@ -603,19 +611,17 @@ function publishStuVoiceURL(rtmpURL) { @@ -603,19 +611,17 @@ function publishStuVoiceURL(rtmpURL) {
603 611
604 612
605 613
606 -//获取老师只推音频  
607 -function achieveTeaVoice() {  
608 - $(".publish").css("display","block");  
609 - $(".play").css("display","none"); 614 + //获取老师只推音频
  615 +function achieveTeaAudioStream() {
610 var paramInfo={ 616 var paramInfo={
611 "type": "flash" 617 "type": "flash"
612 }; 618 };
613 - var pubResult=client.getAudioPublishPath(paramInfo);  
614 - console.log("执行getAudioPublishPath,返回的结果",pubResult); 619 + pushTeaAudioResult=client.getAudioPublishPath(paramInfo);
  620 + console.log("执行getAudioPublishPath,返回的结果",pushTeaAudioResult);
615 621
616 //code为0,代表成功 622 //code为0,代表成功
617 - if (pubResult.code==0){  
618 - if(! window.publishflashVoice) { 623 + if (pushTeaAudioResult.code==0){
  624 + if(! window.publishflashAudio) {
619 flashvideo( 625 flashvideo(
620 'publish', 626 'publish',
621 '100%', 627 '100%',
@@ -624,10 +630,10 @@ function achieveTeaVoice() { @@ -624,10 +630,10 @@ function achieveTeaVoice() {
624 if (error) { 630 if (error) {
625 return console.error(error); 631 return console.error(error);
626 } 632 }
627 - window.publishflashVoice = publishflash;  
628 - window.publishflashVoiceId = teaTimeStamp(); 633 + window.publishflashAudio = publishflash;
  634 + window.publishflashAudioId = teaTimeStamp();
629 635
630 - publishTeaVoiceURL(pubResult.publishUrl); 636 + publishTeaAudioURL(pushTeaAudioResult.publishUrl);
631 }, 637 },
632 function (msg) { 638 function (msg) {
633 639
@@ -637,7 +643,7 @@ function achieveTeaVoice() { @@ -637,7 +643,7 @@ function achieveTeaVoice() {
637 if(_msg.data.result == 0){ 643 if(_msg.data.result == 0){
638 644
639 //将之前底层取的推流结果传递给底层 645 //将之前底层取的推流结果传递给底层
640 - var _successErrorResult= client.publishAudio(pubResult); 646 + var _successErrorResult= client.publishAudio(pushTeaAudioResult);
641 console.log("_successErrorResult======>",_successErrorResult) 647 console.log("_successErrorResult======>",_successErrorResult)
642 if(_successErrorResult.code==0){ 648 if(_successErrorResult.code==0){
643 console.log("底层广播推流成功"); 649 console.log("底层广播推流成功");
@@ -654,44 +660,43 @@ function achieveTeaVoice() { @@ -654,44 +660,43 @@ function achieveTeaVoice() {
654 660
655 } 661 }
656 else { 662 else {
657 - publishTeaVoiceURL(pubResult.publishUrl); 663 + publishTeaAudioURL(pushTeaAudioResult.publishUrl);
658 } 664 }
659 665
660 - }else if(pubResult.code==1){ 666 + }else if(pushTeaAudioResult.code==1){
661 667
662 } 668 }
663 669
664 670
665 } 671 }
666 -  
667 -function publishTeaVoiceURL(rtmpURL) { 672 +function publishTeaAudioURL(rtmpURL) {
668 const msg = JSON.stringify({ 673 const msg = JSON.stringify({
669 type: 10, 674 type: 10,
670 - videoId: publishflashVoiceId, 675 + videoId: publishflashAudioId,
671 data: { 676 data: {
672 video:false, 677 video:false,
673 audio:true, 678 audio:true,
674 url: rtmpURL 679 url: rtmpURL
675 } 680 }
676 }); 681 });
677 - console.log(publishflashVoice._js2native(msg)); 682 + console.log(publishflashAudio._js2native(msg));
678 } 683 }
679 684
680 685
  686 +
681 //获取老师推流音视频地址 687 //获取老师推流音视频地址
682 -function achieveTeaStream(){  
683 - $(".publish").css("display","block"); 688 +function achieveTeaVideoStream(){
  689 + $(".publish").css({"width":"240px","height":"180px"});
684 $(".play").css("display","none"); 690 $(".play").css("display","none");
685 var paramInfo={ 691 var paramInfo={
686 "type": "flash" 692 "type": "flash"
687 }; 693 };
688 - var pubResult=client.getVideoPublishPath(paramInfo);  
689 - console.log("执行getPublishVideoPath,返回的结果",pubResult); 694 + pushTeaResult=client.getVideoPublishPath(paramInfo);
  695 + console.log("执行getPublishVideoPath,返回的结果",pushTeaResult);
690 696
691 //code为0,代表成功 697 //code为0,代表成功
692 - if (pubResult.code==0){ 698 + if (pushTeaResult.code==0){
693 if(! window.publishflash) { 699 if(! window.publishflash) {
694 - console.log("if==================>");  
695 flashvideo( 700 flashvideo(
696 'publish', 701 'publish',
697 '100%', 702 '100%',
@@ -703,7 +708,7 @@ function achieveTeaStream(){ @@ -703,7 +708,7 @@ function achieveTeaStream(){
703 window.publishflash = publishflash; 708 window.publishflash = publishflash;
704 window.publishflashVideoId = teaTimeStamp(); 709 window.publishflashVideoId = teaTimeStamp();
705 710
706 - publishURL(pubResult.publishUrl); 711 + publishURL(pushTeaResult.publishUrl);
707 }, 712 },
708 function (msg) { 713 function (msg) {
709 console.log(' [publish] native 2 js', msg); 714 console.log(' [publish] native 2 js', msg);
@@ -711,7 +716,8 @@ function achieveTeaStream(){ @@ -711,7 +716,8 @@ function achieveTeaStream(){
711 console.log("_msg===========>",_msg); 716 console.log("_msg===========>",_msg);
712 if(_msg.data.result == 0){ 717 if(_msg.data.result == 0){
713 //将之前底层取的推流结果传递给底层 718 //将之前底层取的推流结果传递给底层
714 - var _successErrorResult= client.publishVideo(pubResult); 719 + console.log("之前的推流结果",pushTeaResult);
  720 + var _successErrorResult= client.publishVideo(pushTeaResult);
715 console.log("_successErrorResult======>",_successErrorResult) 721 console.log("_successErrorResult======>",_successErrorResult)
716 if(_successErrorResult.code==0){ 722 if(_successErrorResult.code==0){
717 console.log("底层广播推流成功"); 723 console.log("底层广播推流成功");
@@ -726,16 +732,15 @@ function achieveTeaStream(){ @@ -726,16 +732,15 @@ function achieveTeaStream(){
726 ) 732 )
727 } 733 }
728 else { 734 else {
729 - console.log("else=============>");  
730 - publishURL(pubResult.publishUrl); 735 +
  736 + publishURL(pushTeaResult.publishUrl);
731 } 737 }
732 738
733 - }else if(pubResult.code==1){ 739 + }else if(pushTeaResult.code==1){
734 740
735 - console.log("pubResult.code==1");  
736 } 741 }
737 } 742 }
738 - //推音视频 js2native 743 + //推老师音视频 js2native
739 function publishURL(rtmpURL) { 744 function publishURL(rtmpURL) {
740 const msg = JSON.stringify({ 745 const msg = JSON.stringify({
741 type: 10, 746 type: 10,
@@ -747,12 +752,13 @@ function publishURL(rtmpURL) { @@ -747,12 +752,13 @@ function publishURL(rtmpURL) {
747 } 752 }
748 }); 753 });
749 console.log("publishflashVideoId======>",publishflashVideoId); 754 console.log("publishflashVideoId======>",publishflashVideoId);
750 - console.log(publishflash);  
751 console.log(publishflash._js2native(msg)); 755 console.log(publishflash._js2native(msg));
752 } 756 }
753 757
  758 +
  759 +
754 //获取播放音频地址 760 //获取播放音频地址
755 -function achievePlayVoiceStream(_pubResultObj){ 761 +function achievePlayAudioStream(_pubResultObj){
756 762
757 console.log("_pubResultObj==========>",_pubResultObj) 763 console.log("_pubResultObj==========>",_pubResultObj)
758 var _paramInfo={ 764 var _paramInfo={
@@ -765,12 +771,12 @@ function achievePlayVoiceStream(_pubResultObj){ @@ -765,12 +771,12 @@ function achievePlayVoiceStream(_pubResultObj){
765 }; 771 };
766 var streamInfo=client.getAudioPlayPath(_paramInfo); 772 var streamInfo=client.getAudioPlayPath(_paramInfo);
767 console.log("result是=============>",streamInfo); 773 console.log("result是=============>",streamInfo);
768 - $(".play").css("display","block"); 774 + $(".play").css({"width":"240px","height":"180px"});
769 $(".teacherVideoBg").css("display","none"); 775 $(".teacherVideoBg").css("display","none");
770 $(".teacherVideo").css("background", "#CCCCCC"); 776 $(".teacherVideo").css("background", "#CCCCCC");
771 $(".teacherVideo-voice").css("bottom","4px"); 777 $(".teacherVideo-voice").css("bottom","4px");
772 778
773 - if(! window.playflashVoice) { 779 + if(! window.playflashAudio) {
774 flashvideo( 780 flashvideo(
775 'play', 781 'play',
776 '100%', 782 '100%',
@@ -779,10 +785,10 @@ function achievePlayVoiceStream(_pubResultObj){ @@ -779,10 +785,10 @@ function achievePlayVoiceStream(_pubResultObj){
779 if (error) { 785 if (error) {
780 return console.error(error); 786 return console.error(error);
781 } 787 }
782 - window.playflashVoice = playflash;  
783 - window.playflashVoiceId = teaTimeStamp(); 788 + window.playflashAudio = playflash;
  789 + window.playflashAudioId = teaTimeStamp();
784 790
785 - playVoiceURL(streamInfo.playUrl); 791 + playAudioURL(streamInfo.playUrl);
786 }, 792 },
787 function (msg) { 793 function (msg) {
788 console.log(' [play] native 2 js', msg); 794 console.log(' [play] native 2 js', msg);
@@ -790,25 +796,25 @@ function achievePlayVoiceStream(_pubResultObj){ @@ -790,25 +796,25 @@ function achievePlayVoiceStream(_pubResultObj){
790 ) 796 )
791 } 797 }
792 else { 798 else {
793 - playVoiceURL(streamInfo.playUrl); 799 + playAudioURL(streamInfo.playUrl);
794 } 800 }
795 801
796 802
797 } 803 }
798 804
799 -function playVoiceURL(rtmpURL){ 805 +function playAudioURL(rtmpURL){
800 const msg = JSON.stringify({ 806 const msg = JSON.stringify({
801 type: 2, 807 type: 2,
802 - videoId: playflashVoiceId, 808 + videoId: playflashAudioId,
803 data: { 809 data: {
804 url: rtmpURL 810 url: rtmpURL
805 // url:'rtmp://123.56.205.116:1935/live/alexwang' 811 // url:'rtmp://123.56.205.116:1935/live/alexwang'
806 } 812 }
807 }); 813 });
808 - console.log(playflashVoice._js2native(msg)); 814 + console.log(playflashAudio._js2native(msg));
809 } 815 }
810 816
811 - //获取音视频播流地址 817 + //获取老师音视频播流地址
812 function achievePlayStream(_pubResultObj){ 818 function achievePlayStream(_pubResultObj){
813 console.log("_pubResultObj==========>",_pubResultObj) 819 console.log("_pubResultObj==========>",_pubResultObj)
814 var _paramInfo={ 820 var _paramInfo={
@@ -821,7 +827,7 @@ function playVoiceURL(rtmpURL){ @@ -821,7 +827,7 @@ function playVoiceURL(rtmpURL){
821 }; 827 };
822 var streamInfo=client.getVideoPlayPath(_paramInfo); 828 var streamInfo=client.getVideoPlayPath(_paramInfo);
823 console.log("result是=============>",streamInfo); 829 console.log("result是=============>",streamInfo);
824 - // $(".play").css("display","block"); 830 + $(".play").css({"width":"240px","height":"180px"});
825 $(".teacherVideoBg").css("display","none"); 831 $(".teacherVideoBg").css("display","none");
826 $(".teacherVideo").css("background", "#CCCCCC"); 832 $(".teacherVideo").css("background", "#CCCCCC");
827 $(".teacherVideo-voice").css("bottom","4px"); 833 $(".teacherVideo-voice").css("bottom","4px");