MPMoviePlayerController failing to stream .3gp video since iOS 4.3
I have an existing iPhone/iPad universal app that streamed video with the MPMoviePlayerController over wi-fi (mp4) and 3G Network (3gp). When iOS 4.3 was released our 4.3 devices can no longer play a 3gp video over 3G network. I tested a local 3gp file and that fails too, but works on a 3G phone running 4.2.x.
After debugging the view controller I see the MPMoviePlayerLoadStateDidChangeNotification notification is not being triggered when trying to play the 3gp file locally or streaming it via URL.
[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];
The first condition for the loadState is always hit. For the 3gp file the code will never reach the moviePlayerLoadStateChanged selector method which hides an indicator/status view and creates other fullscreen/orientation notifications. The indicator/status view will just remain up & spinning. Within debugger I can see the onMovieDone selector method gets triggered far sooner than the video would of really of finished.
Confused.
This my answer in regards with playing .3gp file with iPhone .....I have successfully played .3gp file with iphone sdk with using MpMoviePlayerController and my answer link is:
Link: https://stackoverflow.com/a/13088808/1092219
hope you will got help from my answer.........!! :))))))
精彩评论