Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
李勇
/
McuClient
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
AlexWang
2017-06-26 16:27:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4d9a04ec18080640abbe47a7648da5f86becd012
4d9a04ec
1 parent
72f01359
音乐接口
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
1333 行增加
和
701 行删除
src/EngineEntrance.js
src/GlobalConfig.js
src/apes/ApeConsts.js
src/apes/ConferApe.js
src/apes/MusicSharedApe.js
src/pdus/pro.js
src/EngineEntrance.js
查看文件 @
4d9a04e
...
...
@@ -28,6 +28,7 @@ import ArrayBufferUtil from 'libs/ArrayBufferUtil';
import
Server
from
"config/Server"
;
import
MediaModule
from
'apes/MediaModule'
;
import
MediaSharedApe
from
'apes/MediaSharedApe'
;
import
MusicSharedApe
from
'apes/MusicSharedApe'
;
import
QuestionApe
from
'apes/QuestionApe'
;
import
UTF8
from
'utf-8'
;
...
...
@@ -48,6 +49,7 @@ let _whiteboard_ape;
let
_cursor_ape
;
let
_recordPlayback
;
let
_mediaShareApe
;
let
_musicShareApe
;
let
_questionApe
;
//MCUClient 外部实例化主类
...
...
@@ -125,6 +127,10 @@ export default class MessageEntrance extends Emiter {
_mediaShareApe
.
on
(
'*'
,
(
type
,
data
)
=>
this
.
_emit
(
type
,
data
));
_mediaShareApe
.
on
(
MediaSharedApe
.
MEDIASHARED_JOIN_CHANNEL_SUCCESS
,
this
.
mediaShareApeJoinChannelSuccess
.
bind
(
this
));
_musicShareApe
=
new
MusicSharedApe
();
_musicShareApe
.
on
(
'*'
,
(
type
,
data
)
=>
this
.
_emit
(
type
,
data
));
_musicShareApe
.
on
(
MusicSharedApe
.
MUSICSHARED_JOIN_CHANNEL_SUCCESS
,
this
.
musicShareApeJoinChannelSuccess
.
bind
(
this
));
_whiteboard_ape
=
new
WhiteBoardApe
();
_whiteboard_ape
.
on
(
'*'
,
(
type
,
data
)
=>
this
.
_emit
(
type
,
data
));
...
...
@@ -221,6 +227,10 @@ export default class MessageEntrance extends Emiter {
this
.
mediaSharedStop
=
this
.
_sendMediaSharedStop
.
bind
(
this
);
//停止
this
.
mediaSharedUpdate
=
this
.
_sendMediaSharedUpdate
.
bind
(
this
);
//更新媒体的状态
this
.
musicSharedPlay
=
this
.
_sendMusicSharedPlay
.
bind
(
this
);
//Music播放
this
.
musicSharedStop
=
this
.
_sendMusicSharedStop
.
bind
(
this
);
//Music停止
this
.
musicSharedUpdate
=
this
.
_sendMusicSharedUpdate
.
bind
(
this
);
//Music更新媒体的状态
//答题卡
this
.
creatQuestion
=
this
.
_creatQuestion
.
bind
(
this
);
this
.
getQuestion
=
this
.
_getQuestion
.
bind
(
this
);
...
...
@@ -1233,821 +1243,894 @@ export default class MessageEntrance extends Emiter {
}
}
//获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do
//获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do
_sassGetClassParamSuccessHandler
(
_data
)
{
loger
.
log
(
'获取课堂课堂信息完成.'
);
//包含整个课堂最全的信息,储存数据
if
(
_data
)
{
GlobalConfig
.
mcuDelay
=
_data
.
h5Delay
||
0
;
//mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用
GlobalConfig
.
className
=
_data
.
meetingName
||
""
;
GlobalConfig
.
classBeginTime
=
_data
.
beginTime
||
""
;
GlobalConfig
.
classEndTime
=
_data
.
endTime
||
""
;
GlobalConfig
.
userIp
=
_data
.
userIp
||
""
;
GlobalConfig
.
maxVideoChannels
=
_data
.
maxVideoChannels
;
GlobalConfig
.
maxAudioChannels
=
_data
.
maxAudioChannels
;
GlobalConfig
.
maxMediaChannels
=
Math
.
max
(
GlobalConfig
.
maxVideoChannels
,
GlobalConfig
.
maxAudioChannels
);
GlobalConfig
.
ssTunnelAppURL
=
_data
.
ssTunnelAppURL
||
''
;
//屏幕共享插件的地址
//视频质量相关设置,每次加入课堂都按最新的获取设置
GlobalConfig
.
fps
=
_data
.
fps
||
15
;
GlobalConfig
.
gop
=
_data
.
gop
||
3
;
GlobalConfig
.
videoQuality
=
parseInt
(
_data
.
videoQuality
);
GlobalConfig
.
curVideoQuality
=
GlobalConfig
.
videoQuality
;
//是否自动开始(身份是host的时候才用到的)
GlobalConfig
.
isAutoStartClass
=
_data
.
autoRecord
||
0
;
GlobalConfig
.
serverTime
=
_data
.
serverTime
||
new
Date
().
getTime
();
//获取服务器时间戳
GlobalConfig
.
serverAndLoacTimeDistanc
=
(
new
Date
().
getTime
()
-
GlobalConfig
.
serverTime
)
/
1000
;
//当前系统时间和服务器时间的差值 (秒)
loger
.
warn
(
"服务器时间:"
+
GlobalConfig
.
serverTime
+
" 系统时间:"
+
new
Date
().
getTime
()
+
" 时间差:"
+
GlobalConfig
.
serverAndLoacTimeDistanc
);
GlobalConfig
.
setDocListPrepare
(
_data
.
docListPrepare
);
//提前上传的文档列表
GlobalConfig
.
setRecordList
(
_data
.
recordList
);
//录制回放地址
GlobalConfig
.
setDocList
(
_data
.
docList
);
//文档地址
GlobalConfig
.
setMsList
(
_data
.
msList
);
//推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)
GlobalConfig
.
setRsList
(
_data
.
rsList
);
//播放m3u8格式的地址(录制回放时使用)
GlobalConfig
.
setMcuList
(
_data
.
mcuList
);
//mcu
GlobalConfig
.
setMusicList
(
_data
.
musicList
);
//
GlobalConfig
.
setMusicListPrepare
(
_data
.
musicListPrepare
);
//提前上传的声音文件列表
GlobalConfig
.
setVideoCDNAddr
(
_data
.
videoCDNAddr
);
//cdn加速的拉流地址,直播的时候才使用
GlobalConfig
.
setMediaShareList
(
_data
.
sharedMediaList
);
//提前上传的媒体共享文件列表
//MCU地址
if
(
_data
.
mcuList
&&
_data
.
mcuList
.
length
>
0
)
{
//随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
mcuList
.
length
);
GlobalConfig
.
MCUServerIP
=
_data
.
mcuList
[
index
].
ip
||
""
;
GlobalConfig
.
MCUServerPort
=
_data
.
mcuList
[
index
].
port
||
""
;
loger
.
log
(
'初始->MCU->.'
,
GlobalConfig
.
MCUServerIP
,
GlobalConfig
.
MCUServerPort
);
}
loger
.
log
(
'获取课堂课堂信息完成.'
);
//包含整个课堂最全的信息,储存数据
if
(
_data
)
{
GlobalConfig
.
mcuDelay
=
_data
.
h5Delay
||
0
;
//mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用
GlobalConfig
.
className
=
_data
.
meetingName
||
""
;
GlobalConfig
.
classBeginTime
=
_data
.
beginTime
||
""
;
GlobalConfig
.
classEndTime
=
_data
.
endTime
||
""
;
GlobalConfig
.
userIp
=
_data
.
userIp
||
""
;
GlobalConfig
.
maxVideoChannels
=
_data
.
maxVideoChannels
;
GlobalConfig
.
maxAudioChannels
=
_data
.
maxAudioChannels
;
GlobalConfig
.
maxMediaChannels
=
Math
.
max
(
GlobalConfig
.
maxVideoChannels
,
GlobalConfig
.
maxAudioChannels
);
GlobalConfig
.
ssTunnelAppURL
=
_data
.
ssTunnelAppURL
||
''
;
//屏幕共享插件的地址
//视频质量相关设置,每次加入课堂都按最新的获取设置
GlobalConfig
.
fps
=
_data
.
fps
||
15
;
GlobalConfig
.
gop
=
_data
.
gop
||
3
;
GlobalConfig
.
videoQuality
=
parseInt
(
_data
.
videoQuality
);
GlobalConfig
.
curVideoQuality
=
GlobalConfig
.
videoQuality
;
//是否自动开始(身份是host的时候才用到的)
GlobalConfig
.
isAutoStartClass
=
_data
.
autoRecord
||
0
;
GlobalConfig
.
serverTime
=
_data
.
serverTime
||
new
Date
().
getTime
();
//获取服务器时间戳
GlobalConfig
.
serverAndLoacTimeDistanc
=
(
new
Date
().
getTime
()
-
GlobalConfig
.
serverTime
)
/
1000
;
//当前系统时间和服务器时间的差值 (秒)
loger
.
warn
(
"服务器时间:"
+
GlobalConfig
.
serverTime
+
" 系统时间:"
+
new
Date
().
getTime
()
+
" 时间差:"
+
GlobalConfig
.
serverAndLoacTimeDistanc
);
GlobalConfig
.
setDocListPrepare
(
_data
.
docListPrepare
);
//提前上传的文档列表
GlobalConfig
.
setRecordList
(
_data
.
recordList
);
//录制回放地址
GlobalConfig
.
setDocList
(
_data
.
docList
);
//文档地址
GlobalConfig
.
setMsList
(
_data
.
msList
);
//推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)
GlobalConfig
.
setRsList
(
_data
.
rsList
);
//播放m3u8格式的地址(录制回放时使用)
GlobalConfig
.
setMcuList
(
_data
.
mcuList
);
//mcu
GlobalConfig
.
setMusicList
(
_data
.
musicList
);
//
GlobalConfig
.
setMusicListPrepare
(
_data
.
musicListPrepare
);
//提前上传的声音文件列表
GlobalConfig
.
setVideoCDNAddr
(
_data
.
videoCDNAddr
);
//cdn加速的拉流地址,直播的时候才使用
GlobalConfig
.
setMediaShareList
(
_data
.
sharedMediaList
);
//提前上传的媒体共享文件列表
//MCU地址
if
(
_data
.
mcuList
&&
_data
.
mcuList
.
length
>
0
)
{
//随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
mcuList
.
length
);
GlobalConfig
.
MCUServerIP
=
_data
.
mcuList
[
index
].
ip
||
""
;
GlobalConfig
.
MCUServerPort
=
_data
.
mcuList
[
index
].
port
||
""
;
loger
.
log
(
'初始->MCU->.'
,
GlobalConfig
.
MCUServerIP
,
GlobalConfig
.
MCUServerPort
);
}
//录制回放时m3u8播流地址
if
(
_data
.
rsList
&&
_data
.
rsList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
rsList
.
length
);
GlobalConfig
.
RS_RECORD_PLAY_IP
=
_data
.
rsList
[
index
].
ip
||
""
;
GlobalConfig
.
RS_RECORD_PLAY_PORT
=
_data
.
rsList
[
index
].
port
||
""
;
loger
.
log
(
'初始->RS->.'
,
GlobalConfig
.
RS_RECORD_PLAY_IP
,
GlobalConfig
.
RS_RECORD_PLAY_PORT
);
}
//录制回放时m3u8播流地址
if
(
_data
.
rsList
&&
_data
.
rsList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
rsList
.
length
);
GlobalConfig
.
RS_RECORD_PLAY_IP
=
_data
.
rsList
[
index
].
ip
||
""
;
GlobalConfig
.
RS_RECORD_PLAY_PORT
=
_data
.
rsList
[
index
].
port
||
""
;
loger
.
log
(
'初始->RS->.'
,
GlobalConfig
.
RS_RECORD_PLAY_IP
,
GlobalConfig
.
RS_RECORD_PLAY_PORT
);
}
//上课中音视频推流地址
if
(
GlobalConfig
.
msList
&&
GlobalConfig
.
msList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
msList
.
length
);
GlobalConfig
.
MS_PUBLISH_IP
=
GlobalConfig
.
msList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
GlobalConfig
.
msList
[
index
].
port
||
""
;
}
loger
.
log
(
'初始->MS->.'
,
GlobalConfig
.
MS_PUBLISH_IP
,
GlobalConfig
.
MS_PUBLISH_PORT
);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)
if
(
GlobalConfig
.
pullRtmpList
&&
GlobalConfig
.
pullRtmpList
.
length
>
0
)
{
//有单独的rtmp拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
pullRtmpList
.
length
);
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
pullRtmpList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
pullRtmpList
[
index
].
port
||
""
;
}
else
{
//如果没有单独的rtmp拉流地址,和推流地址一样即可
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
MS_PUBLISH_IP
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
MS_PUBLISH_PORT
;
}
//上课中音视频推流地址
if
(
GlobalConfig
.
msList
&&
GlobalConfig
.
msList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
msList
.
length
);
GlobalConfig
.
MS_PUBLISH_IP
=
GlobalConfig
.
msList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
GlobalConfig
.
msList
[
index
].
port
||
""
;
}
loger
.
log
(
'初始->MS->.'
,
GlobalConfig
.
MS_PUBLISH_IP
,
GlobalConfig
.
MS_PUBLISH_PORT
);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)
if
(
GlobalConfig
.
pullRtmpList
&&
GlobalConfig
.
pullRtmpList
.
length
>
0
)
{
//有单独的rtmp拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
pullRtmpList
.
length
);
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
pullRtmpList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
pullRtmpList
[
index
].
port
||
""
;
}
else
{
//如果没有单独的rtmp拉流地址,和推流地址一样即可
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
MS_PUBLISH_IP
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
MS_PUBLISH_PORT
;
}
loger
.
log
(
'初始->MSPull->.'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
,
GlobalConfig
.
MS_PLAY_RTMP_PORT
);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)
if
(
GlobalConfig
.
hlsList
&&
GlobalConfig
.
hlsList
.
length
>
0
)
{
//有单独的hls拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
hlsList
.
length
);
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
hlsList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
hlsList
[
index
].
port
||
""
;
}
else
{
//没有单独的hls拉流地址,和录制回放地址一样即可
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
RS_RECORD_PLAY_IP
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
RS_RECORD_PLAY_PORT
;
}
loger
.
log
(
'初始->MSHls->.'
,
GlobalConfig
.
MS_PLAY_HLS_IP
,
GlobalConfig
.
MS_PLAY_HLS_PORT
);
//直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取
//20170531-新规则,所有课堂类型都支持加速
// if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){
if
(
GlobalConfig
.
videoCDNAddrList
.
length
>
0
)
{
//videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开;
let
listLen
=
GlobalConfig
.
videoCDNAddrList
.
length
;
for
(
let
i
=
0
;
i
<
listLen
;
i
++
)
{
let
ipItem
=
GlobalConfig
.
videoCDNAddrList
[
i
];
if
(
ipItem
)
{
if
(
ipItem
.
indexOf
(
'hls'
)
>=
0
)
{
//直播的时候m3u8拉流地址
GlobalConfig
.
MS_PLAY_HLS_IP
=
ipItem
;
//ip包含了端口
GlobalConfig
.
MS_PLAY_HLS_PORT
=
""
;
loger
.
log
(
'videoCDNAddr>初始->MSHls'
,
GlobalConfig
.
MS_PLAY_HLS_IP
);
}
else
if
(
ipItem
.
indexOf
(
'rtmppull'
)
>=
0
)
{
//直播的时候rtmp拉流地址
GlobalConfig
.
MS_PLAY_RTMP_IP
=
ipItem
;
//ip包含了端口
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
''
;
loger
.
log
(
'videoCDNAddr->初始->MSPull'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
);
}
loger
.
log
(
'初始->MSPull->.'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
,
GlobalConfig
.
MS_PLAY_RTMP_PORT
);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)
if
(
GlobalConfig
.
hlsList
&&
GlobalConfig
.
hlsList
.
length
>
0
)
{
//有单独的hls拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
hlsList
.
length
);
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
hlsList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
hlsList
[
index
].
port
||
""
;
}
else
{
//没有单独的hls拉流地址,和录制回放地址一样即可
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
RS_RECORD_PLAY_IP
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
RS_RECORD_PLAY_PORT
;
}
loger
.
log
(
'初始->MSHls->.'
,
GlobalConfig
.
MS_PLAY_HLS_IP
,
GlobalConfig
.
MS_PLAY_HLS_PORT
);
//直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取
//20170531-新规则,所有课堂类型都支持加速
// if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){
if
(
GlobalConfig
.
videoCDNAddrList
.
length
>
0
)
{
//videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开;
let
listLen
=
GlobalConfig
.
videoCDNAddrList
.
length
;
for
(
let
i
=
0
;
i
<
listLen
;
i
++
)
{
let
ipItem
=
GlobalConfig
.
videoCDNAddrList
[
i
];
if
(
ipItem
)
{
if
(
ipItem
.
indexOf
(
'hls'
)
>=
0
)
{
//直播的时候m3u8拉流地址
GlobalConfig
.
MS_PLAY_HLS_IP
=
ipItem
;
//ip包含了端口
GlobalConfig
.
MS_PLAY_HLS_PORT
=
""
;
loger
.
log
(
'videoCDNAddr>初始->MSHls'
,
GlobalConfig
.
MS_PLAY_HLS_IP
);
}
else
if
(
ipItem
.
indexOf
(
'rtmppull'
)
>=
0
)
{
//直播的时候rtmp拉流地址
GlobalConfig
.
MS_PLAY_RTMP_IP
=
ipItem
;
//ip包含了端口
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
''
;
loger
.
log
(
'videoCDNAddr->初始->MSPull'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
);
}
}
}
else
{
loger
.
log
(
'不需要videoCDNAddr->'
);
}
//文档地址
if
(
_data
.
docList
&&
_data
.
docList
.
length
>
0
)
{
//doc上传地址,随机获取一个
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
docList
.
length
);
loger
.
log
(
"docServer->"
,
_data
.
docList
[
index
]);
GlobalConfig
.
DOCServerIP
=
_data
.
docList
[
index
].
ip
||
""
;
GlobalConfig
.
DOCServerPort
=
_data
.
docList
[
index
].
port
||
""
;
loger
.
log
(
'初始->DOC->.'
,
GlobalConfig
.
DOCServerIP
,
GlobalConfig
.
DOCServerPort
);
}
//record
if
(
_data
.
recordList
&&
_data
.
recordList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
recordList
.
length
);
GlobalConfig
.
RecordServerIP
=
_data
.
recordList
[
index
].
ip
||
""
;
GlobalConfig
.
RecordServerPort
=
_data
.
recordList
[
index
].
port
||
""
;
loger
.
log
(
'初始->RECORD->.'
,
GlobalConfig
.
RecordServerIP
,
GlobalConfig
.
RecordServerPort
);
}
}
//这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟)
this
.
_emit
(
MessageTypes
.
CLASS_GET_INFO_SUCCESS
,
GlobalConfig
.
getClassInfo
());
if
(
_data
.
currentInfo
)
{
//根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息
loger
.
log
(
"本地同步最后一次保存过的课堂状态信息"
);
try
{
GlobalConfig
.
setClassStatusInfo
(
JSON
.
parse
(
_data
.
currentInfo
));
}
catch
(
err
)
{
GlobalConfig
.
setClassStatusInfo
(
_data
.
currentInfo
);
}
loger
.
log
(
GlobalConfig
.
classStatusInfo
);
}
else
{
loger
.
log
(
"还没有保存过课堂状信息"
);
loger
.
log
(
'不需要videoCDNAddr->'
);
}
//录制回放不需要获取ip信息和选点
if
(
GlobalConfig
.
isRecordPlayBack
)
{
if
(
_recordPlayback
)
{
//开启录制回放流程
loger
.
log
(
"开启录制回放流程"
);
_recordPlayback
.
readyRecordPlay
();
}
else
{
loger
.
warn
(
"开启录制回放流程失败->还未创建模块"
);
}
}
else
{
//根据用户的userIp获取信息,选点
this
.
getUserIpInfo
();
//文档地址
if
(
_data
.
docList
&&
_data
.
docList
.
length
>
0
)
{
//doc上传地址,随机获取一个
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
docList
.
length
);
loger
.
log
(
"docServer->"
,
_data
.
docList
[
index
]);
GlobalConfig
.
DOCServerIP
=
_data
.
docList
[
index
].
ip
||
""
;
GlobalConfig
.
DOCServerPort
=
_data
.
docList
[
index
].
port
||
""
;
loger
.
log
(
'初始->DOC->.'
,
GlobalConfig
.
DOCServerIP
,
GlobalConfig
.
DOCServerPort
);
}
//record
if
(
_data
.
recordList
&&
_data
.
recordList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
recordList
.
length
);
GlobalConfig
.
RecordServerIP
=
_data
.
recordList
[
index
].
ip
||
""
;
GlobalConfig
.
RecordServerPort
=
_data
.
recordList
[
index
].
port
||
""
;
loger
.
log
(
'初始->RECORD->.'
,
GlobalConfig
.
RecordServerIP
,
GlobalConfig
.
RecordServerPort
);
}
}
//ChatApe
// 发送聊天消息
_sendChatMsg
(
_messageInfo
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_messageInfo
===
null
||
EngineUtils
.
isEmptyObject
(
_messageInfo
))
{
loger
.
log
(
'发送聊天消息失败->参数错误'
,
_messageInfo
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_chat_ape
)
{
_chat_ape
.
sendChatMsg
(
_messageInfo
);
}
}
//监听摄像头麦克风状态
userDeviecStatusChange
(
_data
)
{
/* nodeId:GlobalConfig.nodeId,
userRole:GlobalConfig.userRole,
userName:GlobalConfig.userName,
userId:GlobalConfig.userId,
openCamera:GlobalConfig.openCamera,
openMicrophones:GlobalConfig.openMicrophones*/
if
(
_confer_ape
)
{
_confer_ape
.
updaterUserDeviecStatusChange
(
_data
);
}
}
//这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟)
this
.
_emit
(
MessageTypes
.
CLASS_GET_INFO_SUCCESS
,
GlobalConfig
.
getClassInfo
());
//屏幕共享
//开始屏幕共享
_publishScreenShare
(
_param
)
{
if
(
_video_ape
)
{
_video_ape
.
publishScreenShare
(
_param
);
if
(
_data
.
currentInfo
)
{
//根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息
loger
.
log
(
"本地同步最后一次保存过的课堂状态信息"
);
try
{
GlobalConfig
.
setClassStatusInfo
(
JSON
.
parse
(
_data
.
currentInfo
));
}
catch
(
err
)
{
GlobalConfig
.
setClassStatusInfo
(
_data
.
currentInfo
);
}
loger
.
log
(
GlobalConfig
.
classStatusInfo
);
}
else
{
loger
.
log
(
"还没有保存过课堂状信息"
);
}
//停止屏幕共享
_stopPublishScreenShare
(
_param
)
{
if
(
_video_ape
)
{
_video_ape
.
stopPublishScreenShare
(
_param
);
//录制回放不需要获取ip信息和选点
if
(
GlobalConfig
.
isRecordPlayBack
)
{
if
(
_recordPlayback
)
{
//开启录制回放流程
loger
.
log
(
"开启录制回放流程"
);
_recordPlayback
.
readyRecordPlay
();
}
else
{
loger
.
warn
(
"开启录制回放流程失败->还未创建模块"
);
}
}
else
{
//根据用户的userIp获取信息,选点
this
.
getUserIpInfo
();
}
//VidoeApe
videoUpdate
(
_data
)
{
//视频同步的消息发送改变,需要通知ferApe模块中的用户更新状态
if
(
_confer_ape
)
{
_confer_ape
.
updaterRosterStatus
(
_data
);
}
}
//ChatApe
// 发送聊天消息
_sendChatMsg
(
_messageInfo
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_messageInfo
===
null
||
EngineUtils
.
isEmptyObject
(
_messageInfo
))
{
loger
.
log
(
'发送聊天消息失败->参数错误'
,
_messageInfo
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_chat_ape
)
{
_chat_ape
.
sendChatMsg
(
_messageInfo
);
}
}
_sendVideoBroadcastMsg
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
sendVideoBroadcastMsg
(
_param
);
}
//监听摄像头麦克风状态
userDeviecStatusChange
(
_data
)
{
/* nodeId:GlobalConfig.nodeId,
userRole:GlobalConfig.userRole,
userName:GlobalConfig.userName,
userId:GlobalConfig.userId,
openCamera:GlobalConfig.openCamera,
openMicrophones:GlobalConfig.openMicrophones*/
if
(
_confer_ape
)
{
_confer_ape
.
updaterUserDeviecStatusChange
(
_data
);
}
}
_getVideoPlayPath
(
_param
)
{
//屏幕共享
//开始屏幕共享
_publishScreenShare
(
_param
)
{
if
(
_video_ape
)
{
return
_video_ape
.
getPlayVideoPath
(
_param
);
_video_ape
.
publishScreenShare
(
_param
);
}
}
_getVideoPublishPath
(
_param
)
{
//停止屏幕共享
_stopPublishScreenShare
(
_param
)
{
if
(
_video_ape
)
{
return
_video_ape
.
getPublishVideoPath
(
_param
);
_video_ape
.
stopPublishScreenShare
(
_param
);
}
}
//VidoeApe
videoUpdate
(
_data
)
{
//视频同步的消息发送改变,需要通知ferApe模块中的用户更新状态
if
(
_confer_ape
)
{
_confer_ape
.
updaterRosterStatus
(
_data
);
}
}
_getVideoAllChannelInfo
(
_param
)
{
if
(
_video_ape
)
{
return
_video_ape
.
getAllChannelInfo
(
_param
);
}
_sendVideoBroadcastMsg
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
sendVideoBroadcastMsg
(
_param
);
}
}
_publishVideo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
publishVideo
(
_param
);
}
_getVideoPlayPath
(
_param
)
{
if
(
_video_ape
)
{
return
_video_ape
.
getPlayVideoPath
(
_param
);
}
}
_stopPublishVideo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
stopPublishVideo
(
_param
);
}
_getVideoPublishPath
(
_param
)
{
if
(
_video_ape
)
{
return
_video_ape
.
getPublishVideoPath
(
_param
);
}
}
//AudioApe
audioUpdate
(
_data
)
{
//音频同步的消息发送改变,需要通知ferApe模块中的用户更新状态
if
(
_confer_ape
)
{
_confer_ape
.
updaterRosterStatus
(
_data
);
}
_getVideoAllChannelInfo
(
_param
)
{
if
(
_video_ape
)
{
return
_video_ape
.
getAllChannelInfo
(
_param
);
}
}
sendAudioCommandMsg
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
sendAudioBroadcastMsg
(
_param
);
}
_publishVideo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
publishVideo
(
_param
);
}
}
_getPlayAudioPath
(
_param
)
{
if
(
_audio_ape
)
{
return
_audio_ape
.
getAudioPlayPath
(
_param
);
}
_stopPublishVideo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
stopPublishVideo
(
_param
);
}
}
_getPublishAudioPath
(
_param
)
{
if
(
_audio_ape
)
{
return
_audio_ape
.
getAudioPublishPath
(
_param
);
}
//AudioApe
audioUpdate
(
_data
)
{
//音频同步的消息发送改变,需要通知ferApe模块中的用户更新状态
if
(
_confer_ape
)
{
_confer_ape
.
updaterRosterStatus
(
_data
);
}
}
_getAudioAllChannelInfo
(
_param
)
{
if
(
_audio_ape
)
{
return
_audio_ape
.
getAllChannelInfo
(
_param
);
}
sendAudioCommandMsg
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
sendAudioBroadcastMsg
(
_param
);
}
}
_publishAudio
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
publishAudio
(
_param
);
}
_getPlayAudioPath
(
_param
)
{
if
(
_audio_ape
)
{
return
_audio_ape
.
getAudioPlayPath
(
_param
);
}
}
_stopPublishAudio
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
stopPublishAudio
(
_param
);
}
_getPublishAudioPath
(
_param
)
{
if
(
_audio_ape
)
{
return
_audio_ape
.
getAudioPublishPath
(
_param
);
}
}
//WhiteBoardApe
// 添加标注,发送信息
_sendInsertAnnotaion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendInsetAnnotaion
(
_param
);
}
_getAudioAllChannelInfo
(
_param
)
{
if
(
_audio_ape
)
{
return
_audio_ape
.
getAllChannelInfo
(
_param
);
}
}
//CursorApe
// 添加鼠标同步
_sendInsertCursor
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_cursor_ape
)
{
_cursor_ape
.
sendInsertCursor
(
_param
);
}
_publishAudio
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
publishAudio
(
_param
);
}
}
//删除当前页面上的所有标注
_sendDeleteCurPageAnnotation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendDeleteCurPageAnnotation
(
_param
);
}
_stopPublishAudio
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
stopPublishAudio
(
_param
);
}
}
//删除所有标注
_sendDeleteAllAnnotation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendDeleteAllAnnotation
(
_param
);
}
//WhiteBoardApe
// 添加标注,发送信息
_sendInsertAnnotaion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendInsetAnnotaion
(
_param
);
}
}
//返回上一步标注
_sendGotoPrev
(
_param
)
{
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendGotoPrev
(
_param
);
}
//CursorApe
// 添加鼠标同步
_sendInsertCursor
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_cursor_ape
)
{
_cursor_ape
.
sendInsertCursor
(
_param
);
}
}
//DocApe
//获取文档的所有资源地址
_getDocFullAddress
(
_param
)
{
if
(
_doc_ape
)
{
return
_doc_ape
.
getDocFullAddress
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建无法获取"
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"文档模块还没有创建无法获取"
};
}
//删除当前页面上的所有标注
_sendDeleteCurPageAnnotation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendDeleteCurPageAnnotation
(
_param
);
}
}
//获取文档完整路径
_getDocImageFullPath
(
_param
)
{
if
(
_doc_ape
)
{
return
_doc_ape
.
getDocImageFullPath
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建无法获取"
);
return
[];
}
//删除所有标注
_sendDeleteAllAnnotation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendDeleteAllAnnotation
(
_param
);
}
}
_getDocPDFFullPath
(
_param
)
{
if
(
_doc_ape
)
{
return
_doc_ape
.
getDocPDFFullPath
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建,无法获取"
);
return
[];
}
//返回上一步标注
_sendGotoPrev
(
_param
)
{
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
sendGotoPrev
(
_param
);
}
}
//DocApe
//获取文档的所有资源地址
_getDocFullAddress
(
_param
)
{
if
(
_doc_ape
)
{
return
_doc_ape
.
getDocFullAddress
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建无法获取"
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"文档模块还没有创建无法获取"
};
}
}
//获取文档完整路径
_getDocImageFullPath
(
_param
)
{
if
(
_doc_ape
)
{
return
_doc_ape
.
getDocImageFullPath
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建无法获取"
);
return
[];
}
}
_getDocPDFFullPath
(
_param
)
{
if
(
_doc_ape
)
{
return
_doc_ape
.
getDocPDFFullPath
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建,无法获取"
);
return
[];
}
}
//上传文档
_sendDocumentUpload
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentUpload
(
_param
);
}
}
//切换文档
_sendDocumentSwitchDoc
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchDoc
(
_param
);
}
}
//上传文档
_sendDocumentUpload
(
_param
)
{
//操作文档(翻页)
_sendDocumentSwitchPage
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
document
Upload
(
_param
);
_doc_ape
.
document
SwitchPage
(
_param
);
}
}
//切换文档
_sendDocumentSwitchDoc
(
_param
)
{
//操作文档(页码上的动画步骤操作)
_sendDocumentSwitchAnimation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitch
Doc
(
_param
);
_doc_ape
.
documentSwitch
Animation
(
_param
);
}
}
//操作文档(翻页)
_sendDocumentSwitchPage
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchPage
(
_param
);
}
}
//操作文档(页码上的动画步骤操作)
_sendDocumentSwitchAnimation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchAnimation
(
_param
);
}
}
//操作文档(缩放、滚动...)
_sendDocumentCommand
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentCommand
(
_param
);
}
//操作文档(缩放、滚动...)
_sendDocumentCommand
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentCommand
(
_param
);
}
}
//删除文档
_sendDocumentDelete
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentDelete
(
_param
);
}
//删除文档
_sendDocumentDelete
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentDelete
(
_param
);
}
}
//删除所有文档
_documentDeleteAll
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentDeleteAll
(
_param
);
}
//删除所有文档
_documentDeleteAll
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentDeleteAll
(
_param
);
}
}
//// 文档变更,白板也需要做处理
docUpdateHandler
(
_data
)
{
if
(
!
_mcu
.
connected
&&
!
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//loger.log('Doc UpdateId ->');
//loger.log(_data);
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
docUpdateHandler
(
_data
);
}
//// 文档变更,白板也需要做处理
docUpdateHandler
(
_data
)
{
if
(
!
_mcu
.
connected
&&
!
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//loger.log('Doc UpdateId ->');
//loger.log(_data);
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
docUpdateHandler
(
_data
);
}
}
//文档删除,白板也需要做处理
docDeleteHandler
(
_data
)
{
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
docDeleteHandler
(
_data
);
}
//文档删除,白板也需要做处理
docDeleteHandler
(
_data
)
{
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
docDeleteHandler
(
_data
);
}
}
//文档加入频道成功,同步到MCU服务器上的数据
docJoinChannelSuccess
()
{
loger
.
log
(
"docJoinChannelSuccess->isHost="
,
GlobalConfig
.
isHost
,
"length="
,
GlobalConfig
.
docListPrepare
.
length
);
//loger.log("docJoinChannelSuccess docListPrepare=");
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
docListPrepare
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
docListPrepare
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
docListPrepare
[
i
];
if
(
value
)
{
//loger.log("判断是否需要把提前上传的文档上传到mcu", value);
let
paramInfo
=
{
"pageNum"
:
value
.
pdfSize
,
"fileName"
:
value
.
name
,
"fileType"
:
value
.
type
,
"relativeUrl"
:
value
.
relativeLocation
,
"url"
:
value
.
absoluteLocation
,
"creatUserId"
:
value
.
createUserID
,
"docId"
:
value
.
id
,
"md5"
:
value
.
MD5
,
"visible"
:
false
};
this
.
_sendDocumentUpload
(
paramInfo
);
}
//文档加入频道成功,同步到MCU服务器上的数据
docJoinChannelSuccess
()
{
loger
.
log
(
"docJoinChannelSuccess->isHost="
,
GlobalConfig
.
isHost
,
"length="
,
GlobalConfig
.
docListPrepare
.
length
);
//loger.log("docJoinChannelSuccess docListPrepare=");
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
docListPrepare
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
docListPrepare
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
docListPrepare
[
i
];
if
(
value
)
{
//loger.log("判断是否需要把提前上传的文档上传到mcu", value);
let
paramInfo
=
{
"pageNum"
:
value
.
pdfSize
,
"fileName"
:
value
.
name
,
"fileType"
:
value
.
type
,
"relativeUrl"
:
value
.
relativeLocation
,
"url"
:
value
.
absoluteLocation
,
"creatUserId"
:
value
.
createUserID
,
"docId"
:
value
.
id
,
"md5"
:
value
.
MD5
,
"visible"
:
false
};
this
.
_sendDocumentUpload
(
paramInfo
);
}
}
}
}
//媒体共享模块的接口
//上传
_sendMediaSharedUpload
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedUpload
(
_param
);
}
}
//Sass删除媒体文件数据
_sassDeletMediaShare
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//媒体共享模块的接口
//上传
_sendMediaSharedUpload
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedUpload
(
_param
);
}
}
//判断传入的参数是否存在
if
(
_param
==
null
||
EngineUtils
.
isEmptyObject
(
_param
))
{
loger
.
error
(
'删除媒体文件失败->参数错误'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_MEDIASHARE_DELETE_FAILED_PARAM
);
return
;
}
//判断必要的参数字段值
if
(
_param
.
itemIdx
==
null
||
isNaN
(
_param
.
itemIdx
)
||
_param
.
fileId
==
null
||
_param
.
fileId
==
""
)
{
loger
.
error
(
'删除媒体文件失败->'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_MEDIASHARE_DELETE_FAILED_PARAM
);
return
;
}
loger
.
log
(
'删除媒体文件->'
,
_param
);
//音乐共享模块的接口
//上传
_sendMusicSharedUpload
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_musicShareApe
)
{
_musicShareApe
.
musicSharedUpload
(
_param
);
}
}
if
(
_sass
)
{
_sass
.
sassDeletMediaShare
(
_param
);
}
}
//删除
_sendMediaSharedDelete
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedDelete
(
_param
);
}
}
//更新媒体文件的状态信息
_sendMediaSharedUpdate
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedUpdate
(
_param
);
}
}
//播放
_sendMediaSharedPlay
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedPlay
(
_param
);
}
}
//停止
_sendMediaSharedStop
(
_param
)
{
//Sass删除媒体文件数据
_sassDeletMediaShare
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//判断传入的参数是否存在
if
(
_param
==
null
||
EngineUtils
.
isEmptyObject
(
_param
))
{
loger
.
error
(
'删除媒体文件失败->参数错误'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_MEDIASHARE_DELETE_FAILED_PARAM
);
return
;
}
//判断必要的参数字段值
if
(
_param
.
itemIdx
==
null
||
isNaN
(
_param
.
itemIdx
)
||
_param
.
fileId
==
null
||
_param
.
fileId
==
""
)
{
loger
.
error
(
'删除媒体文件失败->'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_MEDIASHARE_DELETE_FAILED_PARAM
);
return
;
}
loger
.
log
(
'删除媒体文件->'
,
_param
);
if
(
_sass
)
{
_sass
.
sassDeletMediaShare
(
_param
);
}
}
//删除
_sendMediaSharedDelete
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedDelete
(
_param
);
}
}
//音乐更新
_sendMusicSharedUpdate
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_musicShareApe
)
{
_musicShareApe
.
musicSharedUpdate
(
_param
);
}
}
//音乐播放
_sendMusicSharedPlay
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedStop
(
_param
);
if
(
_musicShareApe
)
{
_musicShareApe
.
musicSharedPlay
(
_param
);
}
}
//音乐停止
_sendMusicSharedStop
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_musicShareApe
)
{
_musicShareApe
.
musicSharedStop
(
_param
);
}
}
//媒体共享模块加入频道成功,同步到MCU服务器上的数据
mediaShareApeJoinChannelSuccess
()
{
loger
.
log
(
"媒体共享模块加入频道成功->isHost="
,
GlobalConfig
.
isHost
,
"length="
,
GlobalConfig
.
sharedMediaList
.
length
);
console
.
log
(
"媒体共享模数据->"
,
GlobalConfig
.
sharedMediaList
);
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
sharedMediaList
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
sharedMediaList
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
sharedMediaList
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
,
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
};
this
.
_sendMediaSharedUpload
(
paramInfo
);
}
}
}
//更新媒体文件的状态信息
_sendMediaSharedUpdate
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedUpdate
(
_param
);
}
}
//录制回放相关的处理------------------------------------------------
//录制回放初始化
_initRecordPlayback
(
_param
)
{
//{"classId":"1653304953","portal":"112.126.80.182:80","userRole":"normal","userId":0}
if
(
_param
==
null
)
{
loger
.
error
(
'录制回放初始化失败->参数错误'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_INIT_RECORD_PLAY_BACK_FAILED
);
//播放
_sendMediaSharedPlay
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//判断必要的参数字段值
if
(
_param
.
classId
==
null
||
isNaN
(
_param
.
classId
)
||
_param
.
portal
==
null
||
_param
.
portal
==
""
)
{
loger
.
error
(
'录制回放初始化失败->'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_INIT_RECORD_PLAY_BACK_FAILED
);
return
;
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedPlay
(
_param
);
}
loger
.
log
(
'录制回放初始化->'
,
_param
);
}
//停止
//保存参数
GlobalConfig
.
isRecordPlayBack
=
true
;
//设置为录制回放状态
GlobalConfig
.
classId
=
parseInt
(
_param
.
classId
);
GlobalConfig
.
portal
=
_param
.
portal
;
GlobalConfig
.
userRole
=
ApeConsts
.
normal
;
//*************很重要,录制回放的时候,身份模式是普通人********
GlobalConfig
.
userId
=
_param
.
userId
||
"0"
;
GlobalConfig
.
userName
=
_param
.
userName
||
""
;
_sendMediaSharedStop
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedStop
(
_param
);
}
}
//获取课堂最完整的数据,录制回放需要获取课堂数据
if
(
_sass
)
{
_sass
.
getClassParam
();
//音乐共享模块加入频道成功,同步到MCU服务器上的数据
musicShareApeJoinChannelSuccess
()
{
loger
.
log
(
"媒体共享模块加入频道成功->isHost="
,
GlobalConfig
.
isHost
,
"length="
,
GlobalConfig
.
sharedMusicList
.
length
);
console
.
log
(
"媒体共享模数据->"
,
GlobalConfig
.
sharedMusicList
);
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
sharedMusicList
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
sharedMusicList
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
sharedMusicList
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
,
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
};
this
.
_sendMusicSharedUpload
(
paramInfo
);
}
}
}
}
//开始录制回放
_startRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
startRecordPlayback
(
_param
);
//媒体共享模块加入频道成功,同步到MCU服务器上的数据
mediaShareApeJoinChannelSuccess
()
{
loger
.
log
(
"媒体共享模块加入频道成功->isHost="
,
GlobalConfig
.
isHost
,
"length="
,
GlobalConfig
.
sharedMediaList
.
length
);
console
.
log
(
"媒体共享模数据->"
,
GlobalConfig
.
sharedMediaList
);
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
sharedMediaList
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
sharedMediaList
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
sharedMediaList
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
,
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
};
this
.
_sendMediaSharedUpload
(
paramInfo
);
}
}
}
}
//停止录制回放
_stopRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
stopRecordPlayback
(
_param
);
}
//录制回放相关的处理------------------------------------------------
//录制回放初始化
_initRecordPlayback
(
_param
)
{
//{"classId":"1653304953","portal":"112.126.80.182:80","userRole":"normal","userId":0}
if
(
_param
==
null
)
{
loger
.
error
(
'录制回放初始化失败->参数错误'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_INIT_RECORD_PLAY_BACK_FAILED
);
return
;
}
//判断必要的参数字段值
if
(
_param
.
classId
==
null
||
isNaN
(
_param
.
classId
)
||
_param
.
portal
==
null
||
_param
.
portal
==
""
)
{
loger
.
error
(
'录制回放初始化失败->'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_INIT_RECORD_PLAY_BACK_FAILED
);
return
;
}
loger
.
log
(
'录制回放初始化->'
,
_param
);
//暂停录制回放
_pauseRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
pauseRecordPlayback
(
_param
);
}
//保存参数
GlobalConfig
.
isRecordPlayBack
=
true
;
//设置为录制回放状态
GlobalConfig
.
classId
=
parseInt
(
_param
.
classId
);
GlobalConfig
.
portal
=
_param
.
portal
;
GlobalConfig
.
userRole
=
ApeConsts
.
normal
;
//*************很重要,录制回放的时候,身份模式是普通人********
GlobalConfig
.
userId
=
_param
.
userId
||
"0"
;
GlobalConfig
.
userName
=
_param
.
userName
||
""
;
//获取课堂最完整的数据,录制回放需要获取课堂数据
if
(
_sass
)
{
_sass
.
getClassParam
();
}
}
//seek录制回放
_seekRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
seekRecordPlayback
(
_param
);
}
//开始录制回放
_startRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
startRecordPlayback
(
_param
);
}
}
//录制回放状态更新
_recordPlaybackClearDataHandler
(
_param
)
{
loger
.
log
(
"录制回放状态更新->"
)
if
(
_doc_ape
)
{
_doc_ape
.
clearData
();
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
clearData
();
}
if
(
_video_ape
)
{
_video_ape
.
clearData
();
}
//停止录制回放
_stopRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
stopRecordPlayback
(
_param
);
}
}
//录制回放加入 课堂成功
_joinRecordPlaybackSuccessHandler
(
_data
)
{
loger
.
log
(
'加入录制回放成功.'
);
GlobalConfig
.
setCurrentStatus
(
GlobalConfig
.
statusCode_2
);
//返回给客户端初始化成功的数据
let
joinClassSuccessCallBackData
=
{};
joinClassSuccessCallBackData
.
isRecordPlayBack
=
GlobalConfig
.
isRecordPlayBack
;
joinClassSuccessCallBackData
.
DOCServerIP
=
GlobalConfig
.
DOCServerIP
;
joinClassSuccessCallBackData
.
DOCServerPort
=
GlobalConfig
.
DOCServerPort
;
joinClassSuccessCallBackData
.
classStatus
=
GlobalConfig
.
classStatus
;
joinClassSuccessCallBackData
.
classId
=
GlobalConfig
.
classId
;
joinClassSuccessCallBackData
.
className
=
GlobalConfig
.
className
;
joinClassSuccessCallBackData
.
h5Module
=
GlobalConfig
.
h5Module
;
joinClassSuccessCallBackData
.
isHost
=
GlobalConfig
.
isHost
;
//
joinClassSuccessCallBackData
.
maxAudioChannels
=
GlobalConfig
.
maxAudioChannels
;
joinClassSuccessCallBackData
.
maxVideoChannels
=
GlobalConfig
.
maxVideoChannels
;
joinClassSuccessCallBackData
.
maxMediaChannels
=
GlobalConfig
.
maxMediaChannels
;
joinClassSuccessCallBackData
.
mcuDelay
=
GlobalConfig
.
mcuDelay
;
joinClassSuccessCallBackData
.
msType
=
GlobalConfig
.
msType
;
joinClassSuccessCallBackData
.
nodeId
=
GlobalConfig
.
nodeId
;
joinClassSuccessCallBackData
.
password
=
GlobalConfig
.
password
;
joinClassSuccessCallBackData
.
passwordRequired
=
GlobalConfig
.
passwordRequired
;
// 老师的默认是true
//GlobalConfig.passwordRequired 老师的默认是true
//GlobalConfig.portal=_data.portal;
joinClassSuccessCallBackData
.
role
=
GlobalConfig
.
role
;
joinClassSuccessCallBackData
.
siteId
=
GlobalConfig
.
siteId
;
joinClassSuccessCallBackData
.
topNodeID
=
GlobalConfig
.
topNodeID
;
joinClassSuccessCallBackData
.
userId
=
GlobalConfig
.
userId
;
joinClassSuccessCallBackData
.
userName
=
GlobalConfig
.
userName
;
joinClassSuccessCallBackData
.
userRole
=
GlobalConfig
.
userRole
;
joinClassSuccessCallBackData
.
userType
=
GlobalConfig
.
userType
;
joinClassSuccessCallBackData
.
siteId
=
GlobalConfig
.
siteId
;
joinClassSuccessCallBackData
.
classId
=
GlobalConfig
.
classId
;
joinClassSuccessCallBackData
.
userRole
=
GlobalConfig
.
userRole
;
joinClassSuccessCallBackData
.
userId
=
GlobalConfig
.
userId
;
joinClassSuccessCallBackData
.
passwordRequired
=
GlobalConfig
.
passwordRequired
;
joinClassSuccessCallBackData
.
classType
=
GlobalConfig
.
classType
||
ApeConsts
.
CLASS_TYPE_1
;
joinClassSuccessCallBackData
.
country
=
GlobalConfig
.
country
;
//国家
joinClassSuccessCallBackData
.
city
=
GlobalConfig
.
city
;
//城市
joinClassSuccessCallBackData
.
province
=
GlobalConfig
.
province
;
//服务商
joinClassSuccessCallBackData
.
isp
=
GlobalConfig
.
isp
;
//服务商
joinClassSuccessCallBackData
.
classTimestamp
=
GlobalConfig
.
classTimestamp
;
//课堂进行的累积时间
joinClassSuccessCallBackData
.
recordTimestamp
=
GlobalConfig
.
recordTimestamp
;
//录制累积的总时间
joinClassSuccessCallBackData
.
recordPlaybackMaxTime
=
GlobalConfig
.
recordPlaybackMaxTime
;
//录制回放的总时间
joinClassSuccessCallBackData
.
fps
=
GlobalConfig
.
fps
;
joinClassSuccessCallBackData
.
gop
=
GlobalConfig
.
gop
;
joinClassSuccessCallBackData
.
videoQuality
=
GlobalConfig
.
videoQuality
;
joinClassSuccessCallBackData
.
ssTunnelAppURL
=
GlobalConfig
.
ssTunnelAppURL
;
joinClassSuccessCallBackData
.
currentSceneTableId
=
GlobalConfig
.
currentSceneTableId
;
//文档区域的模块显示
loger
.
log
(
joinClassSuccessCallBackData
);
//和加入课堂成功使用同样的消息处理
this
.
_emit
(
MessageTypes
.
CLASS_JOIN_SUCCESS
,
joinClassSuccessCallBackData
);
}
// //答题卡
_creatQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
creatQuestion
(
_param
);
}
//暂停录制回放
_pauseRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
pauseRecordPlayback
(
_param
);
}
_getQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
getQuestion
(
_param
);
}
}
//seek录制回放
_seekRecordPlayback
(
_param
)
{
if
(
_recordPlayback
)
{
_recordPlayback
.
seekRecordPlayback
(
_param
);
}
_getQuestionResult
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
getQuestionResult
(
_param
);
}
}
//录制回放状态更新
_recordPlaybackClearDataHandler
(
_param
)
{
loger
.
log
(
"录制回放状态更新->"
)
if
(
_doc_ape
)
{
_doc_ape
.
clearData
();
}
_stopQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
stopQuestion
(
_param
);
}
if
(
_whiteboard_ape
)
{
_whiteboard_ape
.
clearData
();
}
_sendAnswer
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
sendAnswer
(
_param
);
}
if
(
_video_ape
)
{
_video_ape
.
clearData
();
}
}
//录制回放加入 课堂成功
_joinRecordPlaybackSuccessHandler
(
_data
)
{
loger
.
log
(
'加入录制回放成功.'
);
GlobalConfig
.
setCurrentStatus
(
GlobalConfig
.
statusCode_2
);
//返回给客户端初始化成功的数据
let
joinClassSuccessCallBackData
=
{};
joinClassSuccessCallBackData
.
isRecordPlayBack
=
GlobalConfig
.
isRecordPlayBack
;
joinClassSuccessCallBackData
.
DOCServerIP
=
GlobalConfig
.
DOCServerIP
;
joinClassSuccessCallBackData
.
DOCServerPort
=
GlobalConfig
.
DOCServerPort
;
joinClassSuccessCallBackData
.
classStatus
=
GlobalConfig
.
classStatus
;
joinClassSuccessCallBackData
.
classId
=
GlobalConfig
.
classId
;
joinClassSuccessCallBackData
.
className
=
GlobalConfig
.
className
;
joinClassSuccessCallBackData
.
h5Module
=
GlobalConfig
.
h5Module
;
joinClassSuccessCallBackData
.
isHost
=
GlobalConfig
.
isHost
;
//
joinClassSuccessCallBackData
.
maxAudioChannels
=
GlobalConfig
.
maxAudioChannels
;
joinClassSuccessCallBackData
.
maxVideoChannels
=
GlobalConfig
.
maxVideoChannels
;
joinClassSuccessCallBackData
.
maxMediaChannels
=
GlobalConfig
.
maxMediaChannels
;
joinClassSuccessCallBackData
.
mcuDelay
=
GlobalConfig
.
mcuDelay
;
joinClassSuccessCallBackData
.
msType
=
GlobalConfig
.
msType
;
joinClassSuccessCallBackData
.
nodeId
=
GlobalConfig
.
nodeId
;
joinClassSuccessCallBackData
.
password
=
GlobalConfig
.
password
;
joinClassSuccessCallBackData
.
passwordRequired
=
GlobalConfig
.
passwordRequired
;
// 老师的默认是true
//GlobalConfig.passwordRequired 老师的默认是true
//GlobalConfig.portal=_data.portal;
joinClassSuccessCallBackData
.
role
=
GlobalConfig
.
role
;
joinClassSuccessCallBackData
.
siteId
=
GlobalConfig
.
siteId
;
joinClassSuccessCallBackData
.
topNodeID
=
GlobalConfig
.
topNodeID
;
joinClassSuccessCallBackData
.
userId
=
GlobalConfig
.
userId
;
joinClassSuccessCallBackData
.
userName
=
GlobalConfig
.
userName
;
joinClassSuccessCallBackData
.
userRole
=
GlobalConfig
.
userRole
;
joinClassSuccessCallBackData
.
userType
=
GlobalConfig
.
userType
;
joinClassSuccessCallBackData
.
siteId
=
GlobalConfig
.
siteId
;
joinClassSuccessCallBackData
.
classId
=
GlobalConfig
.
classId
;
joinClassSuccessCallBackData
.
userRole
=
GlobalConfig
.
userRole
;
joinClassSuccessCallBackData
.
userId
=
GlobalConfig
.
userId
;
joinClassSuccessCallBackData
.
passwordRequired
=
GlobalConfig
.
passwordRequired
;
joinClassSuccessCallBackData
.
classType
=
GlobalConfig
.
classType
||
ApeConsts
.
CLASS_TYPE_1
;
joinClassSuccessCallBackData
.
country
=
GlobalConfig
.
country
;
//国家
joinClassSuccessCallBackData
.
city
=
GlobalConfig
.
city
;
//城市
joinClassSuccessCallBackData
.
province
=
GlobalConfig
.
province
;
//服务商
joinClassSuccessCallBackData
.
isp
=
GlobalConfig
.
isp
;
//服务商
joinClassSuccessCallBackData
.
classTimestamp
=
GlobalConfig
.
classTimestamp
;
//课堂进行的累积时间
joinClassSuccessCallBackData
.
recordTimestamp
=
GlobalConfig
.
recordTimestamp
;
//录制累积的总时间
joinClassSuccessCallBackData
.
recordPlaybackMaxTime
=
GlobalConfig
.
recordPlaybackMaxTime
;
//录制回放的总时间
joinClassSuccessCallBackData
.
fps
=
GlobalConfig
.
fps
;
joinClassSuccessCallBackData
.
gop
=
GlobalConfig
.
gop
;
joinClassSuccessCallBackData
.
videoQuality
=
GlobalConfig
.
videoQuality
;
joinClassSuccessCallBackData
.
ssTunnelAppURL
=
GlobalConfig
.
ssTunnelAppURL
;
joinClassSuccessCallBackData
.
currentSceneTableId
=
GlobalConfig
.
currentSceneTableId
;
//文档区域的模块显示
loger
.
log
(
joinClassSuccessCallBackData
);
//和加入课堂成功使用同样的消息处理
this
.
_emit
(
MessageTypes
.
CLASS_JOIN_SUCCESS
,
joinClassSuccessCallBackData
);
}
// //答题卡
_creatQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
creatQuestion
(
_param
);
}
}
_getQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
getQuestion
(
_param
);
}
}
_getQuestionResult
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
getQuestionResult
(
_param
);
}
}
_stopQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
stopQuestion
(
_param
);
}
}
_sendAnswer
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_questionApe
)
{
_questionApe
.
sendAnswer
(
_param
);
}
}
}
...
...
src/GlobalConfig.js
查看文件 @
4d9a04e
...
...
@@ -202,6 +202,15 @@ class GlobalConfig {
return
this
.
sharedMediaList
;
}
//储存已经提前上传的媒体共享文件列表
static
setMusicShareList
(
_data
)
{
if
(
_data
==
null
)
return
;
this
.
sharedMusicList
=
_data
;
}
static
getMusicShareList
()
{
return
this
.
sharedMusicList
;
}
//储存录制列表
static
setRecordList
(
_data
)
{
if
(
_data
==
null
)
return
;
...
...
@@ -429,6 +438,7 @@ GlobalConfig.classDetail = {}; //Sass直接返回的当前课堂基本信息
//从Sass获取的
GlobalConfig
.
sharedMediaList
=
[];
// 已经提前上传的媒体文件列表,进入课堂后需要自动加载
GlobalConfig
.
sharedMusicList
=
[];
// 已经提前上传的音乐文件列表,进入课堂后需要自动加载
GlobalConfig
.
docListPrepare
=
[];
// 已经提前上传的文档,进入课堂后需要自动加载
GlobalConfig
.
recordList
=
[];
//录制服务器地址集合
GlobalConfig
.
docList
=
[];
//文档服务器地址集合
...
...
src/apes/ApeConsts.js
查看文件 @
4d9a04e
...
...
@@ -141,6 +141,7 @@ ApeConsts.SCREENSHARING_SESSION_ID = 20;
ApeConsts
.
POLL_SESSION_ID
=
21
;
ApeConsts
.
QUESTION_SESSION_ID
=
22
;
ApeConsts
.
CURSOR_SESSION_ID
=
23
;
ApeConsts
.
MUSIC_SESSION_ID
=
24
;
// defs for common channel id
ApeConsts
.
BROADCAST_CHANNEL_ID
=
0
;
...
...
@@ -152,6 +153,7 @@ ApeConsts.DOCSHARING_CHANNEL_ID = ApeConsts.DOCSHARING_SESSION_ID;
ApeConsts
.
WHITEBOARD_CHANNEL_ID
=
ApeConsts
.
WHITEBOARD_SESSION_ID
;
ApeConsts
.
CURSOR_CHANNEL_ID
=
ApeConsts
.
CURSOR_SESSION_ID
;
ApeConsts
.
MEDIA_CHANNEL_ID
=
ApeConsts
.
MEDIA_SESSION_ID
;
ApeConsts
.
MUSIC_CHANNEL_ID
=
ApeConsts
.
MUSIC_SESSION_ID
;
ApeConsts
.
SCREENSHARING_CHANNEL_ID
=
ApeConsts
.
SCREENSHARING_SESSION_ID
;
ApeConsts
.
QUESTION_CHANNEL_ID
=
ApeConsts
.
QUESTION_SESSION_ID
;
...
...
@@ -167,6 +169,7 @@ ApeConsts.DOCSHARING_SESSION_NAME = "doc sharing app";
ApeConsts
.
WHITEBOARD_SESSION_NAME
=
"whiteboard app"
;
ApeConsts
.
CURSOR_SESSION_NAME
=
"cursor app"
;
ApeConsts
.
MEDIA_SESSION_NAME
=
"media sharing app"
;
ApeConsts
.
MUSIC_SESSION_NAME
=
"music sharing app"
;
ApeConsts
.
SCREENSHARING_SESSION_NAME
=
"screen sharing app"
;
ApeConsts
.
QUESTION_SESSION_NAME
=
"question app"
;
...
...
@@ -181,6 +184,7 @@ ApeConsts.DOCSHARING_SESSION_TAG = "doc-tag";
ApeConsts
.
WHITEBOARD_SESSION_TAG
=
"wbd-tag"
;
ApeConsts
.
CURSOR_SESSION_TAG
=
"cursor-tag"
;
ApeConsts
.
MEDIA_SESSION_TAG
=
"med-tag"
;
ApeConsts
.
MUSIC_SESSION_TAG
=
"mis-tag"
;
ApeConsts
.
SCREENSHARING_SESSION_TAG
=
"scr-tag"
;
ApeConsts
.
QUESTION_SESSION_TAG
=
"qst-tag"
;
...
...
@@ -237,6 +241,11 @@ ApeConsts.MEDIA_OBJ_TABLE_ID = ((ApeConsts.MEDIA_SESSION_ID << 16) + 1);
ApeConsts
.
MEDIA_OBJ_TABLE_NAME
=
"med list"
;
ApeConsts
.
MEDIA_OBJ_TABLE_TAG
=
"med list tag"
;
// music sharing objects
ApeConsts
.
MUSIC_OBJ_TABLE_ID
=
((
ApeConsts
.
MUSIC_SESSION_ID
<<
16
)
+
1
);
ApeConsts
.
MUSIC_OBJ_TABLE_NAME
=
"mis list"
;
ApeConsts
.
MUSIC_OBJ_TABLE_TAG
=
"mis list tag"
;
// chat sharing objects
ApeConsts
.
CHAT_OBJ_TABLE_ID
=
((
ApeConsts
.
CHAT_SESSION_ID
<<
16
)
+
1
);
ApeConsts
.
CHAT_OBJ_TABLE_NAME
=
"chat list"
;
...
...
src/apes/ConferApe.js
查看文件 @
4d9a04e
...
...
@@ -454,23 +454,24 @@ class ConferApe extends Ape {
}
//课堂的场景模块发送改变
sceneTableChange
(
_param
)
{
if
(
GlobalConfig
.
isRecordPlayBack
)
{
return
;
}
loger
.
log
(
'切换文档-媒体-屏幕模块切换->'
,
_param
);
//如果是host身份
if
(
GlobalConfig
.
isHost
)
{
if
(
_param
)
{
GlobalConfig
.
currentSceneTableId
=
parseInt
(
_param
.
currentSceneTableId
)
||
0
;
//当前场景显示的模块 0=文档模块、1=屏幕共享、2=媒体共享
//保存数据到Sass
this
.
_emit
(
MessageTypes
.
CLASS_STATUS_INFO_CHANGE
);
//同步消息给其他人
this
.
sendUpdaterClassStatusInfo
({
"actionType"
:
1
,
isStopAllPublishMedia
:
false
});
}
if
(
GlobalConfig
.
isRecordPlayBack
)
{
return
;
}
loger
.
log
(
'切换文档-媒体-屏幕模块切换->'
,
_param
);
//如果是host身份
if
(
GlobalConfig
.
isHost
)
{
if
(
_param
)
{
GlobalConfig
.
currentSceneTableId
=
parseInt
(
_param
.
currentSceneTableId
)
||
0
;
//当前场景显示的模块 0=文档模块、1=屏幕共享、2=媒体共享
//保存数据到Sass
this
.
_emit
(
MessageTypes
.
CLASS_STATUS_INFO_CHANGE
);
//同步消息给其他人
this
.
sendUpdaterClassStatusInfo
({
"actionType"
:
1
,
isStopAllPublishMedia
:
false
});
}
}
//更新课堂信息
}
//更新课堂信息
sendUpdaterClassStatusInfo
(
_param
)
{
//{"actionType": 1,isStopAllPublishMedia:false} //actionType课堂状态 isStopAllPublishMedia是否停止当前的所有推流
loger
.
log
(
'发送更新课堂信息->'
);
...
...
src/apes/MusicSharedApe.js
0 → 100644
查看文件 @
4d9a04e
// //////////////////////////////////////////////////////////////////////////////
//
// 媒体共享模块
// //////////////////////////////////////////////////////////////////////////////
import
Ape
from
'./Ape'
;
import
ApeConsts
from
'./ApeConsts'
;
import
pdu
from
'pdus'
;
import
Loger
from
'Loger'
;
import
MessageTypes
from
'MessageTypes'
;
import
GlobalConfig
from
'GlobalConfig'
;
import
EngineUtils
from
'EngineUtils'
;
let
loger
=
Loger
.
getLoger
(
'MusicSharedApe'
);
class
MusicSharedApe
extends
Ape
{
constructor
()
{
super
(
ApeConsts
.
MUSIC_SESSION_ID
,
ApeConsts
.
MUSIC_SESSION_NAME
,
ApeConsts
.
MUSIC_SESSION_TAG
);
this
.
musicSharedList
=
{};
//记录媒体数据
// Ape Models
this
.
registerKey
(
this
.
_session_id
,
this
.
_session_name
,
this
.
_session_tag
,
new
ArrayBuffer
);
this
.
registerObj
(
pdu
.
RCPDU_REG_REGISTER_TABLE
,
ApeConsts
.
MUSIC_OBJ_TABLE_ID
,
ApeConsts
.
MUSIC_OBJ_TABLE_NAME
,
ApeConsts
.
MUSIC_OBJ_TABLE_TAG
,
0
,
new
ArrayBuffer
);
}
/////////////发送数据操作//////////////////////////////////////////////////////
//上传媒体文件
musicSharedUpload
(
paramInfo
)
{
if
(
paramInfo
==
null
||
EngineUtils
.
isEmptyObject
(
paramInfo
))
{
loger
.
warn
(
'上传媒体文件->失败->参数错误->'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//判断媒体文件是否已经存在,每个媒体文件都有唯一的fileId,如果已经同步的媒体文件中存在相同的fileId就不需要再同步
if
(
this
.
checkMusicSharedId
(
paramInfo
.
fileId
))
{
//媒体文件已经存在相同的fileId,不需要同步上传
loger
.
warn
(
'上传媒体文件->失败->媒体文件档的fileId无效或已经存在相同的fileId不需要上传'
);
return
;
}
let
itemIdx
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
//
let
pduDataModel
=
this
.
packPdu
(
paramInfo
,
itemIdx
);
if
(
pduDataModel
==
null
)
{
loger
.
log
(
'上传媒体文件->失败->数据无效'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
let
tableItemPdu
=
new
pdu
[
'RCRegistryTableItemPdu'
];
tableItemPdu
.
itemIdx
=
itemIdx
;
//直接用时间戳作为id
tableItemPdu
.
registerObjId
=
ApeConsts
.
MUSIC_OBJ_TABLE_ID
;
tableItemPdu
.
owner
=
0
;
//收到flash的是这个值,不清楚先写固定
tableItemPdu
.
itemData
=
pduDataModel
.
toArrayBuffer
();
//insert
let
tableInsertItemPdu
=
new
pdu
[
'RCRegistryTableInsertItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_INSERT_PDU
;
//
tableInsertItemPdu
.
items
.
push
(
tableItemPdu
);
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
MUSIC_OBJ_TABLE_ID
;
updateObjPdu
.
subType
=
tableInsertItemPdu
.
type
;
updateObjPdu
.
userData
=
tableInsertItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
loger
.
log
(
"上传媒体文件->发送->itemIdx="
+
tableItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
}
//删除媒体文件
musicSharedDelete
(
paramInfo
)
{
let
tableDeleteItemPdu
=
new
pdu
[
'RCRegistryTableDeleteItemPdu'
];
tableDeleteItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_DELETE_PDU
;
//
tableDeleteItemPdu
.
itemIdx
=
parseInt
(
paramInfo
.
itemIdx
);
//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
MUSIC_OBJ_TABLE_ID
;
updateObjPdu
.
subType
=
tableDeleteItemPdu
.
type
;
updateObjPdu
.
userData
=
tableDeleteItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
loger
.
log
(
"媒体文件发送删除数据=============>"
+
tableDeleteItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
}
//更新
updaterMusicShared
(
_pduDataModel
,
_itemIdx
)
{
//验证坐标点集合数组是否合法
if
(
_pduDataModel
==
null
||
_itemIdx
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
loger
.
log
(
"媒体文件->更新 "
,
_pduDataModel
);
let
pduDataModel
=
this
.
packPdu
(
_pduDataModel
,
_itemIdx
);
let
tableItemPdu
=
new
pdu
[
'RCRegistryTableItemPdu'
];
tableItemPdu
.
itemIdx
=
_itemIdx
;
//直接用时间戳作为id
tableItemPdu
.
owner
=
0
;
//收到flash的是这个值,不清楚先写固定
tableItemPdu
.
itemData
=
pduDataModel
.
toArrayBuffer
();
//insert
let
tableInsertItemPdu
=
new
pdu
[
'RCRegistryTableUpdateItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_UPDATE_PDU
;
//
tableInsertItemPdu
.
items
.
push
(
tableItemPdu
);
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
MUSIC_OBJ_TABLE_ID
;
updateObjPdu
.
subType
=
tableInsertItemPdu
.
type
;
updateObjPdu
.
userData
=
tableInsertItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
loger
.
log
(
"发送更新媒体文件.itemIdx="
+
tableItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
}
//组织完整的媒体文件信息,包含上传时的信息和转换后的完整地址信息
_musicSharedPackFullInfo
(
_itemDataInfo
)
{
let
itemDataInfo
=
_itemDataInfo
;
if
(
!
itemDataInfo
.
seek
)
{
itemDataInfo
.
seek
=
1
;
}
loger
.
log
(
'musicPackFullInfo->'
,
itemDataInfo
);
return
itemDataInfo
;
}
//更新媒体文件模块的录制信息,每次开启录制的时候需要把当前媒体文件的信息更新一次
updaterRecordApeStatus
(
_param
)
{
loger
.
warn
(
"录制状态发送改变->更新当前的媒体文件数据->fileId:"
,
GlobalConfig
.
activeMusicId
,
'page:'
,
GlobalConfig
.
activeMusicSeek
);
this
.
musicSharedSeek
({
"itemIdx"
:
GlobalConfig
.
activeMusicId
,
"seek"
:
GlobalConfig
.
activeMusicSeek
});
}
//清除当前媒体文件模块的数据
clearData
()
{
loger
.
log
(
"clearData->"
)
this
.
musicSharedList
=
{};
GlobalConfig
.
activeMusicId
=
0
;
GlobalConfig
.
activeMusicSeek
=
1
;
}
//更新媒体文件(播放,暂停,停止,seek)
musicSharedUpdate
(
_param
)
{
if
(
_param
==
null
||
_param
.
itemIdx
==
null
)
{
loger
.
warn
(
'媒体文件更新失败->参数错误'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//获取已经存在的数据
let
pduDataModel
=
this
.
musicSharedList
[
_param
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
warn
(
'更新媒体文件->媒体文件不存在'
,
_param
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新当前选择的媒体文件数据的字段
pduDataModel
.
status
=
parseInt
(
_param
.
status
)
||
0
;
//默认是0
pduDataModel
.
seek
=
parseInt
(
_param
.
seek
)
||
1
;
pduDataModel
.
musicVolume
=
parseInt
(
_param
.
musicVolume
)
||
0
;
//更新当前选择的媒体文件
this
.
updaterMusicShared
(
pduDataModel
,
pduDataModel
.
itemIdx
);
}
//播放媒体文件
musicSharedPlay
(
paramInfo
)
{
loger
.
log
(
'切换媒体文件->'
,
paramInfo
);
if
(
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
'录制回放状态不允许切换媒体文件'
);
return
;
}
if
(
paramInfo
==
null
||
paramInfo
.
itemIdx
==
null
)
{
loger
.
warn
(
'切换媒体文件失败,参数错误'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
/* if (paramInfo.itemIdx == GlobalConfig.activeMusicId && GlobalConfig.activeMusicId != 0) {
loger.warn('媒体文件已经显示', paramInfo.itemIdx, GlobalConfig.activeMusicId);
return;
}*/
//更新切换之前的媒体文件的数据,要显示当前切换的媒体文件,上一个媒体文件需要隐藏
let
oldPduDataModel
;
if
(
GlobalConfig
.
activeMusicId
!=
0
)
{
oldPduDataModel
=
this
.
musicSharedList
[
GlobalConfig
.
activeMusicId
];
if
(
oldPduDataModel
)
{
oldPduDataModel
.
status
=
0
;
//停止状态
//oldPduDataModel.seek=0;
}
}
//获取已经存在的数据
let
pduDataModel
=
this
.
musicSharedList
[
paramInfo
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
warn
(
'切换媒体文件失败,媒体文件不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新当前选择的媒体文件数据的字段
pduDataModel
.
status
=
paramInfo
.
status
||
0
;
//默认是0
pduDataModel
.
seek
=
paramInfo
.
seek
||
1
;
pduDataModel
.
musicVolume
=
parseInt
(
paramInfo
.
musicVolume
)
||
0
;
//loger.log('切换媒体文件,当前媒体文件和上一个显示的媒体文件都需要更新状态');
loger
.
log
({
"oldDoc"
:
oldPduDataModel
,
"nowDoc"
:
pduDataModel
});
//更新当前选择的媒体文件
this
.
updaterMusicShared
(
pduDataModel
,
pduDataModel
.
itemIdx
);
//更新上一个媒体文件 隐藏
if
(
oldPduDataModel
&&
oldPduDataModel
.
itemIdx
!=
pduDataModel
.
itemIdx
)
{
this
.
updaterMusicShared
(
oldPduDataModel
,
oldPduDataModel
.
itemIdx
);
}
}
//停止媒体文件
musicSharedStop
(
paramInfo
)
{
loger
.
log
(
'停止媒体文件->'
,
paramInfo
);
if
(
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
'录制回放状态不允许停止媒体文件'
);
return
;
}
if
(
paramInfo
==
null
||
paramInfo
.
itemIdx
==
null
)
{
loger
.
warn
(
'停止媒体文件,参数错误'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//获取已经存在的数据
let
pduDataModel
=
this
.
musicSharedList
[
paramInfo
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
warn
(
'停止媒体文件,媒体文件不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新当前选择的媒体文件数据的字段
pduDataModel
.
status
=
0
;
//默认是0
pduDataModel
.
seek
=
0
;
pduDataModel
.
musicVolume
=
60
;
//更新当前选择的媒体文件
this
.
updaterMusicShared
(
pduDataModel
,
pduDataModel
.
itemIdx
);
}
//暂停媒体文件
musicSharedPause
(
paramInfo
)
{
loger
.
log
(
'暂停媒体文件->'
,
paramInfo
);
if
(
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
'录制回放-》暂停媒体文件'
);
return
;
}
if
(
paramInfo
==
null
||
paramInfo
.
itemIdx
==
null
)
{
loger
.
warn
(
'暂停媒体文件,参数错误'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//获取已经存在的数据
let
pduDataModel
=
this
.
musicSharedList
[
paramInfo
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
warn
(
'暂停媒体文件,媒体文件不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新当前选择的媒体文件数据的字段
pduDataModel
.
status
=
2
;
//默认是0
//更新当前选择的媒体文件
this
.
updaterMusicShared
(
pduDataModel
,
pduDataModel
.
itemIdx
);
}
//媒体文件SEEK
musicSharedSeek
(
paramInfo
)
{
loger
.
log
(
'媒体文件SEEK->'
,
paramInfo
);
//获取已经存在的数据
let
pduDataModel
=
this
.
musicSharedList
[
paramInfo
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
log
(
'媒体文件SEEK->媒体文件不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
pduDataModel
.
seek
=
parseInt
(
paramInfo
.
seek
)
||
1
;
if
(
pduDataModel
.
seek
<
1
)
{
pduDataModel
.
seek
=
1
;
//默认值最小是1
}
this
.
updaterMusicShared
(
pduDataModel
,
pduDataModel
.
itemIdx
);
}
/////收到消息处理/////////////////////////////////////////////////////////////////////////////////
tableInsertHandler
(
owner
,
itemIdx
,
itemData
)
{
}
//添加媒体文件
tableInsertApeHandler
(
_tableUpdateItems
,
_seekTime
)
{
let
tableInsertItems
=
_tableUpdateItems
;
let
tableInsertItemsLen
=
tableInsertItems
.
length
;
loger
.
log
(
'添加媒体文件->_seekTime:'
+
_seekTime
,
"activeMusicId->"
,
GlobalConfig
.
activeMusicId
,
"tableUpdateItemsLen->"
,
tableInsertItemsLen
);
for
(
let
i
=
0
;
i
<
tableInsertItemsLen
;
++
i
)
{
let
insertItem
=
tableInsertItems
[
i
];
//this.tableInsertHandler(insertItem.owner, insertItem.itemIdx, insertItem.itemData);
let
itemDataInfo
=
this
.
unPackPdu
(
insertItem
.
owner
,
insertItem
.
itemIdx
,
insertItem
.
itemData
);
if
(
itemDataInfo
)
{
itemDataInfo
.
seek
=
itemDataInfo
.
seek
+
parseInt
(
_seekTime
);
//seek是媒体文件自己的,_seekTime是录制回放时进度条换算的
this
.
musicSharedList
[
insertItem
.
itemIdx
]
=
itemDataInfo
;
if
(
itemDataInfo
.
status
==
1
)
{
GlobalConfig
.
activeMusicId
=
itemDataInfo
.
itemIdx
;
//当前激活的媒体文件ID
GlobalConfig
.
activeMusicSeek
=
itemDataInfo
.
seek
;
loger
.
log
(
'添加媒体文件->设置当前激活的媒体文件id'
);
}
let
getMusicPackFullInfo
=
this
.
_musicSharedPackFullInfo
(
itemDataInfo
);
this
.
_emit
(
MessageTypes
.
MEDIA_SHARED_UPDATE
,
getMusicPackFullInfo
);
}
}
//媒体文件数据更新完毕,如果当前没有显示的媒体文件,默认选择一个显示
this
.
_showDefaultMeida
();
}
tableDeleteHandler
(
object_id
,
tableDeleteData
)
{
loger
.
log
(
'删除媒体文件数据->'
,
object_id
,
tableDeleteData
);
//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}]
if
(
tableDeleteData
&&
tableDeleteData
.
itemIdx
)
{
let
len
=
tableDeleteData
.
itemIdx
.
length
;
let
itemIdxs
=
tableDeleteData
.
itemIdx
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
if
(
this
.
musicSharedList
[
itemIdxs
[
i
]])
{
loger
.
log
(
"删除媒体文件数据:"
,
itemIdxs
[
i
]);
let
itemDataInfo
=
this
.
musicSharedList
[
itemIdxs
[
i
]];
if
(
itemDataInfo
&&
itemDataInfo
.
status
==
1
)
{
GlobalConfig
.
activeMusicId
=
0
;
//当前激活的媒体文件ID
GlobalConfig
.
activeMusicSeek
=
1
;
//当前激活的媒体文件的当前页
loger
.
log
(
'删除媒体文件数据->清除当前显示的媒体文件'
);
}
this
.
_emit
(
MessageTypes
.
MEDIA_SHARED_DELETE
,
{
"itemIdx"
:
itemIdxs
[
i
]
});
delete
this
.
musicSharedList
[
itemIdxs
[
i
]];
}
}
}
}
tableUpdateHandler
(
owner
,
itemIdx
,
itemData
)
{
}
tableUpdateApeHandler
(
_tableUpdateItems
,
_seekTime
)
{
let
tableUpdateItemsLen
=
_tableUpdateItems
.
length
;
loger
.
log
(
'更新媒体文件->_seekTime:'
+
_seekTime
,
"activeDocId->"
,
GlobalConfig
.
activeMusicId
,
"更新的数量->"
,
tableUpdateItemsLen
);
for
(
let
i
=
0
;
i
<
tableUpdateItemsLen
;
++
i
)
{
let
tableItem
=
_tableUpdateItems
[
i
];
let
itemDataInfo
=
this
.
unPackPdu
(
tableItem
.
owner
,
tableItem
.
itemIdx
,
tableItem
.
itemData
);
if
(
itemDataInfo
!=
null
)
{
itemDataInfo
.
seek
=
itemDataInfo
.
seek
+
parseInt
(
_seekTime
);
this
.
musicSharedList
[
tableItem
.
itemIdx
]
=
itemDataInfo
;
if
(
itemDataInfo
&&
itemDataInfo
.
status
==
1
)
{
GlobalConfig
.
activeMusicId
=
itemDataInfo
.
itemIdx
;
//当前激活的媒体文件ID
GlobalConfig
.
activeMusicSeek
=
itemDataInfo
.
seek
;
loger
.
log
(
'更新媒体文件->设置当前激活的媒体文件id->'
,
GlobalConfig
.
activeMusicId
,
"curPageNum->"
,
GlobalConfig
.
activeMusicSeek
);
}
let
getMusicPackFullInfo
=
this
.
_musicSharedPackFullInfo
(
itemDataInfo
);
this
.
_emit
(
MessageTypes
.
MEDIA_SHARED_UPDATE
,
getMusicPackFullInfo
);
}
else
{
loger
.
log
(
'更新媒体文件-> 数据无效--> itemIdx'
,
itemIdx
);
}
}
this
.
_showDefaultMeida
();
}
//果当前没有显示的媒体文件,默认选择一个显示媒体文件
_showDefaultMeida
()
{
//显示默认媒体文件条件->1.非录制回放状态下 2.只有host有权限操作 3.当前激活的媒体文件id不为0
if
(
GlobalConfig
.
isRecordPlayBack
||
!
GlobalConfig
.
isHost
||
GlobalConfig
.
activeMusicId
>
0
)
{
return
;
}
/*
let tempDocItemIdx;//临时记录媒体文件数据,用于显示默认媒体文件
for (let key in this.musicSharedList) {
tempDocItemIdx= this.musicSharedList[key];
if (tempDocItemIdx) {
loger.log("选择一个媒体文件作为默认媒体文件显示->", tempDocItemIdx);
let paramInfo = {
"itemIdx": tempDocItemIdx.itemIdx,
"status": 1
};
this.musicSharedPlay(paramInfo);
//选择完成就跳出循环
return;
}
}*/
}
onJoinChannelHandlerSuccess
()
{
loger
.
log
(
this
.
_session_name
+
' 媒体共享加入频道成功'
);
if
(
this
.
_apeDelayed
)
{
setTimeout
(()
=>
{
this
.
_emit
(
MusicSharedApe
.
MEDIASHARED_JOIN_CHANNEL_SUCCESS
);
},
(
GlobalConfig
.
mcuDelay
+
GlobalConfig
.
docDelay
)
||
12000
+
GlobalConfig
.
docDelay
);
}
else
{
setTimeout
(()
=>
{
this
.
_emit
(
MusicSharedApe
.
MEDIASHARED_JOIN_CHANNEL_SUCCESS
);
},
GlobalConfig
.
docDelay
);
}
}
//检查媒体文件是否已经存在,如果存在 返回true,否则返回false
checkMusicSharedId
(
_fileId
)
{
if
(
_fileId
==
null
)
{
loger
.
warn
(
'查找媒体文件->失败->参数为null'
);
return
true
;
}
//遍历查找
for
(
let
key
in
this
.
musicSharedList
)
{
let
item
=
this
.
musicSharedList
[
key
];
if
(
item
&&
item
.
fileId
==
_fileId
)
{
loger
.
log
(
'查找媒体文件->已经存在->'
,
_fileId
);
return
true
;
}
}
loger
.
log
(
'查找媒体文件->没有查找到媒体文件->'
,
_fileId
);
//储存的数据中没有查找到
return
false
;
}
///////数据的封包和解包/////////////////////////////////////////
packPdu
(
_param
,
_itemIdx
)
{
loger
.
log
(
"媒体文件->packPdu"
);
//验证坐标点集合数组是否合法
if
(
_param
==
null
||
_itemIdx
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
/* optional uint32 item_idx=1;//唯一标识
optional uint32 owner=2;
optional uint32 from=3;
optional string file_type=4;
optional string creat_user_id=5;//创建文件userid
optional string url =6;//文件地址
optional uint32 status=7;//状态0停止 1播放 2暂停
optional string fileId=8;//文件在服务器数据库中的唯一id
optional string file_name=9;//文件的名字
optional uint32 seek=10;//seek*/
//判断type类型,根据type设置不同的参数
let
pduDataModel
=
new
pdu
[
'RCMusicSharedSendDataModelPdu'
];
pduDataModel
.
itemIdx
=
_itemIdx
;
pduDataModel
.
owner
=
GlobalConfig
.
nodeId
;
pduDataModel
.
from
=
GlobalConfig
.
nodeId
;
pduDataModel
.
fileType
=
_param
.
fileType
||
""
;
pduDataModel
.
creatUserId
=
_param
.
creatUserId
||
"0"
;
pduDataModel
.
url
=
_param
.
url
||
""
;
//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
pduDataModel
.
status
=
_param
.
status
||
0
;
pduDataModel
.
fileId
=
_param
.
fileId
||
""
;
//媒体文件在服务器数据库中的唯一id,必须有
pduDataModel
.
fileName
=
_param
.
fileName
||
"music_"
+
_itemIdx
;
//媒体文件的名字
pduDataModel
.
seek
=
parseInt
(
_param
.
seek
)
||
1
;
pduDataModel
.
musicVolume
=
parseInt
(
_param
.
musicVolume
);
if
(
!
pduDataModel
.
musicVolume
)
{
pduDataModel
.
musicVolume
=
60
;
}
return
pduDataModel
;
}
unPackPdu
(
owner
,
itemIdx
,
itemData
)
{
if
(
owner
==
null
||
itemIdx
==
null
||
itemData
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
try
{
let
pduDataModel
=
pdu
[
'RCMusicSharedSendDataModelPdu'
].
decode
(
itemData
);
loger
.
log
(
"媒体文件===>unPackPdu"
);
return
pduDataModel
;
}
catch
(
err
)
{
loger
.
log
(
"媒体文件===>unPackPdu->Pdu解析错误->itemIdx="
+
itemIdx
+
"->err:"
+
err
.
message
);
}
return
null
;
}
}
MusicSharedApe
.
prototype
.
MEDIASHARED_JOIN_CHANNEL_SUCCESS
=
MusicSharedApe
.
MEDIASHARED_JOIN_CHANNEL_SUCCESS
=
'musicShared_join_channel_success'
;
export
default
MusicSharedApe
;
...
...
src/pdus/pro.js
查看文件 @
4d9a04e
...
...
@@ -758,6 +758,20 @@ message RCMediaSharedSendDataModelPdu {
optional
uint32
mediaVolume
=
11
;
//音量
}
message
RCMusicSharedSendDataModelPdu
{
optional
uint32
item_idx
=
1
;
//唯一标识
optional
uint32
owner
=
2
;
optional
uint32
from
=
3
;
optional
string
file_type
=
4
;
optional
string
creat_user_id
=
5
;
//创建文件userid
optional
string
url
=
6
;
//文件地址
optional
uint32
status
=
7
;
//状态0停止 1播放 2暂停
optional
string
fileId
=
8
;
//文件在服务器数据库中的唯一id
optional
string
file_name
=
9
;
//文件的名字
optional
uint32
seek
=
10
;
//seek
optional
uint32
mediaVolume
=
11
;
//音量
}
message
RCDocBroadcastDataRequestPdu
{
optional
uint32
from_node_id
=
1
;
//发起人
optional
uint32
to_node_id
=
2
;
//接收人,如果是0就是所有人都接收
...
...
请
注册
或
登录
后发表评论