I am currently creating an iOS app, but I am also worried about the process of making sounds even in silent mode.
Objective-C should be the following code.
AudioSessionInitialize (NULL, NULL, NULL, NULL);
UInt32 category = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
size of (UInt32),
& category);
AudioSessionSetActive=true
I don't know how to convert the above code to Swift.
I think it is the image below, but it seems that the setProperty
method does not exist.
varaudioSession=AVAudioSession.sharedInstance()
audioSession.setProperty(...)
audioSession.setActive(true, error:nil)
Could someone please give me some advice?
Thank you for your cooperation.
I only checked the playground to the point where there are no errors, but
varaudioSession=AVAudioSession.sharedInstance()
audioSession.setCategory (AVAudioSessionCategoryPlayback, error:nil)
audioSession.setActive(true, error:nil)
If so, I think it will be the same.
© 2024 OneMinuteCode. All rights reserved.