title: play video in single cell in collection view
body: <p>I have problem with playing video in the collection view cell in single cell</p>
  
  <p>cell can have both video and images, when its video the video is downloaded and played from local directory</p>
  
  <p>collection View has 2 cells in each row</p>
  
  <p>problem is : i want video to play in only 1 cell at a time and stop when that video is no more visible </p>
  
  <p>I used following code in cell for item at index path.</p>
  
  <pre><code>let localVideoURL = getDownloadedVideoPathFromDocumentDirectory(filename: eachTimeLineFeed.mediaFile!)
      print("Play Video from URL \(localVideoURL)")
  
          let item = AVPlayerItem(url: localVideoURL!);
          self.avPlayer = AVPlayer(playerItem: item);
          self.avPlayer?.actionAtItemEnd = .none
          self.avPlayerLayer = AVPlayerLayer(player: self.avPlayer);
  
          self.avPlayerLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
          self.avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: SCREENWIDTH()/2, height: SCREENWIDTH()/2)
          cell.viewVideo.layer.addSublayer(self.avPlayerLayer!)
          NotificationCenter.default.addObserver(self, selector: #selector(self.playerItemDidReachEnd), name: NOTIFICATION_PLAYER_DID_END_PLAYING_VIDEO, object: self.avPlayer?.currentItem!)
          self.avPlayer?.play()
  </code></pre>