Search code examples
iphoneobjective-cxcodempmovieplayercontroller

iOS : Playing remote video with URL with MPMoviePlayerController


NSURL *url= [NSURL URLWithString:@"http://www.dailymotion.com/video/x109z02"];
MPMoviePlayerController  *theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
theMoviPlayer.scalingMode = MPMovieScalingModeFill;
theMoviPlayer.view.frame = CGRectMake(0, 60, 320, 350);
[self.view addSubview:theMoviPlayer.view];
[self.theMoviPlayer play];

framework is also addded and imported in .h file but video is not playing in iphone (internet connection is also ok)


Solution

  • NSURL *url   = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
    _moviePlayer = [[MPMoviePlayerController alloc]
                                              initWithContentURL:url];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                          selector:@selector(moviePlayBackDidFinish:)
                                          name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:_moviePlayer];
    
    _moviePlayer.controlStyle   = MPMovieControlStyleDefault;
    _moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:_moviePlayer.view];
    [_moviePlayer setFullscreen:YES animated:YES];