我寫了一個應用程序應該在iPad和iPhone上運行。我正在使用AVAudioPlayer播放聲音。現在我遇到了音量級別的一些問題。在iPhone上運行的應用程序聲音太低
在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上的?
在此先感謝您的幫助。
技術數據: 的XCode 3.2.4 iPhone 4(弗斯4.1)
非常感謝您的幫助!它現在有效。 – MatthiasC 2010-11-12 13:18:46
+1熱門答案!奇蹟般有效! – Groot 2012-12-14 15:07:10
我們是否需要在每個實例上編寫這行代碼,或者在某處寫入? – 2014-01-11 07:00:09