我正在开发一个在所有 iOS 设备上运行的 iOS 应用程序。在我的应用程序中,我正在播放一些视频文件。除 iPhone 4 外的所有设备上一切正常。在 iPhone4 上,即使所有其他应用程序在该设备上以正常音量运行,音量也非常低。在所有其他设备上,音量都很好。有人可以帮我解决这个问题吗?提前致谢。
这是源代码
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];
这是 getVideoToBePlayedForButtonTag 消息的代码:
- (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;
}