张桐

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

... ... @@ -590,7 +590,7 @@
<div class="fourParamsOut">
<ul class="fourParams clear">
<li><span>classId:</span><input class="classId" type="text" value="120394398"></li>
<li><span>classId:</span><input class="classId" type="text" value="1154006572"></li>
<!--<li><span>userRole:</span><input class="userRole" type="text" value=""></li>-->
<!--<li><span>portal:</span><input class="portal" type="text" value=""></li>-->
<li><span>userId:</span><input class="userId" type="text" value=""></li>
... ...
... ... @@ -8,9 +8,14 @@ var client; //客户端
var stuNodeId;
var videoWithFlash={};
var pushTeaResult; //推老师音视频结果
var pushTeaAudioResult; //推老师音频结果
window.videoWithFlash=videoWithFlash;
videoWithFlash.flashInit=function (_client){
... ... @@ -124,20 +129,20 @@ $(function () {
if(teaVoiceDisplay=="block"){
$("#teacherVideo-voiceBg").trigger("click");
}
$(".teacherVideo-videoBg").css("display","block");
$(".teacherVideo-video").css("display","none");
$("#teacherVideo-voice").html("&#xe62d;");
$("#teacherVideo-voice").addClass("teacherVideo-voice");
$("#teacherVideo-voice").removeClass("teacherVideo-voiceBg");
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
$(".teacherVoicing").css("display","none");
if (classAllInfo.userRole=="host"){
$(".teacherVideo-videoBg").css("display","block");
$(".teacherVideo-video").css("display","none");
$("#teacherVideo-voice").html("&#xe62d;");
$("#teacherVideo-voice").addClass("teacherVideo-voice");
$("#teacherVideo-voice").removeClass("teacherVideo-voiceBg");
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
$(".teacherVoicing").css("display","none");
}
//获取推流地址
achieveTeaStream();
achieveTeaVideoStream();
});
... ... @@ -148,7 +153,6 @@ $(function () {
type: 5,
videoId: publishflashVideoId,
});
console.log("publishflashVideoId",publishflashVideoId);
console.log(publishflash._js2native(stopInfo));
}
... ... @@ -158,11 +162,20 @@ $(function () {
console.log(classAllInfo.nodeId);
client.stopPublishVideo(paramInfo);
$(".publish").css("display","none");
$(".teacherVideo").css("background", "#f5f9fb");
$(".teacherVideoBg").css("display","block");
$("#teacherVideo-video").css("display","block");
$("#teacherVideo-videoBg").css("display","none");
if (classAllInfo.userRole=="host"){
$(".publish").css({"width":"1px","height":"1px"});
$(".teacherVideo").css("background", "#f5f9fb");
$(".teacherVideoBg").css("display","block");
$("#teacherVideo-video").css("display","block");
$("#teacherVideo-videoBg").css("display","none");
}
if (classAllInfo.userRole=="normal"){
$(".play").css({"width":"1px","height":"1px"});
}
});
//老师音频按钮点击
... ... @@ -172,50 +185,44 @@ $(function () {
if(teaVideoDisplay=="block"){
$("#teacherVideo-videoBg").trigger("click");
}
$("#teacherVideo-voice").css("display","none");
$("#teacherVideo-voiceBg").css("display","block");
$(".publish").css("display","none");
$(".teacherVideoBg").css("display","none");
if (classAllInfo.userRole=="host"){
$(".publish").css({"width":"240px","height":"180px"});
$(".play").css({"width":"1px","height":"1px"});
$("#teacherVideo-voice").css("display","none");
$("#teacherVideo-voiceBg").css("display","block");
$(".teacherVideoBg").css("display","none");
}
// /获取老师只推音频地址
achieveTeaVoice();
achieveTeaAudioStream();
});
//老师音频关闭按钮点击
$("#teacherVideo-voiceBg").click(function (e) {
console.log("teacherVideo-voice点击");
$(".publish").css("display","none");
$(".teacherVideo").css("background", "#f5f9fb");
$(".teacherVoicing").css("display","none");
$(".teacherVideo-voiceBg").css("display","none");
$(".teacherVideo-voice").css("display","block");
if (classAllInfo.userRole=="host"){
$(".publish").css({"width":"1px","height":"1px"});
$(".teacherVideo").css("background", "#f5f9fb");
$(".teacherVoicing").css("display","none");
$(".teacherVideo-voiceBg").css("display","none");
$(".teacherVideo-voice").css("display","block");
}
var paramInfo={
"nodeId": Number(classAllInfo.nodeId)//用户的nodeId
};
client.stopPublishAudio(paramInfo);
if(window.publishflashVoice) {
if(window.publishflashAudio) {
const stopTeaInfo = JSON.stringify({
type: 5,
videoId: publishflashVoiceId,
videoId: publishflashAudioId,
});
console.log(publishflashVoice._js2native(stopTeaInfo));
console.log(publishflashAudio._js2native(stopTeaInfo));
}
$(".publish").css("display","none");
$(".teacherVideo").css("background", "#f5f9fb");
$(".teacherVideoBg").css("display","block");
$("#teacherVideo-video").css("display","block");
$("#teacherVideo-videoBg").css("display","none");
$("#teacherVideo-voice").css("display","block");
$("#teacherVideo-voiceBg").css("display","none");
});
... ... @@ -327,8 +334,6 @@ function _videoUpdate(callbackDate){
}
if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
achievePlayStream(callbackDate);
... ... @@ -343,7 +348,7 @@ function _videoUpdate(callbackDate){
console.log(callbackDate.fromNodeId,stuNodeId);
if(callbackDate.fromNodeId==stuNodeId){
if (classAllInfo.userRole=="normal"){
// $(".play").css("display","none");
$(".play").css({"width":"1px","height":"1px"});
}
// $(".play").css("display","none");
... ... @@ -376,24 +381,27 @@ function _audioUpdate(callbackDate){
if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
achievePlayVoiceStream(callbackDate);
achievePlayAudioStream(callbackDate);
}
if(callbackDate.status==0){
$(".teacherVideoBg").css("display","block");
$(".teacherVideo").css("background", "#f5f9fb");
if(window.playflashVoice) {
console.log("playflashVoiceId", playflashVoiceId);
if(window.playflashAudio) {
console.log("playflashVoiceId", playflashAudioId);
if (callbackDate.fromNodeId == stuNodeId) {
if (classAllInfo.userRole=="normal"){
$(".play").css("display","none");
$(".play").css({"width":"1px","height":"1px"});
}
const stopPlayInfo = JSON.stringify({
type: 5,
videoId: playflashVoiceId
videoId: playflashAudioId
});
console.log(playflashVoice._js2native(stopPlayInfo));
console.log(playflashAudio._js2native(stopPlayInfo));
}
}
}
... ... @@ -603,19 +611,17 @@ function publishStuVoiceURL(rtmpURL) {
//获取老师只推音频
function achieveTeaVoice() {
$(".publish").css("display","block");
$(".play").css("display","none");
//获取老师只推音频
function achieveTeaAudioStream() {
var paramInfo={
"type": "flash"
};
var pubResult=client.getAudioPublishPath(paramInfo);
console.log("执行getAudioPublishPath,返回的结果",pubResult);
pushTeaAudioResult=client.getAudioPublishPath(paramInfo);
console.log("执行getAudioPublishPath,返回的结果",pushTeaAudioResult);
//code为0,代表成功
if (pubResult.code==0){
if(! window.publishflashVoice) {
if (pushTeaAudioResult.code==0){
if(! window.publishflashAudio) {
flashvideo(
'publish',
'100%',
... ... @@ -624,10 +630,10 @@ function achieveTeaVoice() {
if (error) {
return console.error(error);
}
window.publishflashVoice = publishflash;
window.publishflashVoiceId = teaTimeStamp();
window.publishflashAudio = publishflash;
window.publishflashAudioId = teaTimeStamp();
publishTeaVoiceURL(pubResult.publishUrl);
publishTeaAudioURL(pushTeaAudioResult.publishUrl);
},
function (msg) {
... ... @@ -637,7 +643,7 @@ function achieveTeaVoice() {
if(_msg.data.result == 0){
//将之前底层取的推流结果传递给底层
var _successErrorResult= client.publishAudio(pubResult);
var _successErrorResult= client.publishAudio(pushTeaAudioResult);
console.log("_successErrorResult======>",_successErrorResult)
if(_successErrorResult.code==0){
console.log("底层广播推流成功");
... ... @@ -654,44 +660,43 @@ function achieveTeaVoice() {
}
else {
publishTeaVoiceURL(pubResult.publishUrl);
publishTeaAudioURL(pushTeaAudioResult.publishUrl);
}
}else if(pubResult.code==1){
}else if(pushTeaAudioResult.code==1){
}
}
function publishTeaVoiceURL(rtmpURL) {
function publishTeaAudioURL(rtmpURL) {
const msg = JSON.stringify({
type: 10,
videoId: publishflashVoiceId,
videoId: publishflashAudioId,
data: {
video:false,
audio:true,
url: rtmpURL
}
});
console.log(publishflashVoice._js2native(msg));
console.log(publishflashAudio._js2native(msg));
}
//获取老师推流音视频地址
function achieveTeaStream(){
$(".publish").css("display","block");
function achieveTeaVideoStream(){
$(".publish").css({"width":"240px","height":"180px"});
$(".play").css("display","none");
var paramInfo={
"type": "flash"
};
var pubResult=client.getVideoPublishPath(paramInfo);
console.log("执行getPublishVideoPath,返回的结果",pubResult);
pushTeaResult=client.getVideoPublishPath(paramInfo);
console.log("执行getPublishVideoPath,返回的结果",pushTeaResult);
//code为0,代表成功
if (pubResult.code==0){
if (pushTeaResult.code==0){
if(! window.publishflash) {
console.log("if==================>");
flashvideo(
'publish',
'100%',
... ... @@ -703,7 +708,7 @@ function achieveTeaStream(){
window.publishflash = publishflash;
window.publishflashVideoId = teaTimeStamp();
publishURL(pubResult.publishUrl);
publishURL(pushTeaResult.publishUrl);
},
function (msg) {
console.log(' [publish] native 2 js', msg);
... ... @@ -711,7 +716,8 @@ function achieveTeaStream(){
console.log("_msg===========>",_msg);
if(_msg.data.result == 0){
//将之前底层取的推流结果传递给底层
var _successErrorResult= client.publishVideo(pubResult);
console.log("之前的推流结果",pushTeaResult);
var _successErrorResult= client.publishVideo(pushTeaResult);
console.log("_successErrorResult======>",_successErrorResult)
if(_successErrorResult.code==0){
console.log("底层广播推流成功");
... ... @@ -726,16 +732,15 @@ function achieveTeaStream(){
)
}
else {
console.log("else=============>");
publishURL(pubResult.publishUrl);
publishURL(pushTeaResult.publishUrl);
}
}else if(pubResult.code==1){
}else if(pushTeaResult.code==1){
console.log("pubResult.code==1");
}
}
//推音视频 js2native
//推老师音视频 js2native
function publishURL(rtmpURL) {
const msg = JSON.stringify({
type: 10,
... ... @@ -747,12 +752,13 @@ function publishURL(rtmpURL) {
}
});
console.log("publishflashVideoId======>",publishflashVideoId);
console.log(publishflash);
console.log(publishflash._js2native(msg));
}
//获取播放音频地址
function achievePlayVoiceStream(_pubResultObj){
function achievePlayAudioStream(_pubResultObj){
console.log("_pubResultObj==========>",_pubResultObj)
var _paramInfo={
... ... @@ -765,12 +771,12 @@ function achievePlayVoiceStream(_pubResultObj){
};
var streamInfo=client.getAudioPlayPath(_paramInfo);
console.log("result是=============>",streamInfo);
$(".play").css("display","block");
$(".play").css({"width":"240px","height":"180px"});
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
if(! window.playflashVoice) {
if(! window.playflashAudio) {
flashvideo(
'play',
'100%',
... ... @@ -779,10 +785,10 @@ function achievePlayVoiceStream(_pubResultObj){
if (error) {
return console.error(error);
}
window.playflashVoice = playflash;
window.playflashVoiceId = teaTimeStamp();
window.playflashAudio = playflash;
window.playflashAudioId = teaTimeStamp();
playVoiceURL(streamInfo.playUrl);
playAudioURL(streamInfo.playUrl);
},
function (msg) {
console.log(' [play] native 2 js', msg);
... ... @@ -790,25 +796,25 @@ function achievePlayVoiceStream(_pubResultObj){
)
}
else {
playVoiceURL(streamInfo.playUrl);
playAudioURL(streamInfo.playUrl);
}
}
function playVoiceURL(rtmpURL){
function playAudioURL(rtmpURL){
const msg = JSON.stringify({
type: 2,
videoId: playflashVoiceId,
videoId: playflashAudioId,
data: {
url: rtmpURL
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflashVoice._js2native(msg));
console.log(playflashAudio._js2native(msg));
}
//获取音视频播流地址
//获取老师音视频播流地址
function achievePlayStream(_pubResultObj){
console.log("_pubResultObj==========>",_pubResultObj)
var _paramInfo={
... ... @@ -821,7 +827,7 @@ function playVoiceURL(rtmpURL){
};
var streamInfo=client.getVideoPlayPath(_paramInfo);
console.log("result是=============>",streamInfo);
// $(".play").css("display","block");
$(".play").css({"width":"240px","height":"180px"});
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
... ...