From b220f212dfadf183bf0e245f91daebc671491762 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 31 Aug 2022 21:20:12 +0200 Subject: [PATCH] Revert "Fix drawing state issues" This reverts commit 97149df71cbf769c15ba6534953ad0f1deb79da0. --- Model/Player/Backends/MPVBackend.swift | 2 +- Model/Player/PlayerModel.swift | 6 ++++-- Shared/Player/PlayerDragGesture.swift | 1 - Shared/Player/VideoPlayerView.swift | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index 77262407..c89daa1c 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -502,7 +502,7 @@ final class MPVBackend: PlayerBackend { } func didChangeTo() { - setNeedsDrawing(true) + setNeedsDrawing(model.presentingPlayer) if model.musicMode { startMusicMode() diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index eb0bdd1e..7e4bbab1 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -249,7 +249,6 @@ final class PlayerModel: ObservableObject { #endif presentingPlayer = true - setNeedsDrawing(true) #if os(macOS) Windows.player.open() @@ -505,7 +504,10 @@ final class PlayerModel: ObservableObject { } #endif - backend.setNeedsDrawing(presentingPlayer) + DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in + guard let self = self else { return } + self.backend.setNeedsDrawing(self.presentingPlayer) + } controls.hide() diff --git a/Shared/Player/PlayerDragGesture.swift b/Shared/Player/PlayerDragGesture.swift index c7bf9934..73d34c5f 100644 --- a/Shared/Player/PlayerDragGesture.swift +++ b/Shared/Player/PlayerDragGesture.swift @@ -89,7 +89,6 @@ extension VideoPlayerView { withAnimation(Constants.overlayAnimation) { viewDragOffset = Self.hiddenOffset } - player.backend.setNeedsDrawing(false) } else { withAnimation(Constants.overlayAnimation) { viewDragOffset = 0 diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index db20330f..40aa8aea 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -126,6 +126,9 @@ struct VideoPlayerView: View { .onChange(of: geometry.size) { size in self.playerSize = size } + .onChange(of: fullScreenDetails) { value in + player.backend.setNeedsDrawing(!value) + } #if os(iOS) .frame(width: playerWidth.isNil ? nil : Double(playerWidth!), height: playerHeight.isNil ? nil : Double(playerHeight!)) .ignoresSafeArea(.all, edges: playerEdgesIgnoringSafeArea)