AudioServicesPlaySystemSound卷? [英] AudioServicesPlaySystemSound Volume?

查看:233
本文介绍了AudioServicesPlaySystemSound卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code:

-(void)createAndPlaySoundID: (NSString*)name 
{
    NSString *path = [NSString stringWithFormat: @"%@/%@", [[NSBundle mainBundle] resourcePath], name];

    NSURL* filePath = [NSURL fileURLWithPath: path isDirectory: NO];
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);

    AudioServicesPlaySystemSound(soundID);
}

我把这称为像这样:

I call this like so:

[self createAndPlaySoundID: @"mySound.caf"];

这个伟大的工程,但是我有超过音量的控制。我只是希望的体积要由用户使用他们的iPad标准物理音量按钮来控制。

This works great, however I have no control over the volume. I simply want the volume to be controlled by the user using the standard physical volume buttons on their iPad.

如果我把这个量往下说了1,小青,伟大的,但如果我捶设备的音量最大至其相同体积。

If I put this volume down to say 1, it plays, great, but then if I whack the device volume up to max its the same volume.

任何帮助将是AP preciated,处理这个,谢谢。

Any help would be appreciated, handling this, thanks.

推荐答案

我也有点关于这一主题类似的问题。

I was also bit by a similar problem on this topic.

我的问题是,有一个全球性的设置,我不知道的。

My problem was that there was a global setting that I was unaware of.

在设置应用程序,在

通用>声音>铃声和警报

General > Sounds > Ringer and Alerts

如果更改与按钮设置为关闭,然后声音使用 AudioServicesPlaySystemSound()将始终扮演在最大音量的(但其他声音的API,如 AVAudioPlayer 将尊重设备的音量)。

If 'Change with Buttons' is set to Off, then sounds using AudioServicesPlaySystemSound() will always be played at full volume (yet other sound API's such as AVAudioPlayer will respect the volume of the device).

这篇关于AudioServicesPlaySystemSound卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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