0

I want to display and play video in a table view cell. my code for that is: In cellForRowAtIndexPath:

 NSURL *videoURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",path,[[arrAboutUs objectAtIndex:indexPath.row] valueForKey:@"content"]]];
   MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
    [moviePlayer setControlStyle:MPMovieControlStyleNone];
    moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    [moviePlayer.view setFrame:cell.frame];
    [cell.contentView addSubview:moviePlayer.view];
    moviePlayer.view.hidden = NO;
    [moviePlayer prepareToPlay];
    [moviePlayer play];

But it is showing blank. and my video is in MP4 formate.

V-Dev
  • 488
  • 1
  • 4
  • 16

1 Answers1

1

Thank you @milan for your valuable suggestion. I use AVPlayerViewController and it working fine. code for that:

    AVPlayer*player = [[AVPlayer alloc] initWithURL:videoURL];

        AVPlayerViewController* playerController = [[AVPlayerViewController alloc] init];


        playerController.player = player;
       [self addChildViewController:playerController];

        [cell.contentView addSubview: playerController.view];
        playerController.view.frame = cell.frame;

        [player play];
V-Dev
  • 488
  • 1
  • 4
  • 16