iOS Question Method to play sounds even when silent mode is on

Pete_S

Member
Licensed User
I noticed that there is an app in the AppStore called Trivia 360 that will play sound effects even when silent mode is off. Is there a way to do that in B4i?
 

Sandman

Expert
Licensed User
Longtime User
The user has told the phone they want it to be quiet. Why would you want to ignore their wish? Just curious.
 
Upvote 0

Pete_S

Member
Licensed User
Because users put silent mode on to avoid phone rings and text message dings but they still want to hear the sounds of the games that they are actively playing. This is probably why the popular Trivia 360 in the AppStore uses it
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You need to set the audio session category to AVAudioSessionCategoryPlayback.

B4X:
#If OBJC
#import <AVFoundation/AVFoundation.h>
- (void) setAudioSession {
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback withOptions: AVAudioSessionCategoryOptionDefaultToSpeaker error: nil];
}
#end if

Call it with:
B4X:
Me.As(NativeObject).RunMethod("setAudioSession", Null)
 
Upvote 0
Top