mirror of
				https://github.com/yattee/yattee.git
				synced 2025-11-03 22:22:02 +00:00 
			
		
		
		
	Improve PiP close animation
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
import AVKit
 | 
			
		||||
import Foundation
 | 
			
		||||
import SwiftUI
 | 
			
		||||
 | 
			
		||||
final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
 | 
			
		||||
    var player: PlayerModel!
 | 
			
		||||
@@ -45,16 +46,23 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
 | 
			
		||||
    ) {
 | 
			
		||||
        var delay = 0.0
 | 
			
		||||
        #if os(iOS)
 | 
			
		||||
            if player.currentItem.isNil {
 | 
			
		||||
            if !player.presentingPlayer {
 | 
			
		||||
                delay = 0.5
 | 
			
		||||
            }
 | 
			
		||||
            if player.currentItem.isNil {
 | 
			
		||||
                delay = 1
 | 
			
		||||
            }
 | 
			
		||||
        #endif
 | 
			
		||||
 | 
			
		||||
        if !player.currentItem.isNil, !player.musicMode {
 | 
			
		||||
            player?.show()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
 | 
			
		||||
        DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
 | 
			
		||||
            withAnimation(.linear(duration: 0.3)) {
 | 
			
		||||
                self?.player.playingInPictureInPicture = false
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            completionHandler(true)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user