iosswiftios11avaudiosessionopentok

OpenTok Session Volume Change Doesn't work with MPVolumeView


Hi I've been working on using Open Tok For a streaming session I used MPVolumeView to vary system Sound.

Issue: MPVolumeView does work changing system Volume but that doesn't affect my OTSession Volume

Expected: I want to change "outputVolume" of AVAudioSession running with OpenTok

Code:

func startObservingVolumeChanges() {
    avAudioSession.addObserver(self, forKeyPath: Observation.VolumeKey, options: [.initial, .new], context: &Observation.Context)
  }

  override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    if context == &Observation.Context {
      if keyPath == Observation.VolumeKey, let volume = (change?[NSKeyValueChangeKey.newKey] as? NSNumber)?.floatValue {
        print("Volume: \(volume)")
      }
    } else {
      super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
    }
  }

  func stopObservingVolumeChanges() {
    avAudioSession.removeObserver(self, forKeyPath: Observation.VolumeKey, context: &Observation.Context)
  }

As soon as I change volume using iOS Volume buttons "Volume does get print from 0 to 1 range"

when I change value using Slider "Volume does get print from 0 to 1 range" but doesn't lower the sound of Session

Please help.


Solution

  • Discussed with OpenTok Developers. This is not supported attaching screenshot for same,

    enter image description here