Skip to content

Commit

Permalink
解决tvos没有onDisappear的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Dec 3, 2023
1 parent b3ab335 commit 58b46dd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ public struct KSVideoPlayerView: View {
}
}
#endif
.onAppear {
if let subtitleDataSouce {
playerCoordinator.subtitleModel.addSubtitle(dataSouce: subtitleDataSouce)
}
// 不要加这个,不然playerCoordinator无法释放,也可以在onDisappear调用removeMonitor释放
// #if os(macOS)
// NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
// isMaskShow = overView
// return $0
// }
// #endif
}
.onDisappear {
onPlayerDisappear?(playerCoordinator.playerLayer)
}
.ignoresSafeArea()
#if os(iOS) || os(xrOS)
.navigationBarTitleDisplayMode(.inline)
Expand Down Expand Up @@ -142,6 +127,21 @@ public struct KSVideoPlayerView: View {
#endif
}
}
.onAppear {
if let subtitleDataSouce {
playerCoordinator.subtitleModel.addSubtitle(dataSouce: subtitleDataSouce)
}
// 不要加这个,不然playerCoordinator无法释放,也可以在onDisappear调用removeMonitor释放
// #if os(macOS)
// NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
// isMaskShow = overView
// return $0
// }
// #endif
}
.onDisappear {
onPlayerDisappear?(playerCoordinator.playerLayer)
}
.preferredColorScheme(.dark)
.tint(.white)
.persistentSystemOverlays(.hidden)
Expand Down

0 comments on commit 58b46dd

Please sign in to comment.