张桐

在音视频之间切换多次 ok

... ... @@ -483,7 +483,6 @@ function _audioUpdate(callbackDate){
achieveStuPlayAudioStream(callbackDate);
$(".stuPlay").css({"width":"240px","height":"180px"});
$(".teacherVideo").css("background","#f5f9fb");
$(".teacherVideoBg").css("display","block");
}
... ... @@ -543,7 +542,7 @@ function achieveStuPushStream() {
//code为0,代表成功
if (pubStuResult.code==0){
if(! window.publishStuflash) {
flashvideo(
'stuPublish',
'100%',
... ... @@ -580,16 +579,11 @@ function achieveStuPushStream() {
}
else {
console.error('stuPublish error');
}
}
)
}
else {
publishStuURL(pubStuResult.publishUrl);
}
}else if(pubStuResult.code==1){
... ... @@ -626,7 +620,7 @@ function achieveStuPlayStream(_pubResultObj) {
$(".teacherVideo").css("background","#f5f9fb");
// $(".teacherVideoBg").css("display","block");
if(! window.playflashStu) {
flashvideo(
'stuPlay',
'100%',
... ... @@ -647,12 +641,6 @@ function achieveStuPlayStream(_pubResultObj) {
}
}
)
}
else {
playStuURL(streamInfo.playUrl);
}
}
function playStuURL(rtmpURL){
... ... @@ -678,7 +666,7 @@ function achieveStuVoice() {
//code为0,代表成功
if (pubStuAudioResult.code==0){
if(! window.publishflashStuVoice) {
flashvideo(
'stuPublish',
'100%',
... ... @@ -713,16 +701,11 @@ function achieveStuVoice() {
console.log("5,flash把学生音频流关闭成功");
}
else {
console.error('publish error');
}
}
)
}
else {
publishStuVoiceURL(pubStuAudioResult.publishUrl);
}
}else if(pubStuAudioResult.code==1){
... ... @@ -761,7 +744,7 @@ function achieveStuPlayAudioStream(_pubResultObj){
// $(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
if(! window.playflashStuAudio) {
flashvideo(
'stuPlay',
'100%',
... ... @@ -779,10 +762,7 @@ function achieveStuPlayAudioStream(_pubResultObj){
console.log(' [play] native 2 js', msg);
}
)
}
else {
stuPlayAudioURL(streamInfo.playUrl);
}
}
... ... @@ -800,6 +780,8 @@ function stuPlayAudioURL(rtmpURL){
}
//获取老师只推音频
function achieveTeaAudioStream() {
$(".publish").css({"width":"240px","height":"180px"});
... ... @@ -812,7 +794,7 @@ function achieveTeaAudioStream() {
//code为0,代表成功
if (pushTeaAudioResult.code==0){
if(! window.publishflashAudio) {
flashvideo(
'publish',
'100%',
... ... @@ -846,16 +828,11 @@ function achieveTeaAudioStream() {
console.log("5,flash把推老师音频流关闭");
}
else {
console.error('publish error');
}
}
)
}
else {
publishTeaAudioURL(pushTeaAudioResult.publishUrl);
}
}else if(pushTeaAudioResult.code==1){
... ... @@ -876,11 +853,76 @@ function publishTeaAudioURL(rtmpURL) {
});
console.log(publishflashAudio._js2native(msg));
}
//获取老师播放音频流地址
function achievePlayAudioStream(_pubResultObj){
//获取老师推音视频流地址
function achieveTeaVideoStream(){
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({"width":"240px","height":"180px"});
$(".publish").css({"width":"1px","height":"1px"});
$(".teacherVideoBg").css("display","none");
// $(".teacherVideo").css("background", "#CCCCCC");
// $(".teacherVideo-voice").css("bottom","4px");
flashvideo(
'play',
'100%',
'100%',
function createPlayReady(error, playflash) {
if (error) {
return console.error(error);
}
window.playflashAudio = playflash;
window.playflashAudioId = teaTimeStamp();
playAudioURL(streamInfo.playUrl);
},
function (msg) {
console.log(' [playAudio] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("playAudio_msg===========>",_msg);
if((_msg.data.result == 0)&&(_msg.data.type == 2)){
console.log("2,老师播音频流");
}
else if ((_msg.data.result == 0)&&(_msg.data.type == 5)){
console.log("5,flash把老师的播音频流关闭");
}
}
)
}
function playAudioURL(rtmpURL){
const msg = JSON.stringify({
type: 2,
videoId: playflashAudioId,
data: {
url: rtmpURL
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflashAudio._js2native(msg));
}
//获取老师推音视频流地址
function achieveTeaVideoStream(){
var paramInfo={
"type": "flash"
};
... ... @@ -889,7 +931,6 @@ function achieveTeaVideoStream(){
//code为0,代表成功
if (pushTeaResult.code==0){
if(! window.publishflash) {
flashvideo(
'publish',
'100%',
... ... @@ -923,16 +964,10 @@ function achieveTeaVideoStream(){
else if ((_msg.data.result == 0)&&(_msg.data.type == 5)){
console.log("5,flash把老师的推音视频流关闭");
}
else {
console.error('publish error');
}
}
)
}
else {
publishURL(pushTeaResult.publishUrl);
}
}else if(pushTeaResult.code==1){
... ... @@ -956,11 +991,8 @@ function publishURL(rtmpURL) {
}
//获取老师播放音频流地址
function achievePlayAudioStream(_pubResultObj){
//获取老师播音视频流地址
function achievePlayStream(_pubResultObj){
console.log("_pubResultObj==========>",_pubResultObj)
var _paramInfo={
"type": "rtmp",
... ... @@ -970,17 +1002,14 @@ function achievePlayAudioStream(_pubResultObj){
"timestamp":_pubResultObj.timestamp,//时间戳
"userId": _pubResultObj.userId,//userId
};
var streamInfo=client.getAudioPlayPath(_paramInfo);
var streamInfo=client.getVideoPlayPath(_paramInfo);
console.log("result是=============>",streamInfo);
$(".play").css({"width":"240px","height":"180px"});
$(".publish").css({"width":"1px","height":"1px"});
$(".teacherVideoBg").css("display","none");
// $(".teacherVideo").css("background", "#CCCCCC");
$(".teacherVideo-voice").css("bottom","4px");
if(! window.playflashAudio) {
flashvideo(
'play',
'100%',
... ... @@ -989,112 +1018,44 @@ function achievePlayAudioStream(_pubResultObj){
if (error) {
return console.error(error);
}
window.playflashAudio = playflash;
window.playflashAudioId = teaTimeStamp();
window.playflash = playflash;
window.playflashVideoId = teaTimeStamp();
playAudioURL(streamInfo.playUrl);
playURL(streamInfo.playUrl);
},
function (msg) {
console.log(' [playAudio] native 2 js', msg);
console.log(' [play] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("playAudio_msg===========>",_msg);
console.log("play_msg===========>",_msg);
if((_msg.data.result == 0)&&(_msg.data.type == 2)){
console.log("2,老师播音频流");
console.log("老师播流成功");
}
else if ((_msg.data.result == 0)&&(_msg.data.type == 5)){
console.log("5,flash把老师的播音频流关闭");
}
else {
console.error('playAudio error');
console.log("5,flash把老师的播音视频流关闭");
}
}
)
}
else {
playAudioURL(streamInfo.playUrl);
}
}
function playAudioURL(rtmpURL){
function playURL(rtmpURL) {
const msg = JSON.stringify({
type: 2,
videoId: playflashAudioId,
videoId: playflashVideoId,
data: {
url: rtmpURL
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflashAudio._js2native(msg));
console.log(playflash._js2native(msg));
}
//获取老师播音视频流地址
function achievePlayStream(_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({"width":"240px","height":"180px"});
$(".publish").css({"width":"1px","height":"1px"});
$(".teacherVideoBg").css("display","none");
$(".teacherVideo-voice").css("bottom","4px");
if(! window.playflash) {
flashvideo(
'play',
'100%',
'100%',
function createPlayReady(error, playflash) {
if (error) {
return console.error(error);
}
window.playflash = playflash;
window.playflashVideoId = teaTimeStamp();
playURL(streamInfo.playUrl);
},
function (msg) {
console.log(' [play] native 2 js', msg);
var _msg=JSON.parse(msg);
console.log("play_msg===========>",_msg);
if((_msg.data.result == 0)&&(_msg.data.type == 2)){
console.log("老师播流成功");
}
else if ((_msg.data.result == 0)&&(_msg.data.type == 5)){
console.log("5,flash把老师的播音视频流关闭");
}
else {
console.error('play error');
}
}
)
}
else {
playURL(streamInfo.playUrl);
}
}
function playURL(rtmpURL) {
const msg = JSON.stringify({
type: 2,
videoId: playflashVideoId,
data: {
url: rtmpURL
// url:'rtmp://123.56.205.116:1935/live/alexwang'
}
});
console.log(playflash._js2native(msg));
}
... ...