Open vodemn opened 2 months ago
@vodemn on iOS you can set up a key-value observer for the properties (hasAudio, hasVideo hasCaptions, etc) of an OTStream. For example to see when a stream has captions enabled and disabled:
swift example
//add observer on a stream of interest
let hasCaptionsObservation: NSKeyValueObservation = subscriber.stream.observe(\.hasCaptions, options: [.old, .new]) { object, change in
guard let oldValue = change.oldValue else { return }
guard let newValue = change.newValue else { return }
print("KVO change for \(subscriber.stream.streamId) hasCaptions: \(newValue)")
//manipulate GUI element
}
objc example
//add observer on a stream of interest
[_subscriber.stream addObserver:self forKeyPath:@"hasCaptions" options:NSKeyValueObservingOptionNew context:NULL];
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
NSLog(@"KVO change for %@ = %@",keyPath, change);
//manipulate GUI element
}
@goncalocostamendes, any pro tips?