gpt4 book ai didi

iphone - iPhone 上运行 App 的声音太小

转载 作者:可可西里 更新时间:2023-11-01 05:16:39 25 4
gpt4 key购买 nike

我编写了一个应用程序,应该可以在 iPad 和 iPhone 上运行。我正在使用 AVAudioPlayer 播放声音。现在,我在音量方面遇到了一些问题。

在 iPad 上运行时,一切都很好,正在播放的声音的音量级别很好,在 iPad 模拟器中运行时也是如此。

当应用程序在 iPhone 上运行时出现问题:虽然 iPhone 模拟器中的音量级别很好,但设备上的级别非常低。

这是我在两个设备上使用的代码:

if (audioPlayerAtmo==nil)
{
NSString *filename = [NSString stringWithFormat:@"Atmo_%i", currentPage];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:filename ofType:@"mp3"]];
AVAudioPlayer *tempPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
tempPlayer.delegate = self;
//NSLog(@"tempPlayer.volume: %f", [tempPlayer volume]);
[tempPlayer setVolume:1.0f];
//NSLog(@"tempPlayer.volume: %f", [tempPlayer volume]);
self.audioPlayerAtmo = tempPlayer;
[tempPlayer release];
[audioPlayerAtmo play];
btAtmo.selected = YES;
}
else // player exists
{
// ...
}

有人知道为什么 iPhone 上的水平如此低,而模拟器和 iPad 上的一切都很好吗?

预先感谢您的帮助。

技术数据:X代码 3.2.4iPhone 4(4.1 版)

最佳答案

您确定将音频路由到正确的扬声器吗?

UInt32 doChangeDefaultRoute = 1;        
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);

关于iphone - iPhone 上运行 App 的声音太小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4164170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com