Xcode SwiftUI video editing splash screen

Hi,

I'm trying to create our app splash screen which I need a video to play in the background. I've currently got the video into my project under the following code with AV kit/foundation imported:

    VideoPlayer(player: AVPlayer(url: Bundle.main.url(forResource: "XXXXXX", withExtension: "mp4")!))       .frame(height: 400)       But I need to complete three tasks:

  1. Make the video full screen
  2. Remove the player buttons
  3. Play the video automatically

All resources online seem outdated and don't work on Xcode 14.

Any help from a pro would be greatly appreciated!

Thanks

Replies

update: we have a bigger screen, but still not quite full screen:

  VideoPlayer(player: AVPlayer(url: Bundle.main.url(forResource: "XXXXXX", withExtension: "mp4")!))       .padding(.leading, -85.0)       .aspectRatio(contentMode: .fill)       .ignoresSafeArea()       .controlSize(.large)      

You probably won't be able to use VideoPlayer to do what you are trying to do. You likely need to use AVPlayerViewController and bridge to SwiftUI yourself.

Side note about VideoPlayer though: Creating the AVPlayer inline will likely lead to unexpected behavior if your view refreshes, as it will create a new AVPlayer each time.