1

I need a possibility in the TokBox iOS SDK to find out if a subscribed stream has audio dynamically / via an event. (OTStream.hasAudio)

OTSubscriberDelegate provides callbacks for the subscribed video state subscriberVideoEnabled/Disabled but I can't find anything for audio.

david
  • 662
  • 5
  • 8

1 Answers1

2

TokBox Developer Evangelist here.

For the iOS SDK, we don't provide a delegate for stream property changes, but you can implement key value observing(KVO) to check if the observed stream property has changed.

In the example below, I added an observer for the hasAudio stream property and the observer will print the old and new values whenever it changes.

 func session(_ session: OTSession, streamCreated stream: OTStream) {
   let hasAudioObservation: NSKeyValueObservation = stream.observe(\.hasAudio, options: [.old, .new]) { object, change in
     guard let oldValue = change.oldValue else { return }
     guard let newValue = change.newValue else { return }
     print("Old stream value: \(oldValue)")
     print("New stream value: \(newValue)")
}
Manik
  • 1,495
  • 11
  • 19