|
[BUG]
怎么联系@AC模块工作室,agoraLive模块使用
[复制链接]
agoraLive模块使用能不能给个例子,我们开发时出不来视频
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>title</title>
<link rel="stylesheet" type="text/css" href="../css/api.css"/>
<style>
.bttn {
margin: 50px;
padding: 10px;
}
</style>
</head>
<body>
<div class="bttn">
主播身份加入频道
</div>
<div class="bttn">
观众身份加入频道
</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
var agoraLive = null;
//通信模式
var livemode = "liveBroadcasting";
var rolemode = "";
var channelId = "testmeetting";
var userId = 0;
apiready = function(){
api.parseTapmode();
};
//主动创建
function fnjoinChannelActive() {
rolemode = "BROADCASTER";
userId = 133667858;
agoraLive = api.require('agoraLive');
init();
}
//被动接收
function fnjoinChannelPassive() {
rolemode = "AUDIENCE";
userId = 452876319;
agoraLive = api.require('agoraLive');
init();
}
function init() {
agoraLive.init({
appId: '13d7a037e46947198a70dc699e3af453' // 填写自己的appId
}, function(ret) {
console.log('初始化:' + JSON.stringify(ret));
setChannelProfile();
userJoinedListener();
})
}
function setChannelProfile() {
agoraLive.setChannelProfile({
profile: livemode
}, function(ret) {
if (ret.status) {
console.log('设置频道通话模式:' + '设置成功');
enableVideo();
}
});
}
function enableVideo() {
agoraLive.enableVideo(function(ret) {
console.log('开启视频模式:' + JSON.stringify(ret));
if(api.systemType =='ios'){
agoraLive.setClientRole({
role: rolemode
}, function(ret) {
if (ret.status) {
console.log('设置观众或主播模式:' + JSON.stringify(ret));
setOpenVideo();
}
});
}else{
setOpenVideo();
}
});
}
function setOpenVideo() {
if (rolemode == "BROADCASTER") {
initVideoRect(userId, 0, 0, 480, 320);
console.log('--------------------------------------------');
setTimeout("setupLocalVideo()", 2000)
}else if (rolemode == "AUDIENCE") {
// enableLocalVideo(false);
muteLocalAudioStream(false);
joinChannelByToken();
initVideoRect(userId, 0, 0,80, 60);
setTimeout("setupRemoteVideo()", 2000)
}
}
function initVideoRect(userId, x, y, w, h) {
agoraLive.initVideoRect({
uid: userId,
rect: {
x: x,
y: y,
w: w,
h: h
},
fixedOn: "agoravideo",
fixed: true
});
}
function setupLocalVideo() {
agoraLive.setupLocalVideo({
renderMode: 'RENDER_MODE_HIDDEN',
uid: userId
}, function(ret) {
console.log('设置本地视频显示信息' + JSON.stringify(ret));
startPreview();
});
}
function startPreview() {
agoraLive.startPreview(function(ret) {
console.log('启动本地视频预览' + JSON.stringify(ret));
joinChannelByToken();
});
agoraLive.enableVideo();
}
function stopPreview() {
agoraLive.stopPreview(function(ret) {
alert('停止本地视频预览' + JSON.stringify(ret));
});
}
function setupRemoteVideo() {
agoraLive.setupRemoteVideo({
renderMode: 'RENDER_MODE_HIDDEN',
uid: userId
}, function(ret) {
if (ret.status) {
console.log("显示主播视频:"+JSON.stringify(ret));
}
});
}
function joinChannelByToken() {
agoraLive.joinChannelByToken({
channelToken: '',
channelId: channelId,
uid: userId
}, function(ret, err) {
if (ret.status) {
console.log("加入频道成功:" + JSON.stringify(ret));
} else {
}
});
}
function userJoinedListener() {
agoraLive.userJoinedListener({
enable: true
}, function(ret) {
console.log("加入频道监听:" + JSON.stringify(ret));
remId = ret.uid;
});
}
function muteLocalAudioStream(flag) {
agoraLive.muteLocalAudioStream({
muted: flag
}, function(ret) {
if (ret.status) {
console.log("禁用本地音频");
}
});
}
function enableLocalVideo(flag) {
agoraLive.enableLocalVideo({
enabled: flag
}, function(ret) {
if (ret.status) {
console.log("禁用本地视频");
}
});
}
</script>
</html>
|
|