Search code examples
iosobjective-cvideoios7mpmovieplayercontroller

iOS 7 video not being played


i have used MPMoviePlayerController to play a video but this only shows the black screen. not played my video. this code is correct. where may i wrong....

i have done this code to play video..

    NSString * str=[[NSBundle mainBundle]pathForResource:@"iGreet" ofType:@"m4v"];
    NSURL * url=[NSURL fileURLWithPath:str];
    MPMoviePlayerController * movieController=[[MPMoviePlayerController alloc]initWithContentURL:url];
    movieController.controlStyle=MPMovieControlStyleFullscreen;
    [movieController.view setFrame:self.view.bounds];
    [self.view addSubview:movieController.view];
    [movieController prepareToPlay];
    [movieController play];

Any help appreciated.. Thanks in advance..


Solution

  • If you are trying to play video from resource then you need mentioned this:

       [movieController setMovieSourceType:MPMovieSourceTypeFile];