iosobjective-cmpmovieplayercontrollermpmoviewcontroller

Video is not playing from URL


I have video uploaded in server url and pass the URL to MPMoviePlayerController to play the video automatically but the video is not playing and I'm getting black page. When I using the local video then it's playing.

NSURL *fileURL = [NSURL URLWithString:@"server.net/projects/media/videos/023.mp4"];

 NSLog(@"Magento url is %@", fileURL);

 moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

 [[moviePlayerController view] setFrame:CGRectMake(100,200, 600, 500)];

 [moviePlayerController setShouldAutoplay:YES];

 [moviePlayerController setControlStyle:MPMovieControlStyleEmbedded];

 [[moviePlayerController backgroundView] setBackgroundColor:[UIColor clearColor]];

 [moviePlayerController prepareToPlay];


 [self.view addSubview:moviePlayerController.view];

Solution

  • I assume the reason why player doesn't load the video because you should add http:// at the beginning