Usually we have scenarios for playing videos within the app. MPMoviePlayerController will be used for that. But you can see MPMoviePlayerController deprecated in iOS 9 and later. So we need to put our focus on AVPlayer now. With AVPlayer either we can play video in different screen with the help of AVPlayerViewController or we can play it within a frame into any view or cell. Following code can be used to play video into an UICollectionView:
You can see here that we are playing around with layer of our view and AVPlayerLayer. After adding its layer, we can see its working in content view frame of cell. You can pass any given view frame and layer accordingly.
Following code can be used to play video with other screen using AVPlayerViewController: