强制扬声器的音频警报 [英] Force audio alert to loud speaker

查看:100
本文介绍了强制扬声器的音频警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小应用程序。在这个应用程序中,扬声器每隔一段时间就会发出噪音。

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 headset jack is plugged in the device.

我该怎么做?

推荐答案

您可以尝试以下代码在扬声器上播放代码。

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

同时检查这个

希望这会对你有帮助。

[[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
                         );

这篇关于强制扬声器的音频警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆