mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix player initializer
This commit is contained in:
parent
ac8cb98cdd
commit
53fbae29a0
@ -29,6 +29,8 @@ struct ContentView: View {
|
|||||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@State private var playerInitialized = false
|
||||||
|
|
||||||
let persistenceController = PersistenceController.shared
|
let persistenceController = PersistenceController.shared
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -120,6 +122,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
|
.background(playerViewInitialize)
|
||||||
.alert(isPresented: $navigation.presentingAlert) { navigation.alert }
|
.alert(isPresented: $navigation.presentingAlert) { navigation.alert }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +162,18 @@ struct ContentView: View {
|
|||||||
.environmentObject(thumbnailsModel)
|
.environmentObject(thumbnailsModel)
|
||||||
.environment(\.navigationStyle, navigationStyle)
|
.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 {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
|
@ -231,12 +231,7 @@ struct YatteeApp: App {
|
|||||||
subscriptions.load()
|
subscriptions.load()
|
||||||
playlists.load()
|
playlists.load()
|
||||||
|
|
||||||
#if os(macOS)
|
#if !os(macOS)
|
||||||
Windows.player.open()
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
||||||
Windows.main.focus()
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
player.updateRemoteCommandCenter()
|
player.updateRemoteCommandCenter()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ struct TVNavigationView: View {
|
|||||||
|
|
||||||
@Default(.visibleSections) private var visibleSections
|
@Default(.visibleSections) private var visibleSections
|
||||||
|
|
||||||
@State private var playerInitialized = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
TabView(selection: navigation.tabSelectionBinding) {
|
TabView(selection: navigation.tabSelectionBinding) {
|
||||||
@ -58,7 +56,6 @@ struct TVNavigationView: View {
|
|||||||
.tag(TabSelection.settings)
|
.tag(TabSelection.settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.background(videoPlayerInitialize)
|
|
||||||
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {
|
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {
|
||||||
if let video = navigation.videoToAddToPlaylist {
|
if let video = navigation.videoToAddToPlaylist {
|
||||||
AddToPlaylistView(video: video)
|
AddToPlaylistView(video: video)
|
||||||
@ -78,18 +75,6 @@ struct TVNavigationView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder var videoPlayerInitialize: some View {
|
|
||||||
if !playerInitialized {
|
|
||||||
VideoPlayerView()
|
|
||||||
.scaleEffect(0.00001)
|
|
||||||
.onAppear {
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
||||||
playerInitialized = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TVNavigationView_Previews: PreviewProvider {
|
struct TVNavigationView_Previews: PreviewProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user