张桐

音视频模块修改

... ... @@ -258,6 +258,15 @@ height: 1080px;
color: #333;
font-size: 12px;
}
.classCurId{
float: left;
margin-left: 20px;
color: #333;
font-size: 12px;
width: 40px;
height: 20px;
}
/*直播中*/
.cur-status {
float: left;
... ... @@ -962,6 +971,43 @@ height: 1080px;
}
.spinner1 {
display: none;
z-index: 10;
position: absolute;
top: 190px;
left: 231px;
margin: 100px auto 0;
width: 150px;
text-align: center;
}
.spinner1 > div {
width: 30px;
height: 30px;
background-color: #3498db;
border-radius: 100%;
display: inline-block;
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
animation: bouncedelay 1.4s infinite ease-in-out;
/* Prevent first frame from flickering when animation starts */
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.spinner1 .bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.spinner1 .bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
.spinner > div {
width: 30px;
... ... @@ -1198,16 +1244,17 @@ height: 1080px;
.stuVideo-video{
position: absolute;
left: 3px;
bottom: 0px;
bottom: -5px;
cursor: pointer;
color: #333333;
margin: 5px 5px 0px 5px;
margin: 0px 5px 0px 5px;
}
.stuVideo-videoBg{
display: none;
position: absolute;
left: 3px;
bottom: 5px;
bottom: 1px;
width: 16px;
height: 16px;
cursor: pointer;
... ... @@ -1224,19 +1271,20 @@ height: 1080px;
.stuVideo-voice{
position: absolute;
left:23px;
bottom: 10px;
bottom: 4px;
width: 16px;
height: 16px;
font-size: 16px;
cursor: pointer;
color: #333333;
margin: 5px 5px 0px 5px;
margin: 0px 5px 0px 5px;
}
.stuVideo-voiceBg{
display: none;
position: absolute;
left:23px;
bottom: 5px;
bottom: 0px;
width: 16px;
height: 16px;
font-size: 16px;
... ... @@ -1264,13 +1312,25 @@ height: 1080px;
}
.teacherVideo .teacherVideoBg{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: url("../images/none-video-tea.png") no-repeat center center;
}
.teacherVideo .teacherVoicing{
display: none;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: url("../images/none-video-tea.png") no-repeat center center;
background: url("../images/voicing.gif") no-repeat center center;
}
.teacherVideo .teacherVideoInfo{
height: 100%;
width: 100%;
... ... @@ -1316,9 +1376,10 @@ height: 1080px;
}
.teacherVideo-voiceBg{
display:none;
position: absolute;
left:23px;
bottom: 5px;
bottom: 0px;
width: 16px;
height: 16px;
font-size: 16px;
... ... @@ -2389,6 +2450,7 @@ canvas {
}
.loginContent li:nth-of-type(5){
display: none;
height: 40px;
line-height: 40px;
width: 270px;
... ...
... ... @@ -16,8 +16,8 @@
<script type="text/javascript" src="js/xdyEvent.js"></script>
<script type="text/javascript" src="js/drag.js"></script>
<script type="text/javascript" src="js/McuClient.js?v=1.0.228.14"></script>
<!--<script type="text/javascript" src="http://192.168.1.140/McuClient/McuClient.js?729903213236"></script>-->
<!--<script type="text/javascript" src="js/McuClient.js?v=1.0.228.14"></script>-->
<script type="text/javascript" src="http://192.168.1.140/McuClient/McuClient.js?7213236"></script>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="src/main.js"></script>
... ... @@ -81,8 +81,8 @@
</div>
<a id="a-status" href="javascript: void(0)">未开始</a></li>
<li class="classroom"><a href="javascript: void(0)">[少儿英语口语]第四节</a></li>
<li class="classroom"><a id="classCurName" href="javascript: void(0)"></a></li>
<li class="classCurId"><a id="classCurId" href="javascript: void(0)"></a></li>
<!--设置-->
<div class="am-dropdown" data-am-dropdown>
... ... @@ -245,10 +245,15 @@
<!--<div class="am-tabs" data-am-tabs>-->
<!--<div id="tab-box" class="am-tabs-bd">-->
<!--<div class="am-tab-panel am-fade am-in am-active" id="tab1">-->
<div class="spinner1">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
<!--引入canvas画板-->
<div id="draw" class="clear">
<div class="canvas_container">
<canvas id="canvas">
浏览器不支持
</canvas>
... ... @@ -376,9 +381,17 @@
<!--右侧-->
<div id="right" class="right">
<div class="studentVideo">
<img>
<div class="stuPublish" style="position:absolute;top: 0; width:240px;height:180px">
<div id="stuPublish"></div>
</div>
<div class="stuPlay" style="position:absolute;top: 0; width:240px;height:180px">
<div id="stuPlay"></div>
</div>
<img class="stuVideoBg"/>
<div id="stuVideo-video" class="stuVideo-video iconfont">&#xe62e;</div>
<div id="stuVideo-videoBg" class="stuVideo-videoBg iconfont"></div>
<div id="stuVideo-voice" class="stuVideo-voice iconfont">&#xe62d;</div>
<div id="stuVideo-voiceBg" class="stuVideo-voiceBg iconfont"></div>
<!--<span>lucy</span>-->
</div>
<div class="teacherVideo">
... ... @@ -389,9 +402,11 @@
<div id="play"></div>
</div>
<img class="teacherVideoBg"/>
<img class="teacherVoicing"/>
<div id="teacherVideo-video" class="teacherVideo-video iconfont">&#xe62e;</div>
<div id="teacherVideo-videoBg" class="teacherVideo-videoBg iconfont"></div>
<div id="teacherVideo-voice" class="teacherVideo-voice iconfont">&#xe62d;</div>
<div id="teacherVideo-voiceBg" class="teacherVideo-voiceBg iconfont"></div>
</div>
... ... @@ -575,7 +590,7 @@
<div class="fourParamsOut">
<ul class="fourParams clear">
<li><span>classId:</span><input class="classId" type="text" value="2028061409"></li>
<li><span>classId:</span><input class="classId" type="text" value="120394398"></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>
... ... @@ -584,7 +599,6 @@
</li>
</ul>
<div class="permission">
<div class="permissionIn">
<input id="host" type="radio" name="userRole" value="host" onclick="getValue(this.value)"><label for="host">老师</label>
<input id="normal" type="radio" name="userRole" value="normal" onclick="getValue(this.value)"><label
... ...
此 diff 太大无法显示。
... ... @@ -3,69 +3,22 @@
var client;
var MessageTypes;
var canvasInfo;
var canvasInfoUpdate;
var canvasInfoArr=[];
var canvasInfoUpArr=[];
var classLoadInfo; //3个参数 课堂号/用户角色/ip 的对象
var classAllInfo={};
var fourParams={};
var fileInfo={}; //传递给底层的对象
var fileDeleteInfo={}; //删除的文件对象
var thisFileName; //当前点击的文件名称
var thisFileId;//当前点击的文件ID
var thisDocId;
var thisClassId;
var thisFileParent;//当前元素的父级
var fileFromArr=[]; //存储底层返回的文件,放到该数组
var fileFromUpArr=[];//存储上传返回的文件,,放到该数组
var classParamInfo={}
var pdfUrl;
var docfullPath;
var imgUrl;
var switchArr=[];
var pdfFile;
var currPageNumber;
var fileShowArr=[]; //存储显示的文档
var pdfArr=[];
var openPage;
var pdfUrlArr=[];
var docfullPathArr=[];
var imgUrlSingle;
var curPageNum;
var pageNum;
var fileItemIdx;
//画布
var canvas ;
var context ;
... ... @@ -92,21 +45,11 @@ function mainTimeStamp() {
}
$(function () {
// FastClick.attach(document.body);
initEngine();//加载MCUClientEngine;
listenClass();
loading();
urlParamsJudge();//对地址栏参数的数据进行判断
});
function initEngine(){
... ... @@ -115,26 +58,63 @@ function initEngine(){
client=MCUClientEngine.createMcuClient();
//获取事件监听消息定义
MessageTypes=MCUClientEngine.MessageTypes;
//McuClient版本号
console.log(client.sdkInfo.version);
videoWithFlash.flashInit(client);
// nativeVideo.nativeInit(client);
}
//监听课堂
function listenClass() {
if(client){
// client.on(MessageTypes.UPDATE_CLASS_TIMER,updateClassTime);// 监听会议时间更新
client.on(MessageTypes.CLASS_UPTATE_STATUS,classUpdateStatus);//监听会议状态更新
client.on(MessageTypes.CHAT_RECEIVE,chatReceive); //监听到聊天信息
client.on(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,whiteboardUpdate);//监听白板更新
client.on(MessageTypes.DOC_DELETE,docDelete);//监听删除文档
client.on(MessageTypes.DOC_UPDATE,docUpdate);//监听更新文档
// // //点击开始上课
//
// if($("#classes-status-1").html()=="开始上课"){
// $("#classes-status-1").click(function (e){
// client.sendStartClass();
// });
// }
// if($("#classes-status-1").html()=="课间休息"){
// $("#classes-status-1").click(function (e){
// client.sendPauseClass();
// });
// }
// if($("#classes-status-1").html()=="继续上课"){
// $("#classes-status-1").click(function (e){
// client.sendStartClass();
// });
// }
//
//
//
// //结束课堂
// $("#classes-status-2").click(function (e) {
// if($("#classes-status-2").html()=="结束课堂"){
// client.sendCloseClass();
// }
// });
//
//
//
// if($("#class-now").html()=="结束"){
// $("#class-now").unbind("click");
// }
}
}
//在窗口关闭前提示用户
window.onbeforeunload = function() {
if(client){
console.log("11111111111111111111111")
}else {
console.log("11111111111111111111111")
}
return false; // 可以阻止关闭
}
//窗口关闭,退出课堂
... ... @@ -341,13 +321,13 @@ function uploadFile(msg){
//监听文档更新
function docUpdate(callbackData){
console.log("监听文档更新=========================>");
console.log(callbackData);
if(callbackData==null){
return;
}
if (callbackData.visible===true){
showInter(callbackData,2);
}
//操作数据
... ... @@ -879,21 +859,9 @@ if (callbackData.userRole=="normal"){
//准备主页面
layoutView();
//开始课堂
startClass();
}
//开始课堂
function startClass() {
if(client){
//监听到聊天信息
client.on(MessageTypes.CHAT_RECEIVE,chatReceive);
client.on(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,whiteboardUpdate);//监听白板更新
client.on(MessageTypes.DOC_DELETE,docDelete);//监听删除文档
client.on(MessageTypes.DOC_UPDATE,docUpdate);//监听更新文档
}
}
//登录成功后,登录页隐藏,主页面显示
function layoutView( ) {
... ... @@ -927,6 +895,9 @@ function layoutView( ) {
//发送聊天消息
$("#btn_send").click(function (e) {
console.log("点击了发送消息按钮------->");
... ... @@ -941,6 +912,7 @@ function layoutView( ) {
//点击下一页
$("#nextPage").on("click",function (e) {
$(".spinner1").css("display","block");
console.log(curPageNum);
var paramInfo={
... ... @@ -966,6 +938,7 @@ function layoutView( ) {
//点击上一页
$("#prevPage").on("click",function (e) {
$(".spinner1").css("display","block");
if (curPageNum>1){
console.log("curPageNum",curPageNum);
for (var i=0;i<docfullPath.length;i++){
... ... @@ -985,15 +958,32 @@ function layoutView( ) {
});
//获取课堂信息
var classCurInfo=client.getClassStatusInfo();
$("#classCurName").html(classCurInfo.className);
$("#classCurId").html(classAllInfo.nodeId);
}
function whiteboardUpdate(callbackData) {
console.log("同步canvas消息");
console.log(callbackData);
draw.drawCanvas(callbackData);
$(".spinner").css("display","none");
$(".spinner1").css("display","none");
$(".doc-headline-a").trigger("click");
}
// function updateClassTime(callbackData){
//
// }
//监听会议状态更新
function classUpdateStatus(callbackData) {
console.log(callbackData);
}
//接收聊天消息
function chatReceive(callbackData){
console.log(callbackData);
... ... @@ -1071,8 +1061,6 @@ function loading() {
$(".permission").css("display","none");
$(".fourParams").css("display","none");
$(".loginBg").css("display","none");
}
//在页面loading时,提交验证,传给底层
... ...
... ... @@ -6,7 +6,7 @@
var client; //客户端
var stuNodeId;
var videoWithFlash={};
... ... @@ -17,7 +17,6 @@ videoWithFlash.flashInit=function (_client){
client=_client;
};
function teaTimeStamp() {
var _teatimestamp= Date.parse(new Date());
return _teatimestamp;
... ... @@ -26,74 +25,122 @@ $(function () {
//根据传进来的消息,创建老师NativeVideo窗口,进行播流
client.on(MessageTypes.VIDEO_UPDATE,_videoUpdate);
client.on(MessageTypes.AUDIO_UPDATE,_audioUpdate)
client.on(MessageTypes.CLASS_INSERT_ROSTER,userListUpdate)
client.on(MessageTypes.VIDEO_BROADCAST,stuBroadcast)
client.on(MessageTypes.AUDIO_BROADCAST,stuAudioBroadcast)
//学生视频按钮点击
$("#stuVideo-video").click(function (e) {
console.log("stuVideo-video点击");
$(".stuVideoBg").css("display","none");
$(".stuVideo-videoBg").css("display","block");
$(".stuVideo-video").css("display","none");
$(".studentVideo").css("background", "#CCCCCC");
$(".stuVideo-voice").css("bottom","4px");
var paramInfo={
"actionType":1,
"toNodeId":stuNodeId,
"data":"0"
};
console.log("stuNodeId",stuNodeId);
client.sendVideoBroadcastMsg(paramInfo);
if (classAllInfo.userRole=="normal"){
$(".stuVideo-voice").css("display","none");
$(".stuVideo-video").css("display","none");
}
});
//学生视频关闭按钮点击
$("#stuVideo-videoBg").click(function (e) {
var paramInfo={
"actionType":2,
"toNodeId":stuNodeId,
"data":"0"
};
client.sendVideoBroadcastMsg(paramInfo);
$("#stuVideo-video").css("display","block");
$("#stuVideo-videoBg").css("display","none");
});
//学生音频按钮点击
$("#stuVideo-voice").click(function (e) {
console.log("stuVideo-voice点击");
var stuVideoDisplay= $(".stuVideo-videoBg").css("display");
if(stuVideoDisplay=="block"){
$("#stuVideo-videoBg").trigger("click");
}
$("#stuVideo-voice").css("display","none");
$("#stuVideo-voiceBg").css("display","block");
$(".stuPublish").css("display","none");
$(".studentVideoBg").css("display","none");
var paramInfo={
"actionType":1,
"toNodeId":stuNodeId,
"data":"0"
};
console.log("stuNodeId",stuNodeId);
client.sendAudioBroadcastMsg(paramInfo);
if (classAllInfo.userRole=="normal"){
$(".stuVideo-voice").css("display","none");
$(".stuVideo-video").css("display","none");
}
});
//学生音频关闭按钮点击
$("#stuVideo-voiceBg").click(function(e){
var paramInfo={
"actionType":2,
"toNodeId":stuNodeId,
"data":"0"
};
client.sendAudioBroadcastMsg(paramInfo);
$("#stuVideo-voice").css("display","block");
$("#stuVideo-voiceBg").css("display","none");
if (classAllInfo.userRole=="normal"){
$(".stuVideo-voice").css("display","none");
$(".stuVideo-video").css("display","none");
}
});
// //学生视频按钮点击
// $("#stuVideo-video").click(function (e) {
// console.log("teacherVideo-video点击");
// $("#stuVideo-video").html(" ");
// $("#stuVideo-video").removeClass("stuVideo-video");
// $("#stuVideo-video").addClass("stuVideo-videoBg");
//
//
// $("#stuVideo-voice").html("&#xe62d;");
// $("#stuVideo-voice").addClass("stuVideo-voice");
// $("#stuVideo-voice").removeClass("stuVideo-voiceBg");
//
//
// //获取推流地址
// achieveStupPushStream();
//
//
// });
//
// //学生音频按钮点击
// $("#stuVideo-voice").click(function (e) {
//
// console.log("stuVideo-voice点击");
// $("#stuVideo-video").html("&#xe62e;");
// $("#stuVideo-video").removeClass("stuVideo-videoBg");
// $("#stuVideo-video").addClass("stuVideo-video");
//
// $("#stuVideo-voice").html("");
// $("#stuVideo-voice").removeClass("stuVideo-voice");
// $("#stuVideo-voice").addClass("stuVideo-voiceBg");
// });
//老师视频按钮点击
$("#teacherVideo-video").click(function (e) {
console.log("teacherVideo-video点击");
$("#teacherVideo-video").html(" ");
// $("#teacherVideo-video").removeClass("teacherVideo-video");
// $("#teacherVideo-video").addClass("teacherVideo-videoBg");
$(".teacherVideo-videoBg").css("display","block");
$(".teacherVideo-video").css("display","none");
var teaVoiceDisplay= $(".teacherVideo-voiceBg").css("display");
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");
//获取推流地址
achieveTeaStream();
});
//老师音频按钮点击
$(".teacherVideo-voice").click(function (e) {
console.log("teacherVideo-voice点击");
$("#teacherVideo-video").html("&#xe62e;");
$("#teacherVideo-video").removeClass("teacherVideo-videoBg");
$("#teacherVideo-video").addClass("teacherVideo-video");
$("#teacherVideo-voice").html("");
$("#teacherVideo-voice").removeClass("teacherVideo-voice");
$("#teacherVideo-voice").addClass("teacherVideo-voiceBg");
});
//老师视频关闭按钮点击
$("#teacherVideo-videoBg").click(function (e) {
if(window.publishflash) {
... ... @@ -101,12 +148,14 @@ $(function () {
type: 5,
videoId: publishflashVideoId,
});
console.log("publishflashVideoId",publishflashVideoId);
console.log(publishflash._js2native(stopInfo));
}
var paramInfo={
"nodeId": Number(classAllInfo.nodeId)//用户的nodeId
};
console.log(classAllInfo.nodeId);
client.stopPublishVideo(paramInfo);
$(".publish").css("display","none");
... ... @@ -114,35 +163,535 @@ $(function () {
$(".teacherVideoBg").css("display","block");
$("#teacherVideo-video").css("display","block");
$("#teacherVideo-videoBg").css("display","none");
});
//老师音频按钮点击
$("#teacherVideo-voice").click(function (e) {
console.log("teacherVideo-voice点击");
var teaVideoDisplay= $(".teacherVideo-videoBg").css("display");
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");
// /获取老师只推音频地址
achieveTeaVoice();
});
//老师音频关闭按钮点击
$("#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");
var paramInfo={
"nodeId": Number(classAllInfo.nodeId)//用户的nodeId
};
client.stopPublishAudio(paramInfo);
if(window.publishflashVoice) {
const stopTeaInfo = JSON.stringify({
type: 5,
videoId: publishflashVoiceId,
});
console.log(publishflashVoice._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");
});
});
//监听学生视频更新
function stuBroadcast(callbackDate){
if (callbackDate.actionType==1){
$(".stuVideoBg").css("display","none");
if(classAllInfo.userRole=="normal"){
//获取推流地址
achieveStuPushStream();
}
}
if(callbackDate.actionType==2){
if(window.publishStuflash) {
const stopStuInfo = JSON.stringify({
type: 5,
videoId: publishflashStuVideoId,
});
console.log(publishStuflash._js2native(stopStuInfo));
}
//获取推流地址
function achieveTeaStream(){
$(".publish").css("display","block");
$(".play").css("display","none");
var paramInfo={
"nodeId": Number(stuNodeId)//用户的nodeId
};
client.stopPublishVideo(paramInfo);
$(".stuPlay").css("display","none");
$(".stuPublish").css("display","none");
$(".studentVideo").css("background", "#f5f9fb");
$(".stuVideoBg").css("display","block");
$("#stuVideo-voice").css("display","block");
$("#stuVideo-voiceBg").css("display","none");
if (classAllInfo.userRole=="normal"){
$(".stuVideo-video").css("display","none");
}
}
}
//监听学生音频更新
function stuAudioBroadcast(callbackDate){
if (callbackDate.actionType==1){
$(".stuVideoBg").css("display","none");
$(".stuPlay").css("display","none");
if(classAllInfo.userRole=="normal"){
//获取学生只推音频地址
achieveStuVoice();
}
}
if(callbackDate.actionType==2){
if(window.publishflashStuVoice) {
const stopStuInfo = JSON.stringify({
type: 5,
videoId: publishflashStuVoiceId,
});
console.log(publishflashStuVoice._js2native(stopStuInfo));
}
var paramInfo={
"type": "flash"
"nodeId": Number(stuNodeId)//用户的nodeId
};
var pubResult=client.getVideoPublishPath(paramInfo);
client.stopPublishAudio(paramInfo);
$(".stuPlay").css("display","none");
$(".stuPublish").css("display","none");
$(".studentVideo").css("background", "#f5f9fb");
$(".stuVideoBg").css("display","block");
$("#stuVideo-video").css("display","block");
$("#stuVideo-videoBg").css("display","none");
if (classAllInfo.userRole=="normal"){
$(".stuVideo-voice").css("display","none");
$(".stuVideo-video").css("display","none");
}
}
}
//人员进入
function userListUpdate(callbackData) {
console.log("人员进入",callbackData);
if (classAllInfo.nodeId==callbackData.nodeId){
}else{
console.log("callbackData.nodeId================>",callbackData.nodeId)
stuNodeId=callbackData.nodeId;
}
}
// 监听当前是否有视频流更新
function _videoUpdate(callbackDate){
console.log("videoUpdate==============>",callbackDate);
// alert((classAllInfo.userRole=="host")&&(callbackDate.status==1)&&(callbackDate.fromNodeId==stuNodeId));
if((classAllInfo.userRole=="host")&&(callbackDate.status==1)&&(callbackDate.fromNodeId==stuNodeId)){
//获取学生播流地址
achieveStuPlayStream(callbackDate);
$(".teacherVideo").css("background","#f5f9fb");
$(".teacherVideoBg").css("display","block");
}
if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
achievePlayStream(callbackDate);
}
//流的状态为0
if(callbackDate.status==0){
console.log("callbackDate.fromNodeId,stuNodeId");
console.log(callbackDate.fromNodeId,stuNodeId);
if(callbackDate.fromNodeId==stuNodeId){
if (classAllInfo.userRole=="normal"){
// $(".play").css("display","none");
}
// $(".play").css("display","none");
$(".teacherVideoBg").css("display","block");
$(".teacherVideo").css("background", "#f5f9fb");
if(window.playflash){
console.log("playflashVideoId",playflashVideoId);
const stopPlayInfo = JSON.stringify({
type: 5,
videoId: playflashVideoId
});
console.log(playflash._js2native(stopPlayInfo));
}
}
}
}
// 监听当前是否有音频流更新
function _audioUpdate(callbackDate){
if((classAllInfo.userRole=="host")&&(callbackDate.status==1)&&(callbackDate.fromNodeId==stuNodeId)){
//获取学生播流地址
achieveStuPlayStream(callbackDate);
$(".stuPlay").css("display","block");
$(".teacherVideo").css("background","#f5f9fb");
$(".teacherVideoBg").css("display","block");
}
if ((classAllInfo.userRole=="normal")&&(callbackDate.status==1)&&(callbackDate.channelId!=='')&&(callbackDate.fromNodeId==stuNodeId)){
achievePlayVoiceStream(callbackDate);
}
if(callbackDate.status==0){
$(".teacherVideoBg").css("display","block");
$(".teacherVideo").css("background", "#f5f9fb");
if(window.playflashVoice) {
console.log("playflashVoiceId", playflashVoiceId);
if (callbackDate.fromNodeId == stuNodeId) {
if (classAllInfo.userRole=="normal"){
$(".play").css("display","none");
}
const stopPlayInfo = JSON.stringify({
type: 5,
videoId: playflashVoiceId
});
console.log(playflashVoice._js2native(stopPlayInfo));
}
}
}
}
// //获取学生推流地址
function achieveStuPushStream() {
$(".stuPublish").css("display","block");
$(".stuPlay").css("display","none");
var paramInfo={
"type": "flash"
};
var pubStuResult=client.getVideoPublishPath(paramInfo);
console.log("执行getPublishVideoPath,返回的结果",pubStuResult);
//code为0,代表成功
if (pubStuResult.code==0){
if(! window.publishStuflash) {
flashvideo(
'stuPublish',
'100%',
'100%',
function (error, publishflash) {
if (error) {
return console.error(error);
}
window.publishStuflash = publishflash;
window.publishflashStuVideoId = teaTimeStamp();
publishStuURL(pubStuResult.publishUrl);
},
function (msg) {
console.log(' [stuPublish] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("_msg===========>",_msg);
if(_msg.data.result == 0){
//将之前底层取的推流结果传递给底层
var _successErrorResult= client.publishVideo(pubStuResult);
console.log("_successErrorResult======>",_successErrorResult)
if(_successErrorResult.code==0){
console.log("底层广播推流成功");
} else if(_successErrorResult.code==1){
console.log("底层广播推流失败,关闭推流");
}
}else {
console.error('stuPublish error');
}
}
)
}
else {
publishStuURL(pubStuResult.publishUrl);
}
}else if(pubStuResult.code==1){
}
}
function publishStuURL(rtmpStuURL){
const msg = JSON.stringify({
type: 10,
videoId: publishflashStuVideoId,
data: {
video:true,
audio:true,
url: rtmpStuURL
}
});
console.log(publishStuflash._js2native(msg));
}
//获取学生播流地址
function achieveStuPlayStream(_pubResultObj) {
console.log("_pubResultObj==========>",_pubResultObj)
var _paramInfo={
"type": "rtmp",
"channelId": _pubResultObj.channelId,//频道号
"classId": _pubResultObj.classId,//课堂号
"siteId": _pubResultObj.siteId,//站点号
"timestamp":_pubResultObj.timestamp,//时间戳
"userId": _pubResultObj.userId,//userId
};
var streamInfo=client.getVideoPlayPath(_paramInfo);
console.log("result是=============>",streamInfo);
// $(".play").css("display","block");
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
if(! window.playflashStu) {
flashvideo(
'stuPlay',
'100%',
'100%',
function createPlayReady(error, playflash) {
if (error) {
return console.error(error);
}
window.playflashStu = playflash;
window.playflashStuVideoId = teaTimeStamp();
playStuURL(streamInfo.playUrl);
},
function (msg) {
console.log(' [play] native 2 js', msg);
}
)
}
else {
playStuURL(streamInfo.playUrl);
}
}
function playStuURL(rtmpURL){
const msg = JSON.stringify({
type: 2,
videoId: playflashStuVideoId,
data: {
url: rtmpURL
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflashStu._js2native(msg));
}
//获取学生只推音频
function achieveStuVoice() {
var paramInfo={
"type": "flash"
};
var pubResult=client.getAudioPublishPath(paramInfo);
console.log("执行getAudioPublishPath,返回的结果",pubResult);
//code为0,代表成功
if (pubResult.code==0){
if(! window.publishflashStuVoice) {
flashvideo(
'stuPublish',
'100%',
'100%',
function (error, publishflash) {
if (error) {
return console.error(error);
}
window.publishflashStuVoice = publishflash;
window.publishflashStuVoiceId = teaTimeStamp();
publishStuVoiceURL(pubResult.publishUrl);
},
function (msg) {
console.log(' [publish] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("_msg===========>",_msg);
if(_msg.data.result == 0){
//将之前底层取的推流结果传递给底层
var _successErrorResult= client.publishAudio(pubResult);
console.log("_successErrorResult======>",_successErrorResult)
if(_successErrorResult.code==0){
console.log("底层广播推流成功");
} else if(_successErrorResult.code==1){
console.log("底层广播推流失败,关闭推流");
}
}else {
console.error('publish error');
}
}
)
}
else {
publishStuVoiceURL(pubResult.publishUrl);
}
}else if(pubResult.code==1){
}
}
function publishStuVoiceURL(rtmpURL) {
const msg = JSON.stringify({
type: 10,
videoId: publishflashStuVoiceId,
data: {
video:false,
audio:true,
url: rtmpURL
}
});
console.log(publishflashStuVoice._js2native(msg));
}
console.log("执行getPublishVideoPath,返回的结果",pubResult);
//获取老师只推音频
function achieveTeaVoice() {
$(".publish").css("display","block");
$(".play").css("display","none");
var paramInfo={
"type": "flash"
};
var pubResult=client.getAudioPublishPath(paramInfo);
console.log("执行getAudioPublishPath,返回的结果",pubResult);
//code为0,代表成功
if (pubResult.code==0){
if(! window.publishflashVoice) {
flashvideo(
'publish',
'100%',
'100%',
function (error, publishflash) {
if (error) {
return console.error(error);
}
window.publishflashVoice = publishflash;
window.publishflashVoiceId = teaTimeStamp();
publishTeaVoiceURL(pubResult.publishUrl);
},
function (msg) {
console.log(' [publish] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("_msg===========>",_msg);
if(_msg.data.result == 0){
//将之前底层取的推流结果传递给底层
var _successErrorResult= client.publishAudio(pubResult);
console.log("_successErrorResult======>",_successErrorResult)
if(_successErrorResult.code==0){
console.log("底层广播推流成功");
} else if(_successErrorResult.code==1){
console.log("底层广播推流失败,关闭推流");
}
}else {
console.error('publish error');
}
}
)
}
else {
publishTeaVoiceURL(pubResult.publishUrl);
}
}else if(pubResult.code==1){
}
}
function publishTeaVoiceURL(rtmpURL) {
const msg = JSON.stringify({
type: 10,
videoId: publishflashVoiceId,
data: {
video:false,
audio:true,
url: rtmpURL
}
});
console.log(publishflashVoice._js2native(msg));
}
//获取老师推流音视频地址
function achieveTeaStream(){
$(".publish").css("display","block");
$(".play").css("display","none");
var paramInfo={
"type": "flash"
};
var pubResult=client.getVideoPublishPath(paramInfo);
console.log("执行getPublishVideoPath,返回的结果",pubResult);
//code为0,代表成功
if (pubResult.code==0){
if(! window.publishflash) {
console.log("if==================>");
flashvideo(
'publish',
'100%',
... ... @@ -157,7 +706,6 @@ $(function () {
publishURL(pubResult.publishUrl);
},
function (msg) {
console.log(' [publish] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("_msg===========>",_msg);
... ... @@ -169,71 +717,98 @@ $(function () {
console.log("底层广播推流成功");
} else if(_successErrorResult.code==1){
console.log("底层广播推流失败,关闭推流");
}
}else {
console.error('publish error');
}
}
)
}
else {
console.log("else=============>");
publishURL(pubResult.publishUrl);
}
}else if(pubResult.code==1){
console.log("pubResult.code==1");
}
}
//推音视频 js2native
function publishURL(rtmpURL) {
const msg = JSON.stringify({
type: 10,
videoId: publishflashVideoId,
data: {
video:true,
audio:true,
url: rtmpURL
}
});
console.log("publishflashVideoId======>",publishflashVideoId);
console.log(publishflash);
console.log(publishflash._js2native(msg));
}
// 监听当前是否有视频流更新
function _videoUpdate(callbackDate){
playCallbackDate=callbackDate;
console.log("videoUpdate==============>",playCallbackDate);
if ((callbackDate.status==1)&&(callbackDate.channelId!=='')){
achievePlayStream(playCallbackDate);
//获取播放音频地址
function achievePlayVoiceStream(_pubResultObj){
console.log("_pubResultObj==========>",_pubResultObj)
var _paramInfo={
"type": "rtmp",
"channelId": _pubResultObj.channelId,//频道号
"classId": _pubResultObj.classId,//课堂号
"siteId": _pubResultObj.siteId,//站点号
"timestamp":_pubResultObj.timestamp,//时间戳
"userId": _pubResultObj.userId,//userId
};
var streamInfo=client.getAudioPlayPath(_paramInfo);
console.log("result是=============>",streamInfo);
$(".play").css("display","block");
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
if(! window.playflashVoice) {
flashvideo(
'play',
'100%',
'100%',
function createPlayReady(error, playflash) {
if (error) {
return console.error(error);
}
window.playflashVoice = playflash;
window.playflashVoiceId = teaTimeStamp();
playVoiceURL(streamInfo.playUrl);
},
function (msg) {
console.log(' [play] native 2 js', msg);
}
)
}
else {
playVoiceURL(streamInfo.playUrl);
}
if(callbackDate.status==0){
if(window.playflash){
console.log("playflashVideoId",playflashVideoId);
const stopPlayInfo = JSON.stringify({
type: 5,
videoId: playflashVideoId
});
console.log(playflash._js2native(stopPlayInfo));
}
$("#teacherVideo-videoBg").css("display","none");
$("#teacherVideo-video").html("&#xe62e;");
$(".play").css("display","none");
$(".teacherVideo").css("background", "#f5f9fb");
$(".teacherVideoBg").css("display","block");
}
}
function playVoiceURL(rtmpURL){
const msg = JSON.stringify({
type: 2,
videoId: playflashVoiceId,
data: {
url: rtmpURL
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflashVoice._js2native(msg));
}
//获取播流地址
//获取音视频播流地址
function achievePlayStream(_pubResultObj){
console.log("_pubResultObj==========>",_pubResultObj)
var _paramInfo={
... ... @@ -246,9 +821,8 @@ function publishURL(rtmpURL) {
};
var streamInfo=client.getVideoPlayPath(_paramInfo);
console.log("result是=============>",streamInfo);
$(".play").css("display","block");
// $(".play").css("display","block");
$(".teacherVideoBg").css("display","none");
$(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
... ... @@ -285,6 +859,7 @@ function publishURL(rtmpURL) {
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflash._js2native(msg));
}
... ...