My requirement is to play movies from
UICollectionView
directly by pressing play/pause remote key when cell is focused.It is perfectly working if we go background(by pressing home button) and come to foreground .But running app from xcode directly and do any actions not working.(Only play/pause button not working. other gestures,menu button and selection are working )
Play/Pause is not working for custom
AVPlayerViewController
(showsPlaybackControls = false as I have own progress and options view)prefferedFocusEnvironments
is calling properly and I am retuning focused object
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier:SuggestionsCollectionViewCell.reuseIdentifier, for: indexPath) as! SuggestionsCollectionViewCell
let playPauseRecognizer = UITapGestureRecognizer(target: self, action: #selector(selectThisMagazineCell))
playPauseRecognizer.allowedPressTypes = [NSNumber(value: UIPressType.playPause.rawValue)]
playPauseRecognizer.numberOfTapsRequired = 1
cell.addGestureRecognizer(playPauseRecognizer)
return cell
}