From 08ae69b5d2d60134f9070ae99f5e4990b001b6dc Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 11 Jul 2022 00:42:47 +0200 Subject: [PATCH] Minor fixes --- Model/Applications/InvidiousAPI.swift | 8 +++++++- Shared/Player/Controls/PlayerControls.swift | 1 - Shared/Player/VideoPlayerView.swift | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Model/Applications/InvidiousAPI.swift b/Model/Applications/InvidiousAPI.swift index 9a6ee1a1..162639d4 100644 --- a/Model/Applications/InvidiousAPI.swift +++ b/Model/Applications/InvidiousAPI.swift @@ -508,7 +508,13 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { } private func extractAdaptiveFormats(from streams: [JSON]) -> [Stream] { - guard let audioStream = streams.first(where: { $0["type"].stringValue.starts(with: "audio/mp4") }) else { + let audioStreams = streams + .filter { $0["type"].stringValue.starts(with: "audio/mp4") } + .sorted { + $0.dictionaryValue["bitrate"]?.int ?? 0 > + $1.dictionaryValue["bitrate"]?.int ?? 0 + } + guard let audioStream = audioStreams.first else { return .init() } diff --git a/Shared/Player/Controls/PlayerControls.swift b/Shared/Player/Controls/PlayerControls.swift index 236263fe..a9e9ab69 100644 --- a/Shared/Player/Controls/PlayerControls.swift +++ b/Shared/Player/Controls/PlayerControls.swift @@ -124,7 +124,6 @@ struct PlayerControls: View { .foregroundColor(.secondary) .modifier(ControlBackgroundModifier()) .clipShape(RoundedRectangle(cornerRadius: 2)) - .offset(x: -2, y: -2) } .buttonStyle(.plain) .opacity(model.presentingControls || model.presentingOverlays ? 0 : player.lastSkipped.isNil ? 0 : 1) diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index 4cbd8723..13d57577 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -41,6 +41,7 @@ struct VideoPlayerView: View { @State private var orientation = UIInterfaceOrientation.portrait @State private var lastOrientation: UIInterfaceOrientation? #elseif os(macOS) + var hoverThrottle = Throttle(interval: 0.5) var mouseLocation: CGPoint { NSEvent.mouseLocation } #endif @@ -209,8 +210,10 @@ struct VideoPlayerView: View { #elseif os(macOS) .onAppear(perform: { NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) { - if !player.currentItem.isNil, hoveringPlayer { - playerControls.resetTimer() + hoverThrottle.execute { + if !player.currentItem.isNil, hoveringPlayer { + playerControls.resetTimer() + } } return $0