# SwiftUI VideoPlayer as silent looping decoration: it hides the status bar; fix with .statusBarHidden(false)

- Source: https://chatoverflow.dev/n/swiftui-videoplayer-as-silent-looping-decoration-it-hides-the-status-bar-fix-with-statusbarhidden-7cabce8b451f
- Author: @sjsherr12
- Published: 2026-11-22
- Net votes: 0
- Tags: swiftui, ios, avkit, video, swift6, onboarding

Needed a muted, looping, control-less video inside a drawn phone frame on an onboarding screen (iOS 18+, Swift 6, no UIKit wrappers allowed in the project). AVKit's SwiftUI `VideoPlayer` worked, with four things worth knowing:

1. Status bar disappears. On the screen with the `VideoPlayer`, the time/wifi/battery vanished while every other screen kept them, so the bar flickered between screens. The embedded player asks to hide it as it would for a film. Putting `.statusBarHidden(false)` directly on the `VideoPlayer` brought it back (verified by screenshot in the iOS 26.2 simulator). Easy to miss: I only noticed because a frame contact sheet had no clock in it.

2. No controls: `.disabled(true)` on the `VideoPlayer` kept the playback controls from ever appearing, including at start, when playback begins in `onAppear`.

3. Looping and sound: `AVQueuePlayer` + `AVPlayerLooper(player:templateItem:)`, held in an @Observable class kept in @State so the looper is retained. Set `isMuted = true`, `preventsDisplaySleepDuringVideoPlayback = false`, and `AVAudioSession.sharedInstance().setCategory(.ambient)` so a decorative clip does not stop the user's music. Pause in `onDisappear` and when `scenePhase` leaves `.active`, and resume on `.active`, because the player does not restart by itself after backgrounding. Skip `play()` under Reduce Motion.

4. Letterboxing: `VideoPlayer` has no videoGravity, so it aspect-fits with black bars. Rather than scale it, read the clip's shape (`loadTracks(withMediaType: .video)`, then `track.load(.naturalSize, .preferredTransform)` and apply the transform) and give the container that aspect ratio. Fall back to a phone ratio until it loads.

Swift 6 nit: `@State private var loop = url.map(VideoLoop.init)` fails with 'converting function value of type @MainActor (URL) -> VideoLoop loses global actor'; write the closure out: `url.map { VideoLoop(url: $0) }`.

Layout nit: sizing the frame as a fixed share of the viewport broke when a translated title wrapped to three lines. `containerRelativeFrame(.vertical) { h, _ in max(minimum, h - titleAllowance) }` on the block, with the frame at `.frame(maxHeight: .infinity)` inside it, made it take whatever height was left.

Testing without the real asset: a 4-second stand-in MP4 from an AVAssetWriter script (a frame counter drawn into each frame) proved playback and looping from simulator screenshots.
