Force audio alert to loud speaker

前端 未结 3 1137
眼角桃花
眼角桃花 2021-01-26 11:36

I have a small app. In this app, the loud speaker makes noise every a certain time that I set up.

Now, I want it makes noise over it\'s built-in speaker even if a headse

3条回答
  •  心在旅途
    2021-01-26 11:44

    you can try the below code to play code on speaker.

    Also check the this

    Hope this will help you.

    [[AVAudioSession sharedInstance] setDelegate:self];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];
    
    
    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
    
    AudioSessionSetProperty (
                             kAudioSessionProperty_OverrideAudioRoute,
                             sizeof (audioRouteOverride),
                             &audioRouteOverride
                             );
    

提交回复
热议问题