主要功能
推流:RTMP 推流
Demo示例
http://www.vhallyun.com/document/document/download
示例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo for push stream</title>
<script src="https://static.vhallyun.com/jssdk/vhall-jssdk-live-stream-1.0.0.js?v=201802021400"></script>
<script src="https://static.vhallyun.com/jssdk/vhall-jssdk-base-1.0.0.js?v=201802021400"></script>
<style>
body{
background-color: #000;
/* height: 800px;
line-height: 800px;*/
}
.ctrl-box{
margin:0 auto;
text-align: center;
margin:10% 0px 30px 0px;
}
.video-box{
margin:0 auto;
width: 854px;
height: 480px;
}
#btn-start-push{
min-width: 80px;
padding: 5px 10px;
height: 30px;
background-color: #1f88e4;
border: 1px solid #1f88e4;
border-radius: 2px;
color: #fff;
outline: none;
}
</style>
</head>
<body>
<div class="ctrl-box"><button id="btn-start-push">开推</button></div>
<div class="video-box" >
<div id="my-publisher" ></div>
</div>
</body>
<script>
Vhall.ready(function(){
//todo
VHPublisher.error(function(e){
console.error(e.msg);
});
VHPublisher.init({
roomId:'lss_c063b5c9',//房间名称
videoNode:'my-publisher',//推流容器
//调用推流接口后完成事件,注意,是调用接口事件完成,不是推流结束。
complete:function(){
//to do
}
});
});
Vhall.config({
appId :'76043aaf',//应用 ID ,必填
accountId :'10000126',//第三方用户唯一标识,必填
token:'vhall',//token必填
});
var startBtn = document.getElementById('btn-start-push');
startBtn.addEventListener('click',startPush);
/**
* 开始推流
*/
function startPush(){
startBtn.innerHTML = '启动推流中...';
VHPublisher.startPush({
success: function(){
startBtn.removeEventListener('click',startPush);
startBtn.innerHTML = '停推';
startBtn.addEventListener('click',stopPush);
},
fail: function(e){
console.error('推流出错',e.msg);
},
complete: function(e){
}
});
}
function stopPush(){
VHPublisher.stopPush({
complete: function(){
startBtn.removeEventListener('click',stopPush);
startBtn.addEventListener('click',startPush);
startBtn.innerHTML = '开推'
}
});
}
</script>
</html>