0

When I perform the following code, AVPlayerViewController will be displayed on the cell, but when I click on the player again, will perform tableView: (UITableView *) tableView didSelectRowAtIndexPath method.What I want is when the video is playing, click on the player, will show or hide controlls instead of performing tableView: (UITableView *) tableView didSelectRowAtIndexPath

-(void)showVideoInView:(UIView *)view URL:(NSURL *)url {
if (!url || !view) {
    return;
}

CGRect frame = CGRectIntegral(view.bounds);

UIViewController *video;

if (@available(iOS 8.0,*)) {
    AVPlayerViewController * videoController = [[AVPlayerViewController alloc]init];
    videoController.view.frame = frame;
    videoController.player = [AVPlayer playerWithURL:url];
    if (@available(iOS 10.0,*)) {
        videoController.player.automaticallyWaitsToMinimizeStalling = NO;
    }
    [videoController.player play];
    video = videoController;
}else {
    MPMoviePlayerViewController *videoController = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
    videoController.view.frame = frame;
    [[videoController moviePlayer] play];
    video = videoController;
}
   [view addSubview:video.view];
}
BaQiWL
  • 417
  • 5
  • 14

1 Answers1

0

As far as I know, AVPlayers don't show the video controls when they are not full screen. You can refer this.

Instead you can add a touch gesture to the video player and add the play pause buttons accordingly. Maybe customize a bit. Also remember to reuse the cells else they will mess you the video playback. You may also want to remember the seek bar position, in case you reuse the cell.

AjinkyaSharma
  • 1,870
  • 1
  • 16
  • 26