From 3a8f91f88c1e17d4ef0793972ae1d556950ee617 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Fri, 17 Jul 2026 18:43:10 +0200 Subject: [PATCH] Reset player aspect ratio to 16:9 for audio-only playback Audio-only streams never report a video size, so the aspect ratio of the last played video stuck to the player area indefinitely once audio mode was enabled. Reset it in play() when the selected stream is audio-only, and let the macOS player window fall back to 16:9 instead of keeping the previous lock. --- Yattee/Services/Player/PlayerService.swift | 7 +++++++ Yattee/Views/Player/ExpandedPlayerSheet.swift | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Yattee/Services/Player/PlayerService.swift b/Yattee/Services/Player/PlayerService.swift index fdc5c483..caee4384 100644 --- a/Yattee/Services/Player/PlayerService.swift +++ b/Yattee/Services/Player/PlayerService.swift @@ -347,6 +347,13 @@ final class PlayerService { } } + // Audio-only streams never report a video size, so the previous + // video's aspect ratio would stick to the player area forever. + // Reset it so the UI falls back to the standard 16:9. + if selectedStream.isAudioOnly { + state.videoAspectRatio = nil + } + // Check for cancellation before loading stream try Task.checkCancellation() diff --git a/Yattee/Views/Player/ExpandedPlayerSheet.swift b/Yattee/Views/Player/ExpandedPlayerSheet.swift index 7ada85b1..d8b1aa4d 100644 --- a/Yattee/Views/Player/ExpandedPlayerSheet.swift +++ b/Yattee/Views/Player/ExpandedPlayerSheet.swift @@ -964,11 +964,21 @@ private struct PlayerMacOSEventHandlersModifier: ViewModifier { } private func handleAspectRatioChange(oldValue: Double?, newValue: Double?) { - guard let newValue, newValue > 0 else { return } + // nil while a video is loaded means audio-only playback (no video + // track reports a size) — fall back to the standard 16:9 instead of + // keeping the previous video's ratio. + let ratio: Double + if let newValue, newValue > 0 { + ratio = newValue + } else if playerState?.currentVideo != nil { + ratio = 16.0 / 9.0 + } else { + return + } // Always keep the manual-resize aspect lock in sync, regardless of the // auto-resize setting — the user always wants resize to be ratio-locked. - ExpandedPlayerWindowManager.shared.lockAspectRatio(newValue) + ExpandedPlayerWindowManager.shared.lockAspectRatio(ratio) guard appEnvironment?.settingsManager.playerSheetAutoResize == true else { return } @@ -977,7 +987,7 @@ private struct PlayerMacOSEventHandlersModifier: ViewModifier { Task { @MainActor in try? await Task.sleep(for: .milliseconds(100)) ExpandedPlayerWindowManager.shared.resizeToFitAspectRatio( - newValue, + ratio, animated: shouldAnimate ) }