I am trying to play video in iOS - MPMoviePlayerController using URL. But it is not allowing me to load the video. I am using following code in viewDidLoad Method:
NSURL *fileURL = [NSURL URLWithString:@"http://videos.testtube.com/revision3/web/discoverydinosaurs/0035/discoverydinosaurs--0035--male-dinosaurs-battle--large.h264.mp4"];
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[moviePlayerController.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.movieSourceType = MPMovieSourceTypeStreaming;
moviePlayerController.fullscreen = YES;
moviePlayerController.shouldAutoplay = YES;
[moviePlayerController prepareToPlay];
[moviePlayerController play];
It is giving me following error log:
<Info>: logging starts...
<Debug>: setMessageLoggingBlock: called
ERROR: 98: Error '!obj' trying to fetch default input device's sample rate
ERROR: 100: Error getting audio input device sample rate: '!obj'
WARNING: 230: The input device is 0x0; '(null)'
WARNING: 234: The output device is 0x26; 'AppleHDAEngineOutput:1B,0,1,2:0'
ERROR: 400: error '!obj'
ERROR: 400: error -66680
ERROR: 113: * * * NULL AQIONode object
ERROR: 400: error -66680
ERROR: 400: error -66680
ERROR: 703: Can't make UISound Renderer
ERROR: 400: error -66680
ERROR: 400: error -66680
ERROR: 400: error -66680
ERROR: 400: error -66680
ERROR: 400: error -66680
Please help me to resolve this error.
Is it really possible to play video using URL in MPMoviePlayerController???
Please help.
Thanks and regards.
It is working for your URL. I have tried it...
-(void)Play
{
NSURL *videoPath = [NSURL URLWithString:@"http://videos.testtube.com/revision3/web/discoverydinosaurs/0035/discoverydinosaurs--0035--male-dinosaurs-battle--large.h264.mp4"];
MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoPath];
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:mpViewController
name:MPMoviePlayerPlaybackDidFinishNotification
object:mpViewController.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mpViewController.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(doneButtonClick:)
name:MPMoviePlayerWillExitFullscreenNotification
object:nil];
// Set the modal transition style of your choice
mpViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
// Present the movie player view controller
[self presentViewController:mpViewController animated:YES completion:nil];
// Start playback
[mpViewController.moviePlayer prepareToPlay];
[mpViewController.moviePlayer play];
}
- (void)movieFinishedCallback:(NSNotification*)aNotification
{
// Obtain the reason why the movie playback finished
NSNumber *finishReason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
// Dismiss the view controller ONLY when the reason is not "playback ended"
if ([finishReason intValue] != MPMovieFinishReasonPlaybackEnded)
{
MPMoviePlayerController *moviePlayer = [aNotification object];
// Remove this class from the observers
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
// Dismiss the view controller
[self dismissViewControllerAnimated:YES completion:nil];
}
}