如何在按钮点击事件中禁用和启用视频聊天,但音频始终在两者中.. [英] How to disable and enable video chatting in button click event, but audio is always in both ..
本文介绍了如何在按钮点击事件中禁用和启用视频聊天,但音频始终在两者中..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我们正在实施2人之间的视频聊天。这里有启用/禁用按钮。当我点击启用按钮视频聊天确定,但点击禁用按钮显示错误,如
Hello,
we are implementing video chatting between 2persons. here enable/disable buttons is there. when i click enable button video chatting ok, but when click disable button showing error like "
The stream was unable to connect due to a network error. Make sure your connection isn't blocked by a firewall
。请给出一些解决方案..
". pls give some solution on it..
I use the latest opentok Android SDK to development an application. My purpose is to provide a button to let user can publish / unpublish camera. It works to unpublish the camera OT.initPublisher("publisherContainer", publisherOptions).publishVideo(false);, but it doesn't work to republish when I use OT.initPublisher("publisherContainer", publisherOptions).publishVideo(true);.
<script src="//static.opentok.com/webrtc/v2.2/js/opentok.min.js" ></script>
$(document).ready(function () {
var apikey = "xxxxx";
var sessionI = "@Session["SessionId"]";
var token = "@Session["Token"]";
var videoOn = true;
var session = OT.initSession(apikey, sessionI);
session.connect(token, function (err) {
if (err) {
alert("Vendor video call disconnected");
}
else {
var publisherOptions = {
insertMode: "append",
height: "260px",
width: "450px",
}
var publisher = OT.initPublisher("publisherContainer", publisherOptions);
$('#disablevideo').click(function () {
if (videoOn == true)
{
publisher.destroy();
publisher = OT.initPublisher("publisherContainer", publisherOptions).publishVideo(false);
videoOn = false;
session.publish(publisher);
}
else {
publisher.destroy();
publisher = OT.initPublisher("publisherContainer", publisherOptions).publishVideo(true);
videoOn = true;
session.publish(publisher);
}
});
session.publish(publisher);
}
});
session.on("streamCreated", function (event) {
var options = {
insertMode: 'append',
height: "450px",
width: "720px",
}
session.subscribe(event.stream, 'containerElementId', options)
$("#vendoename").hide();
clearInterval(interval);
});
谢谢。
thank you.
推荐答案
( document )。ready( function (){
var apikey = xxxxx;
var sessionI = @ Session [ SessionId ];
var token = @ Session [ 令牌 ];
var videoOn = true ;
var session = OT.initSession(apikey,sessionI);
session.connect(令牌,功能(错误){
如果(错误){
alert( 供应商视频通话断开连接);
}
其他 {
var publisherOptions = {
insertMode : 追加,
height: 260px,
width: 450px,
}
var publisher = OT.initPublisher( publisherContainer,publisherOptions);
(document).ready(function () { var apikey = "xxxxx"; var sessionI = "@Session["SessionId"]"; var token = "@Session["Token"]"; var videoOn = true; var session = OT.initSession(apikey, sessionI); session.connect(token, function (err) { if (err) { alert("Vendor video call disconnected"); } else { var publisherOptions = { insertMode: "append", height: "260px", width: "450px", } var publisher = OT.initPublisher("publisherContainer", publisherOptions);
(' #disablevideo')。click( function (){
if (videoOn == true )
{
publisher.destroy();
publisher = OT.initPublisher( publisherContainer,publisherOptions).publishVideo(假跨度>);
videoOn = false ;
session.publish(出版商);
}
else {
publisher.destroy();
publisher = OT.initPublisher( publisherContainer,publisherOptions).publishVideo(真跨度>);
videoOn = true ;
session.publish(出版商);
}
});
session.publish(出版商);
}
});
session.on( streamCreated,函数(事件){
var options = {
insertMode:' 追加',
height: 450px,
宽度: 720px,
}
session.subscribe(event.stream,' containerElementId',options)
('#disablevideo').click(function () { if (videoOn == true) { publisher.destroy(); publisher = OT.initPublisher("publisherContainer", publisherOptions).publishVideo(false); videoOn = false; session.publish(publisher); } else { publisher.destroy(); publisher = OT.initPublisher("publisherContainer", publisherOptions).publishVideo(true); videoOn = true; session.publish(publisher); } }); session.publish(publisher); } }); session.on("streamCreated", function (event) { var options = { insertMode: 'append', height: "450px", width: "720px", } session.subscribe(event.stream, 'containerElementId', options)
( #vendoename)。hide();
clearInterval(interval);
});
("#vendoename").hide(); clearInterval(interval); });
谢谢。
thank you.
这篇关于如何在按钮点击事件中禁用和启用视频聊天,但音频始终在两者中..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文