StopAudio & unsubscribe from audio doesn't work

Description
When starting the session with the audio disconnected:

let audioOptions = ZoomVideoSDKAudioOptions()
audioOptions.connect = false
audioOptions.mute = true

let ctx = ZoomVideoSDKSessionContext()
ctx.audioOption = audioOptions
ctx.virtualAudioMicDelegate = self
ctx.virtualAudioSpeakerDelegate = self

the callback:

func onOneWayAudioReceived(_ rawData: ZoomAudioRawData?, user: ZoomUser?)

doesn’t get called when there is audio in the session. :white_check_mark:

After calling:

zoom?.getAudioHelper().startAudio()

The callback onOneWayAudioReceived gets called when there is audio in the session. :white_check_mark:

At that point calling:

zoom?.getAudioHelper().stopAudio()

and/or also:

zoom?.getAudioHelper().subscribe() / zoom?.getAudioHelper().unSubscribe()

in different orders the callback onOneWayAudioReceived still gets called when there is audio in the session. :x:

Which iOS Video SDK version?
v1.3.2
v1.5.2

Hi @rokgregoric ,

Thanks for sharing on the forum! Are you getting the user’s ZoomVideoSDKAudioType first per our guidance here?

Here’s the full reference: Reference

Hi @gianni.zoom,
The audioType works correctly. And YES I check the audioType before starting/stopping audio.

Before I start audio I see:

me?.audioStatus()?.audioType == .None

after starting audio I see:

me?.audioStatus()?.audioType == .VOIP

and after stopping audio I see:

me?.audioStatus()?.audioType == .None

but the callbacks are still being called.

as a reference … here is a code snippet that explains how I change states:

/// start+unmute / mute+stop audio
private func set(audio enabled: Bool) {
  if enabled {
    if me?.audioStarted == false {
      shouldUnmuteAudio = true
      audio(start: true)
    } else if unmute {
      audio(mute: false)
    }
  } else {
    if me?.audioStarted == true {
      if me?.audioMuted == true {
        audio(start: false)
      } else {
        shouldStopAudio = true
        audio(mute: true)
      }
    }
  }
}

private func audioDidChange() {
  DispatchQueue.main.async(execute: audioFixes)
}

private var shouldUnmuteAudio = false
private var shouldStopAudio = false

private func audioFixes() {
  if shouldUnmuteAudio {
    shouldUnmuteAudio = false
    audio(mute: false)
  } else if shouldStopAudio {
    shouldStopAudio = false
    audio(start: false)
  }
}

func onUserAudioStatusChanged(_ helper: ZoomVideoSDKAudioHelper?, user userArray: [ZoomVideoSDKUser]?) {
  audioDidChange()
}

extension ZoomVideoSDKUser {
  var audioStarted: Bool { audioStatus()?.audioType == .VOIP }
  var audioMuted: Bool { audioStatus()?.isMuted == true }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.