App in Background Or Lock Phone Then Spatial Audio Selector Not Working
For Spatial Audio,
Here we Declare Variable of CADisplayLink ->
private var AudioUpdater: CADisplayLink?
And Play Audio Function we write code for Play Spatial Audio ->
spatialNotificationAudioUpdater = CADisplayLink(target: self, selector: #selector(self.AudioUpdateUI))
And this function is used when my spatial start playing
@objc func AudioUpdateUI() {
AudioCurrentPosition = AudioCurrentFrame + AudioSkipFrame
AudioCurrentPosition = max(AudioCurrentPosition, 0)
AudioCurrentPosition = min(AudioCurrentPosition, AudioLengthSamples)
// if reached end of audio file
if AudioCurrentPosition >= AudioLengthSamples {
}
}
When i play audio in Foreground mode then AudioUpdateUI() function is called but when my app is on Background (Phone Lock) then AudioUpdateUI() function is not Called.
Thanks,
Ketan.
Answers
Did you put break points and logging statements? What are those looking like?
Best,
@[email protected]
we we added breakpoint in @objc func AudioUpdateUI() {} function breakpoint is called when my app is on Foreground Mode. But when my app is on background mode (Phone Locked) then breakpoint of @objc func AudioUpdateUI() {} is not Called.
And When my app in background mode then breakpoint not called and whenever i return to foreground mode then breakpoint working perfectly.
Here, can i missing to set any properties or anything else for setting spatial audio?
Thanks,
@KetanSodvadiya
Did you implement a background task when your app enters background via the app delegate's didEnterBackground method?
@[email protected]
Yes, I implement app delegate's didEnterBackground method and also Enable Background Mode from capabilities.
Thanks,
@KetanSodvadiya
What do you have under didEnterBackground method?
Thanks,
@[email protected]