@@ -43,7 +43,7 @@ struct FileViewerView: View {
4343 LazyHStack ( spacing: 1.0 ) {
4444 ForEach ( self . scrollableFiles) { sibling in
4545 NavigationStack {
46- FileViewerContentView ( file: sibling, isShown: $isShown)
46+ FileViewerContentView ( file: sibling, isShown: $isShown, playFile : . constant ( sibling == self . file ) )
4747 . toolbar {
4848 self . toolbarContent ( file: sibling)
4949 }
@@ -163,6 +163,7 @@ private struct FileViewerContentView: View {
163163 @Environment ( AppState . self) private var appState
164164 var file : SushitrainEntry
165165 @Binding var isShown : Bool
166+ @Binding var playFile : Bool
166167 @State private var error : ( any Error ) ? = nil
167168 @State private var loading : Bool = true
168169
@@ -177,6 +178,17 @@ private struct FileViewerContentView: View {
177178 self . error = nil
178179 }
179180 }
181+ else if !playFile {
182+ // Placeholder is shown while this view is not yet fully scrolled into view
183+ ZStack {
184+ if file. isVideo {
185+ Rectangle ( ) . frame ( maxWidth: . infinity, maxHeight: . infinity)
186+ . foregroundStyle ( . black)
187+ . ignoresSafeArea ( )
188+ }
189+ ThumbnailView ( file: file, showFileName: false , showErrorMessages: false , scaleToFill: false )
190+ }
191+ }
180192 else {
181193 if file. isVideo || file. isAudio {
182194 FileMediaPlayer ( file: file, visible: $isShown)
@@ -187,8 +199,12 @@ private struct FileViewerContentView: View {
187199 . id ( url)
188200 #if os(iOS)
189201 . ignoresSafeArea( )
202+ . opacity ( loading ? 0.0 : 1.0 )
190203 #endif
191204 if loading {
205+ ThumbnailView ( file: file, showFileName: false , showErrorMessages: false , scaleToFill: false )
206+ . blur ( radius: 10.0 )
207+ . opacity ( 0.5 )
192208 ProgressView ( )
193209 . progressViewStyle ( . circular) . controlSize ( . extraLarge)
194210 }
@@ -225,11 +241,7 @@ private struct FileMediaPlayer: View {
225241 private func activateSession( ) {
226242 #if os(iOS)
227243 do {
228- try session. setCategory (
229- . playback,
230- mode: . default,
231- options: [ ]
232- )
244+ try session. setCategory ( . playback, mode: . default, options: [ ] )
233245 }
234246 catch _ { }
235247
@@ -299,6 +311,7 @@ private struct FileMediaPlayer: View {
299311 do {
300312 let url = file. localNativeFileURL ?? URL ( string: self . file. onDemandURL ( ) ) !
301313 let avAsset = AVURLAsset ( url: url)
314+ Log . warn ( " StartPlayer file= \( file. fileName ( ) ) url= \( url) " )
302315 if try await avAsset. load ( . isPlayable) {
303316 let player = AVPlayer ( playerItem: AVPlayerItem ( asset: avAsset) )
304317 // TODO: External playback requires us to use http://devicename.local:xxx/file/.. URLs rather than http://localhost.
0 commit comments