From f9c8fdbb56a343c0d60b8b2c2c18d4fa537bc262 Mon Sep 17 00:00:00 2001 From: Guillaume Louel <37544189+glouel@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:55:33 +0200 Subject: [PATCH] Fix overlays showing on wrong screens --- Aerial.xcodeproj/project.pbxproj | 8 ++-- Aerial/Source/Models/Sources/Source.swift | 20 +++++++++- Aerial/Source/Views/AerialView+Player.swift | 39 ++++++++++++------- Aerial/Source/Views/AerialView.swift | 13 +++++-- .../CompanionCacheViewController.xib | 4 +- .../Settings panels/TimeViewController.xib | 8 ++-- 6 files changed, 63 insertions(+), 29 deletions(-) diff --git a/Aerial.xcodeproj/project.pbxproj b/Aerial.xcodeproj/project.pbxproj index 1a2e033c..a444661d 100644 --- a/Aerial.xcodeproj/project.pbxproj +++ b/Aerial.xcodeproj/project.pbxproj @@ -3241,7 +3241,7 @@ CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3.2.7beta10; + CURRENT_PROJECT_VERSION = 3.3.3; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3L54M5L5KK; ENABLE_HARDENED_RUNTIME = YES; @@ -3249,7 +3249,7 @@ INSTALL_PATH = "$(HOME)/Library/Screen Savers"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 3.2.7beta10; + MARKETING_VERSION = 3.3.3; PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3270,7 +3270,7 @@ CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3.2.7beta10; + CURRENT_PROJECT_VERSION = 3.3.3; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3L54M5L5KK; ENABLE_HARDENED_RUNTIME = YES; @@ -3278,7 +3278,7 @@ INSTALL_PATH = "$(HOME)/Library/Screen Savers"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 3.2.7beta10; + MARKETING_VERSION = 3.3.3; OTHER_CODE_SIGN_FLAGS = "--timestamp"; PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Aerial/Source/Models/Sources/Source.swift b/Aerial/Source/Models/Sources/Source.swift index b543a53d..df48399b 100644 --- a/Aerial/Source/Models/Sources/Source.swift +++ b/Aerial/Source/Models/Sources/Source.swift @@ -439,7 +439,7 @@ struct Source: Codable { var processedVideos: [AerialVideo] = [] for asset in videoManifest.assets { - let (isDupe, _) = SourceInfo.findDuplicate(id: asset.id, url1080pH264: asset.url1080H264 ?? "") + let (isDupe, foundVideo) = SourceInfo.findDuplicate(id: asset.id, url1080pH264: asset.url1080H264 ?? "") if !isDupe { let video = AerialVideo(id: asset.id, @@ -454,6 +454,24 @@ struct Source: Codable { communityPoi: PoiStringProvider.sharedInstance.getCommunityPoi(id: asset.id)) processedVideos.append(video) + } else { + // Merge urls with macOS manifest + let assetURLs = urlsFor(asset) + if foundVideo?.urls[.v4KHDR] == "" { + foundVideo?.urls[.v4KHDR] = assetURLs[.v4KHDR] + } + if foundVideo?.urls[.v4KHEVC] == "" { + foundVideo?.urls[.v4KHEVC] = assetURLs[.v4KHEVC] + } + if foundVideo?.urls[.v1080pHDR] == "" { + foundVideo?.urls[.v1080pHDR] = assetURLs[.v1080pHDR] + } + if foundVideo?.urls[.v1080pHEVC] == "" { + foundVideo?.urls[.v1080pHEVC] = assetURLs[.v1080pHEVC] + } + if foundVideo?.urls[.v1080pH264] == "" { + foundVideo?.urls[.v1080pH264] = assetURLs[.v1080pH264] + } } } diff --git a/Aerial/Source/Views/AerialView+Player.swift b/Aerial/Source/Views/AerialView+Player.swift index d616ccb4..40bad567 100644 --- a/Aerial/Source/Views/AerialView+Player.swift +++ b/Aerial/Source/Views/AerialView+Player.swift @@ -69,7 +69,12 @@ extension AerialView { // The layers for descriptions, clock, message - layerManager.setupExtraLayers(layer: layer, frame: self.frame) + // On Sonoma we can't use the reported frame! + if foundFrame != nil { + layerManager.setupExtraLayers(layer: layer, frame: foundFrame!) + } else { + layerManager.setupExtraLayers(layer: layer, frame: self.frame) + } // Make sure we set the retinaness here layerManager.setContentScale(scale: self.window?.backingScaleFactor ?? 1.0) @@ -114,20 +119,24 @@ extension AerialView { // Video fade-in/out func addPlayerFades(view: AerialView, player: AVPlayer, video: AerialVideo) { - // We only fade in/out if we have duration - if video.duration > 0 && AerialView.shouldFade && !shouldLoop { - let playbackSpeed = Double(PlaybackSpeed.forVideo(video.id)) - - view.playerLayer.opacity = 0 - let fadeAnimation = CAKeyframeAnimation(keyPath: "opacity") - fadeAnimation.values = [0, 1, 1, 0] as [Int] - fadeAnimation.keyTimes = [0, - AerialView.fadeDuration/(video.duration/playbackSpeed), - 1-(AerialView.fadeDuration/(video.duration/playbackSpeed)), 1 ] as [NSNumber] - - fadeAnimation.duration = video.duration/playbackSpeed - fadeAnimation.calculationMode = CAAnimationCalculationMode.cubic - view.playerLayer.add(fadeAnimation, forKey: "mainfade") + if !Aerial.helper.underCompanion { + // We only fade in/out if we have duration + if video.duration > 0 && AerialView.shouldFade && !shouldLoop { + let playbackSpeed = Double(PlaybackSpeed.forVideo(video.id)) + + view.playerLayer.opacity = 0 + let fadeAnimation = CAKeyframeAnimation(keyPath: "opacity") + fadeAnimation.values = [0, 1, 1, 0] as [Int] + fadeAnimation.keyTimes = [0, + AerialView.fadeDuration/(video.duration/playbackSpeed), + 1-(AerialView.fadeDuration/(video.duration/playbackSpeed)), 1 ] as [NSNumber] + + fadeAnimation.duration = video.duration/playbackSpeed + fadeAnimation.calculationMode = CAAnimationCalculationMode.cubic + view.playerLayer.add(fadeAnimation, forKey: "mainfade") + } else { + view.playerLayer.opacity = 1.0 + } } else { view.playerLayer.opacity = 1.0 } diff --git a/Aerial/Source/Views/AerialView.swift b/Aerial/Source/Views/AerialView.swift index 76734b72..adce3641 100644 --- a/Aerial/Source/Views/AerialView.swift +++ b/Aerial/Source/Views/AerialView.swift @@ -626,8 +626,10 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate { @objc func onSleepNote(note: Notification) { debugLog("🖼️ 📢📢📢 onSleepNote") - if #available(macOS 14.0, *) { - exit(0) + if !Aerial.helper.underCompanion { + if #available(macOS 14.0, *) { + exit(0) + } } } @@ -889,7 +891,12 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate { let fadeOutAnimation = CAKeyframeAnimation(keyPath: "opacity") fadeOutAnimation.values = [1, 0] as [Int] fadeOutAnimation.keyTimes = [0, AerialView.fadeDuration] as [NSNumber] - fadeOutAnimation.duration = AerialView.fadeDuration + if !Aerial.helper.underCompanion { + fadeOutAnimation.duration = AerialView.fadeDuration + } else { + fadeOutAnimation.values = [1, 1] as [Int] + fadeOutAnimation.duration = 0.1 + } fadeOutAnimation.delegate = self fadeOutAnimation.isRemovedOnCompletion = false fadeOutAnimation.calculationMode = CAAnimationCalculationMode.cubic diff --git a/Resources/MainUI/Settings panels/CompanionCacheViewController.xib b/Resources/MainUI/Settings panels/CompanionCacheViewController.xib index 94f5bf48..3948ef3f 100644 --- a/Resources/MainUI/Settings panels/CompanionCacheViewController.xib +++ b/Resources/MainUI/Settings panels/CompanionCacheViewController.xib @@ -1,8 +1,8 @@ - + - + diff --git a/Resources/MainUI/Settings panels/TimeViewController.xib b/Resources/MainUI/Settings panels/TimeViewController.xib index 99e43203..cef646b0 100644 --- a/Resources/MainUI/Settings panels/TimeViewController.xib +++ b/Resources/MainUI/Settings panels/TimeViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -122,8 +122,8 @@ - - + +