iPhone上运行的应用程序声音太低 [英] Sound of App running on iPhone too low

查看:107
本文介绍了iPhone上运行的应用程序声音太低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个应该同时在iPad和iPhone上运行的应用程序.我正在使用AVAudioPlayer播放声音.现在我在音量方面遇到了一些问题.

I've written an App supposed to BE run both on iPad and on iPhone. I'm using AVAudioPlayer for playing back sound. Now I've run into some problems with the volume levels.

在iPad上运行时,一切都很好,在iPad模拟器中运行时,所播放声音的音量也很好.

When running on the iPad, everything is fine, the volume level of the sound being played is fine, also when running in the iPad simulator.

在iPhone上运行该应用程序时会出现问题:尽管iPhone模拟器中的音量很好,但设备上的音量却很低.

The problem arises when the app is being run on the iPhone: whereas the volume levels in the iPhone simulator are fine, the levels on the device are very low.

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

Here's the code I'm using on both devices:

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 
{
    // ...
}

有人知道为什么在模拟器和iPad上一切正常时,iPhone上的电平如此之低吗?

Does someone have an idea why the level is so low on the iPhone while everything is fine in the simulator and on the iPad?

预先感谢您的帮助.

技术数据: XCode 3.2.4 iPhone 4(4.1版)

Tech data: XCode 3.2.4 iPhone 4 (Vers. 4.1)

推荐答案

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

Are you sure you're routing the audio to the correct speaker?

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

这篇关于iPhone上运行的应用程序声音太低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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