Search code examples
iosswiftswiftuivideo-playerswiftui-navigationlink

SwiftUI VideoPlayer dismisses entire root view


On ios14 SwiftUI 2.0 i'm using the video player.

I have it setup in a NavigationLink like so..

    NavigationLink(destination: VideoPlayer(player: AVPlayer(url: ***)), isActive: $isActive) {
        EmptyView()
    }

This works well and plays the video, however when I tap the built in "X" in the top right of the video player my entire SwiftUI view is dismissed. This includes the video player and the view it was presented from.


Solution

  • After some discovery, it looks like this can be resolved by presenting this view in the fullScreenCover.

        VStack {
            EmptyView()
        }.fullScreenCover($isPresented) {
            VideoPlayer...
        }