I'm getting this error mentioned in title while playing a video from internet.
- (void)viewDidLoad
{
NSString *urlAdress = [NSString stringWithFormat:@"http://www.dailymotion.com/video/x108t8t"];
//NSString *urlAdress = [[NSBundle mainBundle] pathForResource:@"video8" ofType:@"mp4"];in this case video plays.
NSURL *videoURL = [NSURL fileURLWithPath:urlAdress];
self.mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
self.mpvc.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
//when using file in resources use MPMovieSourceTypeFile,when online then streaming
[self presentMoviePlayerViewControllerAnimated:mpvc];
[super viewDidLoad];
}
//and here is moviePlaybackDidFinish method
- (void)moviePlayBackDidFinish:(NSNotification *)notification
{
MPMoviePlayerController *theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie stop];
[theMovie.view removeFromSuperview];
NSLog(@" playback finish Called......");
}
this is whole code. i have went through most of tutorials,stackoverflow questions but could not get a single solution
Your URL is not correctly created for the case you quoted.
You are trying to play a remote stream, hence the URL needs to be a remote one.
Local file URLs are created using fileURLWithPath
. Remote URLs are created using URLWithString
.
Local File URL
NSURL *videoURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video8" ofType:@"mp4"]];
Remote URL
NSURL *videoURL = [NSURL URLWithString:@"http://www.dailymotion.com/video/x108t8t"];
well this question seems a lot on stack overflow, i got a solution to this. most of the people facing same issue have right code but only problem is we forget to add dailymotion,vimeo frameworks. since they provide their own framework sdks you can download them from links below and add them to your projects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.