1

I am creating demo with OpenTok library. It is created and working fine so far.

Now I want to implement hold / pause feature in video call. But I can't find direct method to put call on hold or we can say pause video call in between.

Can we put video call on hold ? If yes, then how ?

Has anyone idea about that ?

I have refered this link : Putting a video call on hold with OpenTok But it is for .js

Update : 1

I have created properties for required Objects :

var otSession: OTSession!
var otPublisher: OTPublisher!
var otSubscriber: OTSubscriber!

And did required code for connecting session and put delegate methods.

Now on button click I want to pause video call, for that :

@IBAction func pauseVideo(_ sender: UIButton) {

    if otPublisher != nil {
        sender.isSelected = !sender.isSelected
        otPublisher?.publishVideo = !(otPublisher?.publishVideo)!
    }

    if sender.isSelected {
        self.lblPause.text = "Call paused..!!"
        self.lblPause.isHidden = false
        otSubscriber.view?.isHidden = true
        otSubscriber.view?.backgroundColor = UIColor.black
    } else {
        self.lblPause.isHidden = true
        otSubscriber.view?.isHidden = false
        otSubscriber.view?.backgroundColor = UIColor.white
    }
}

It's working fine, But now on the other hand how they know that on first end video call put on hold ?

If one end it is on hold, then other side as well we have to hide video view and make it black. Other end may be admin panel or mobile app. enter image description here

VRAwesome
  • 4,721
  • 5
  • 27
  • 52

1 Answers1

2

TokBox Developer Evangelist here.

The OpenTok iOS SDK also allows you to stop publishing audio and video using publishAudio and publishVideo properties of the Publisher Object. You can change these properties at any time after you've created the Publisher.

This would not necessarily put the Session on hold, but it would stop sending video and audio to the other participants. You would have to create your own custom logic where you would show a message or icon indicating that the session is on hold when audio and video are not being published.

Update 1(based on changes in the question):

You can implement key value observing to see if a stream property (i.e video or audio) have changed. This implementation will allow you to see when someone stops or starts publishing video. For a sample implementation, please see OpentTok (iOS) How to subscribe to hasAudio stream changes.

Manik
  • 1,495
  • 11
  • 19