Video Streaming Tutorial for iOS: Getting Started | Kodeco, the new raywenderlich.com

Learn how to build a video streaming app using AVKit and AVFoundation frameworks.


This is a companion discussion topic for the original entry at https://www.kodeco.com/22372639-video-streaming-tutorial-for-ios-getting-started

In my implementation of the full screen video, I’m missing the “cross” to close the video. What did I miss?

Hi.

There could me many reasons for that. I’ll name a few.

  • You may have pushed the viewController instead of preseting it as a modal. If you do so, you need to handle the popping behavior yourself.
  • You may have added another subview that obscures the default dismiss button.
  • You may be using SwiftUI’s default VideoPlayer. As mentioned in the article in the case of PiP, there are some weird issues going on with that component. I’ve found this regarding your issue and it seems to happen on iOS 16.
    I’d suggest you use AVPlayerController from UIKit.

I hope this helps.
Have a good day ahead.

Hi, just finished the tutorial and enjoyed learning from it! A couple of feedback items:

  • There is one line that says Since you’re wrapping the player layer in a view, you need to expose a player property. I think you meant to say playerLayer property, or layer property?
  • I did this tutorial using my iPhone 14 Pro using iOS 16.2. It could be worth mentioning that it seems like the button to dismiss the full screen video player does not come with the AVPlayer out of the box as of iOS 16 (according to this SO post), but this is resolved once we use the AVPlayerViewController at the end. Could be a helpful caveat if you’ve got the bandwidth to update the tutorial, and could be a good additional item for the “where to go from here?” section to add our own close button, or to implement a pull-to-dismiss behavior!

By the way, is it still the case that we still need KVO to inspect the player’s properties for looping? I’m holding out hope that a better API has appeared within the last few years :sweat_smile:

Anyway, thanks again!