Video Player: Pause video when onDisappear

This commit is contained in:
Thomas Ricouard 2023-08-09 13:53:41 +02:00
parent 27164fa399
commit 04b5804c96
1 changed files with 3 additions and 0 deletions

View File

@ -68,6 +68,9 @@ struct VideoPlayerView: View {
}.onAppear { }.onAppear {
viewModel.preparePlayer(autoPlay: preferences.autoPlayVideo) viewModel.preparePlayer(autoPlay: preferences.autoPlayVideo)
} }
.onDisappear {
viewModel.pause()
}
.cornerRadius(4) .cornerRadius(4)
.onChange(of: scenePhase, perform: { scenePhase in .onChange(of: scenePhase, perform: { scenePhase in
switch scenePhase { switch scenePhase {