From 97149df71cbf769c15ba6534953ad0f1deb79da0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 29 Aug 2022 17:56:49 +0200 Subject: [PATCH] Fix drawing state issues --- Model/Player/Backends/MPVBackend.swift | 2 +- Model/Player/PlayerModel.swift | 6 ++---- Shared/Player/PlayerDragGesture.swift | 1 + Shared/Player/VideoPlayerView.swift | 3 --- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index c89daa1c..77262407 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -502,7 +502,7 @@ final class MPVBackend: PlayerBackend { } func didChangeTo() { - setNeedsDrawing(model.presentingPlayer) + setNeedsDrawing(true) if model.musicMode { startMusicMode() diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index dcfc0c80..54881a09 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -249,6 +249,7 @@ final class PlayerModel: ObservableObject { #endif presentingPlayer = true + setNeedsDrawing(true) #if os(macOS) Windows.player.open() @@ -504,10 +505,7 @@ final class PlayerModel: ObservableObject { } #endif - DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in - guard let self = self else { return } - self.backend.setNeedsDrawing(self.presentingPlayer) - } + backend.setNeedsDrawing(presentingPlayer) controls.hide() diff --git a/Shared/Player/PlayerDragGesture.swift b/Shared/Player/PlayerDragGesture.swift index fb19bdaa..43419915 100644 --- a/Shared/Player/PlayerDragGesture.swift +++ b/Shared/Player/PlayerDragGesture.swift @@ -89,6 +89,7 @@ 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 54a65275..8fe65332 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -126,9 +126,6 @@ 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)