网易云信 抄送 php,网易云信——直播sdk的使用方法

740c8df49420

html:

NePublisher Demo

摄像头:

麦克风:

清晰度:

流畅(480*360@20)

标清(640*480@20)

高清(960*540@20)

推流地址:

预览

开始直播

+++++++++++++++++++++++++++++++++++++

js部分:

var cameraList,

microPhoneList,

cameraOptions = '',

microPhoneOptions = '';

var publishBtn = document.getElementById('publishBtn');

var previewBtn = document.getElementById('previewBtn')

var testInput = document.getElementsByClassName('u-input');

var myPublisher = new nePublisher('my-publisher', {

//viewOptions

videoWidth: 960,

videoHeight: 540,

fps: 20,

bitrate: 1500

}, {

//flashOptions

previewWindowWidth: 862,

previewWindowHeight: 486,

wmode: 'transparent',

quality: 'high',

allowScriptAccess: 'always'

}, function() {

cameraList = this.getCameraList();

microPhoneList = this.getMicroPhoneList();

console.log(cameraList, microPhoneList);

for (var i = cameraList.length - 1; i >= 0; i--) {

cameraOptions = '' + cameraList[i] + '' + cameraOptions;

}

for (var i = microPhoneList.length - 1; i >= 0; i--) {

microPhoneOptions = '' + microPhoneList[i] + '' + microPhoneOptions;

}

document.getElementById("cameraSelect").innerHTML = cameraOptions;

document.getElementById("microPhoneSelect").innerHTML = microPhoneOptions;

}, function(code, desc) {

console.log(code, desc);

});

var qualityList = [

{

//流畅

fps: 20,

bitrate: 600,

videoWidth:480,

videoHeight:360

},

{

//标清

fps: 20,

bitrate: 800,

videoWidth:640,

videoHeight:480

},

{

//高清

fps: 20,

bitrate: 1500,

videoWidth:960,

videoHeight:540

}

];

var getCameraIndex = function() {

var cameraSelect = document.getElementById("cameraSelect");

var cameraIndex = cameraSelect.selectedIndex;

return cameraSelect.options[cameraIndex].value;

};

var getMicroPhoneIndex = function() {

var microPhoneSelect = document.getElementById("microPhoneSelect");

var microPhoneIndex = microPhoneSelect.selectedIndex;

return microPhoneSelect.options[microPhoneIndex].value;

};

var getQualityOption = function() {

var qualitySelect = document.getElementById("qualitySelect");

var qualityIndex = qualitySelect.selectedIndex;

return qualityList[qualityIndex];

};

var startPreview = function() {

myPublisher.startPreview(getCameraIndex());

document.getElementsByClassName('u-status')[0].innerHTML = '预览中';

};

var startPublish = function() {

var publishUrl = document.getElementById("publishUrl").value;

startPublishCall();

myPublisher.setCamera(getCameraIndex());

myPublisher.setMicroPhone(getMicroPhoneIndex());

myPublisher.startPublish(publishUrl, getQualityOption(),function(code, desc) {

console.log(code, desc);

alert(code + ':' + desc);

stopPublishCall();

});

};

var stopPublish = function() {

myPublisher.stopPublish();

stopPublishCall();

};

var startPublishCall = function() {

console.log('推流开始');

document.getElementsByClassName('u-status')[0].innerHTML = '直播中';

publishBtn.innerHTML = '停止直播';

publishBtn.onclick = stopPublish;

for (var i = testInput.length - 1; i >= 0; i--) {

testInput[i].disabled = true;

}

previewBtn.disabled = true;

};

var stopPublishCall = function() {

console.log('推流结束');

document.getElementsByClassName('u-status')[0].innerHTML = '预览中';

publishBtn.innerHTML = '开始直播';

publishBtn.onclick = startPublish;

for (var i = testInput.length - 1; i >= 0; i--) {

testInput[i].disabled = false;

}

previewBtn.disabled = false;

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值