【发布时间】:2013-06-24 14:51:53
【问题描述】:
我正在开发一个可在所有 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;
}
【问题讨论】:
-
你能发布你的代码吗?
-
你用什么框架播放视频?
-
您的 iPhone 4 上的 iOS 版本是什么?
-
您的问题是音量增加时无法正常缩放吗?音量是否永远不会随着滑块或物理音量按钮而改变?这是一个外部机会,但您正在测试的 iPhone 4 是否有另一个应用程序在后台运行劫持音量级别?我曾遇到过(app x)实际上将我的 iOS 设备静音的情况,我不得不关闭后台运行的应用程序以缓解问题。
-
@KhanhNguyen:我正在使用 MpMoviePlayerController 播放我的视频文件。
标签: iphone ios objective-c ipad