-2

Is there any way to stop and start video calling like audio features in opentok.js

When Publisher and subscriber is on video call then user can off camera and again user can On camera.

1 Answers1

1

You can toggle camera on/off while video call. Here is example.

​<!DOCTYPE HTML>
<html>
 <body>
 <div id='myPublisherDiv'></div>
 <button onclick="myFunction()">Toggle Video</button>
 <script src="https://static.opentok.com/v2/js/opentok.js" charset="utf-8"></script>
 <script charset="utf-8">
 var publisher;
 var apiKey = 'apikey';
 var sessionId = 'session id'; 
 var token = 'token';
 var session = OT.initSession(apiKey, sessionId)
 .on('streamCreated', function(event) {
 session.subscribe(event.stream);
 })
 .connect(token, function(error) {
 var pubOptions = {publishAudio:true, publishVideo:true};
 publisher = OT.initPublisher(myPublisherDiv, pubOptions);
 session.publish(publisher);
 });
 var enableVideo=true;
 function myFunction() {
 if(enableVideo)
 {
 publisher.publishVideo(false);
 enableVideo=false;
 } else
 {
 publisher.publishVideo(true);
 enableVideo=true;
 }
 }
Chomu
  • 214
  • 1
  • 10