除iPhone4外,所有iOS设备上的音量都很好。在iPhone上,这个级别非常低
我正在开发一个在所有iOS设备上运行的iOS应用程序。在我的应用程序中,我正在播放一些视频文件。除了iPhone4之外,所有设备都可以正常工作。在iPhone4上,即使所有其他应用程序在该设备上使用正常音量,音量也非常低。在所有其他设备上,音量都可以。 有谁能帮我解决这个麻烦吗? 提前谢谢 这是源代码除iPhone4外,所有iOS设备上的音量都很好。在iPhone上,这个级别非常低,iphone,ios,objective-c,ipad,Iphone,Ios,Objective C,Ipad,我正在开发一个在所有iOS设备上运行的iOS应用程序。在我的应用程序中,我正在播放一些视频文件。除了iPhone4之外,所有设备都可以正常工作。在iPhone4上,即使所有其他应用程序在该设备上使用正常音量,音量也非常低。在所有其他设备上,音量都可以。 有谁能帮我解决这个麻烦吗? 提前谢谢 这是源代码 NSInteger selectedVideoTag = sender.tag; NSString *videoPath = [self getVideoToBePlayedForButtonTa
NSInteger selectedVideoTag = sender.tag;
NSString *videoPath = [self getVideoToBePlayedForButtonTag:selectedVideoTag];
NSURL *videoUrl = [[NSURL alloc] initFileURLWithPath:videoPath];
NSLog(@"videoUrl = %@", videoUrl);
self.theMovie = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.theMovie];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackStateChaned:)
name:MPMoviePlayerWillExitFullscreenNotification
object:self.theMovie];
[self.theMovie prepareToPlay];
[self.theMovie.view setFrame:[[UIScreen mainScreen] bounds]];
[self.view addSubview:self.theMovie.view];
self.theMovie.controlStyle = MPMovieControlStyleDefault;
[self.theMovie setFullscreen:YES animated:YES];
[self.theMovie setScalingMode:MPMovieScalingModeAspectFill];
self.theMovie.movieSourceType = MPMovieSourceTypeFile;
[self.theMovie play];
下面是GetVideoToDeplayedForButtontag消息的代码:
- (NSString *) getVideoToBePlayedForButtonTag:(NSInteger)btnTag
{
NSString *videoPath = nil;
//Trigger MixPanel events for selected button
Mixpanel *mixPanel = [Mixpanel sharedInstance];
switch (btnTag) {
case 1:
videoPath =[[NSBundle mainBundle] pathForResource:@"song_01" ofType:@"mp4"];
break;
case 2:
videoPath =[[NSBundle mainBundle] pathForResource:@"song_02" ofType:@"mp4"];
break;
case 3:
videoPath =[[NSBundle mainBundle] pathForResource:@"song_03" ofType:@"mp4"];
break;
case 4:
videoPath =[[NSBundle mainBundle] pathForResource:@"song_04" ofType:@"mp4"];
break;
default:
break;
}
return videoPath;
}找到了这个问题的解决方案。 在我的应用程序中,我必须覆盖静音开关,所以我在AppDelegate.m中添加了代码
NSError *categoryError = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&categoryError];
由于这一类别,iPhone4的产量很低。
我把密码改成
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&categoryError];
现在,它工作得很好。尽管如此,我仍然无法理解为什么只有iPhone 4上的声音输出较低,而没有任何其他设备,如iPad、iPhone 5。你能发布你的代码吗?你用什么框架来播放视频?你的iPhone 4上的iOS版本是什么?你的问题是音量在增加时不能正确缩放吗?音量是否从不随滑块或物理音量按钮变化?这是一个外部的机会,但你正在测试的iPhone4是否有另一个应用程序在后台运行,从而影响了音量水平?我曾经有过(应用程序x)几乎使我的iOS设备静音的情况,为了缓解这个问题,我不得不关闭后台运行的应用程序。@Khanhunguyen:我正在使用MpMoviePlayerController来播放我的视频文件。我想这是因为当你选择“播放和录制”时该库假设您正在执行类似VOIP的操作,这意味着用户将手机举到了耳边。在这种情况下,您可能希望音量低于您面前的音量。你可以通过设置
kAudioSessionProperty\u OverrideCategoryDefaultToSpeaker
@LewisGordon:我同意你的观点,但我仍然不明白为什么库会认为只有在iPhone 4而不是其他设备的情况下才会这样。