I'm trying to put a video in the background with swifui 2 and IOS 14
My goal is for the bar with the play button to disappear completely.
Normally with .disabled (true) the bar should disappear but this is
not the case it is always present at the start of the video and
disappears about 1 sec after the start of playback.
where is my error in my code?
What I have done
My goal is for the bar with the play button to disappear completely.
Normally with .disabled (true) the bar should disappear but this is
not the case it is always present at the start of the video and
disappears about 1 sec after the start of playback.
where is my error in my code?
What I have done
Code Block import SwiftUI import AVKit struct TestBackground: View { private let player = AVPlayer(url: URL(string: "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8")!) private let controler = AVPlayerViewController() init() { let control = AVPlayerViewController() control.showsPlaybackControls = true } var body: some View { VideoPlayer(player: player) .aspectRatio(contentMode: .fill) .edgesIgnoringSafeArea(.all) .disabled(true) .onAppear() { player.isMuted = true player.play() } .onDisappear() { // Stop the player when the view disappears player.pause() } .scaledToFill() } } struct TestBackground_Previews: PreviewProvider { static var previews: some View { TestBackground() } }