静音时播放iOS声音 [英] iOS sound plays while muted

查看:77
本文介绍了静音时播放iOS声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为幼儿制作一个学习字母的应用程序,但在声音输出方面遇到了问题.在ipad上进行测试时,应用播放的每种声音都具有相同的音量,无论设备的声音设置为最大还是静音.换句话说,无论设备的音量设置如何,都会发出相同的声音.

I am making a learn-the-alphabet app for toddlers and I have encountered a problem with the sound output. Every sound the app plays when testing on my ipad has the same volume whether the device's sound is set at maximum or mute. In other words, the same sound level comes out regardless of the device's volume setting.

我用来播放声音的代码是(以A音为例):

The code I use to play sounds is (using the A-sound as an example):

- (IBAction)aSpill:(id)sender {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"aLyd", CFSTR("wav"), NULL);
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);

非常感谢您的帮助! :)

Any help is much appreciated! :)

推荐答案

请在此处查看答案 AudioServicesPlaySystemSound音量? 它说明了系统声音并不总是使用系统音量.

Please see the answer here AudioServicesPlaySystemSound Volume? It explains that system sounds don't always use the system volume.

我建议改用AVAudioPlayer播放声音.

I suggest using AVAudioPlayer to play your sound instead.

这篇关于静音时播放iOS声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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