我使用SimpleWebRTC进行视频会议,但问题是FireFox工作正常,但Chrome和其他浏览器甚至不会显示允许其使用网络摄像头或麦克风的弹出窗口。
请帮我解决问题。
鉴赏
我的代码:
<script src="js/jquery-2.2.0.js"></script>
<script src="js/latest-v2.js"></script>
<button class="btn btn-danger" id="show" onclick="play();">btn1</button>
<button class="btn btn-danger" id="hide" style="display: none;" onclick="pause();">btn2</button>
<video class="paused localVideo" id="localVideo"></video>
<div id="import">
</div>
<script type="text/javascript">
function play()
{
webrtc.resumeVideo();
$('.localVideo').removeClass('paused');
$("#show").hide();
$("#hide").show();
}
function pause()
{
webrtc.pauseVideo();
$('.localVideo').addClass('paused');
$("#show").show();
$("#hide").hide();
}
function unmute()
{
webrtc.unmute();
$('.localVideo').removeClass('muted');
}
function mute()
{
webrtc.mute();
$('.localVideo').addClass('muted');
}
function type()
{
// some IFs here
$('#import').css('someAttribute','someValue');
$('.remoteVideos').css('someAttribute','someValue');
return true;
}
var webrtc = new SimpleWebRTC({
localVideoEl: 'localVideo',
remoteVideosEl: '',
autoRequestMedia: true,
media: {
video: type(),
audio: type()
},
});
webrtc.on('readyToCall', function () {
var class_name = "<?php echo $class_name; ?>";
webrtc.joinRoom(class_name);
});
webrtc.on('mute', function(data) {
if(data.name === 'video')
$('.remoteVideos').addClass('paused');
else if(data.name === 'audio')
$('.remoteVideos').addClass('muted');
});
webrtc.on('unmute', function(data) {
if(data.name === 'video')
$('.remoteVideos').removeClass('paused');
else if(data.name === 'audio')
$('.remoteVideos').removeClass('muted');
});
webrtc.on('videoAdded', function(video, peer) {
remotes = document.getElementById('import');
container = document.createElement('div');
container.className = "paused remoteVideos col-xs-5";
container.appendChild(video);
remotes.appendChild(container);
$('#'+video.id).parent().removeClass('paused');
$('#'+video.id).parent().removeClass('muted');
type();
if (peer && peer.pc)
{
peer.pc.on('iceConnectionStateChange', function (event)
{
if(peer.pc.iceConnectionState == 'closed')
{
$('#'+video.id).parent().addClass('paused');
$('#'+video.id).parent().addClass('muted');
}
});
}
});
</script>