Fix player initializer

This commit is contained in:
Arkadiusz Fal
2022-08-29 15:31:36 +02:00
parent ac8cb98cdd
commit 53fbae29a0
3 changed files with 16 additions and 21 deletions

View File

@@ -29,6 +29,8 @@ struct ContentView: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
@State private var playerInitialized = false
let persistenceController = PersistenceController.shared
var body: some View {
@@ -120,6 +122,7 @@ struct ContentView: View {
}
)
#endif
.background(playerViewInitialize)
.alert(isPresented: $navigation.presentingAlert) { navigation.alert }
}
@@ -159,6 +162,18 @@ struct ContentView: View {
.environmentObject(thumbnailsModel)
.environment(\.navigationStyle, navigationStyle)
}
@ViewBuilder var playerViewInitialize: some View {
if !playerInitialized {
VideoPlayerView()
.scaleEffect(0.00001)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
playerInitialized = true
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {

View File

@@ -231,12 +231,7 @@ struct YatteeApp: App {
subscriptions.load()
playlists.load()
#if os(macOS)
Windows.player.open()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Windows.main.focus()
}
#else
#if !os(macOS)
player.updateRemoteCommandCenter()
#endif