iPhone上运行的应用程序声音过低
我已经编写了一个应用程序,应该可以在iPad和iPhone上运行。我正在使用AVAudioPlayer播放声音。现在我在音量方面遇到了一些问题 在iPad上运行时,一切正常,播放的声音音量也正常,在iPad模拟器上运行时也是如此 当应用程序在iPhone上运行时,问题就出现了:虽然iPhone模拟器中的音量水平很好,但设备上的音量水平非常低 以下是我在两台设备上使用的代码:iPhone上运行的应用程序声音过低,iphone,ios,avaudioplayer,volume,Iphone,Ios,Avaudioplayer,Volume,我已经编写了一个应用程序,应该可以在iPad和iPhone上运行。我正在使用AVAudioPlayer播放声音。现在我在音量方面遇到了一些问题 在iPad上运行时,一切正常,播放的声音音量也正常,在iPad模拟器上运行时也是如此 当应用程序在iPhone上运行时,问题就出现了:虽然iPhone模拟器中的音量水平很好,但设备上的音量水平非常低 以下是我在两台设备上使用的代码: if (audioPlayerAtmo==nil) { NSString *filename = [NSStrin
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上的一切都很好吗
提前感谢你的帮助
技术数据:
代码3.2.4
iPhone 4(4.1版)您确定将音频传送到正确的扬声器吗
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);
对于iOS7,AudioSessionSetProperty已弃用。foundry在以下帖子中给出的答案显示了如何为iOS7做到这一点:
非常感谢您的提醒!我们需要在每个实例中编写这行代码,还是在某个地方同时编写?