我有一个现有的iPhone / iPad通用应用程序,通过Wi-Fi(mp4)和3G网络(3gp)与MPMoviePlayerController一起流式传输视频。当iOS 4.3发布时,我们的4.3设备无法再通过3G网络播放3gp视频。我测试了一个本地3gp文件但也失败了,但是在运行4.2.x的3G手机上运行。
调试视图控制器后,我看到尝试在本地播放3gp文件或通过URL流式传输时未触发MPMoviePlayerLoadStateDidChangeNotification通知。
[APPDEL showStatusView: @"Please wait..."];
NSString * videoUrl = [[request.URL description] stringByReplacingOccurrencesOfString: @"idvideo:" withString: @"http:"];
DLog(@"Loading video %@", videoUrl);
_moviePlayer = [[IDMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString: videoUrl]];
_moviePlayer.view.backgroundColor = [UIColor clearColor];
_moviePlayer.allowsAirPlay = YES;
_moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
if ([_moviePlayer respondsToSelector:@selector(loadState)]) {
// May help to reduce latency
[_moviePlayer prepareToPlay];
// Register that the load state changed (movie is ready)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:_moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:_moviePlayer];
//[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(moviePlayerTimerUp:) userInfo:nil repeats:NO];
}
else {
// Register to receive a notification when the movie is in memory and ready to play.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(onMovieDone:) name: MPMoviePlayerPlaybackDidFinishNotification object: nil];
if ([_moviePlayer respondsToSelector: @selector(view)]) {
[self.view addSubview: _moviePlayer.view];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
_moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
}
else {
_moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
}
_moviePlayer.view.frame = _webView.frame;
}
[_moviePlayer play];
始终命中loadState的第一个条件。对于3gp文件,代码永远不会到达moviePlayerLoadStateChanged选择器方法,该方法隐藏指示符/状态视图并创建其他全屏/方向通知。指标/状态视图将保持不变并且纺纱。在调试器中,我可以看到onMovieDone选择器方法的触发时间远远超过视频真正完成的时间。
混淆。
答案 0 :(得分:0)
这是我用iPhone播放 .3gp 文件的答案..... 我已成功播放.3gp文件与iphone sdk 使用 MpMoviePlayerController ,我的回答链接是:
希望你能从我的回答中得到帮助......... !! :))))))