title: How do I play video (autoplay) in UITableViewCell in iOS
body: <p>I am playing a video in <code>UITableViewCell</code>. For that I am using the following code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *VideoCellIdentifier = @"VideoCell";
  
      NSDictionary *_response_data = [self.response objectAtIndex:indexPath.row];
  
      VideoCustomCell *cell = (VideoCustomCell *) [tableView dequeueReusableCellWithIdentifier:VideoCellIdentifier];
  
      if (cell == nil) {
          NSArray *topLevelObjects;
          topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"VideoCustomCell" owner:self options:nil];
          for (id currentObject in topLevelObjects){
              if ([currentObject isKindOfClass:[UITableViewCell class]]){
                  cell =  (VideoCustomCell *) currentObject;
                  cell.delegate  = self;
                  break;
              }
          }
      }
  
      avPlayer = [[AVPlayer playerWithURL:[NSURL URLWithString:[_response_data valueForKey:@"media_id"]]] retain];
      avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
      avPlayerLayer.frame = cell.video_player_view.layer.bounds;
      avPlayerLayer.videoGravity = AVLayerVideoGravityResize;
      [cell.video_player_view.layer addSublayer: avPlayerLayer];
      [avPlayer play];
  
      return cell;
  }
  </code></pre>
  
  <p>The video is playing properly, but I want to play only one video at a time. Play the video of the cell which is fully visible.</p>