繁体   English   中英

如何隐藏此选项卡正在使用您的相机或麦克风 opentok

[英]How to hide This tab is using your camera or microphone opentok

我正在将 opentok javascript 库用于视频通话应用程序。 当视频通话以我正在通话的通话结束时

session.disconnect(); 
session.destroy();
session.unpublish(publisher);

在 chrome 中(至少),红色相机图标仍然可见,并显示“此选项卡正在使用您的相机或麦克风”的消息。

如何隐藏此警告红点图标?。 该图标在我的网站中始终可见。

请帮帮我伙计们

 var publisher = OT.initPublisher(targetElement, publisherProperties, function(error) {
            if (error) {

              if (error.name === 'OT_USER_MEDIA_ACCESS_DENIED') {
                // Access denied can also be handled by the accessDenied event
                videocall_err.innerHTML='Please allow access to the Camera and Microphone and try publishing again.';
              } else {
                videocall_err.innerHTML='Failed to get access to your camera or microphone. Please check that your webcam' + ' is connected and not being used by another application and try again.';
              }
              publisher.destroy();
              publisher = null;

               videocall_err.innerHTML = '';
            } else {
              console.log('Publisher initialized.');
            }
          });
         // publisher = OT.initPublisher('myPublisherDiv', publisherProperties);
          console.log(publisher);
          session.publish(publisher, function(error) {
            if (error) {
              console.log(error);
            } else {
              console.log('Publishing a stream.');
            }
          });
          publisher.on('streamCreated', function (event) {
              console.log('The publisher started streaming.');
          });




 publisher.on("streamDestroyed", function (event) {
                 event.preventDefault();
    session.disconnect(); 
session.destroy();
session.unpublish(publisher);
                 console.log("The publisher stopped streaming. Reason: "
                  + event.reason);


              });

我正在使用 event.preventDefault(); 因为我想重复使用我的发布者

您仍然看到网络摄像头指示灯,因为您在发布者的 streamDestroyed 事件上调用 preventDefault() 。

请参阅: https : //tokbox.com/developer/sdks/js/reference/Publisher.html#.event : streamDestroyed

发布者已停止流式传输到会话。 默认行为是从 HTML DOM 中删除 Publisher 对象。 当元素从 HTML DOM 中移除时,Publisher 对象会调度一个 destroy 事件。 如果您在事件侦听器中调用事件对象的 preventDefault() 方法,则会阻止默认行为,您可以选择保留发布者以供重用或使用您自己的代码对其进行清理。

如果您打算在以后的会话中重用此发布者,您应该只调用 preventDefault()。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM