From 7cb1838cc7d67a51e67fe0ad09ea69796c030d00 Mon Sep 17 00:00:00 2001 From: kingslay Date: Thu, 21 Dec 2023 23:47:55 +0800 Subject: [PATCH] add seekable --- Sources/KSPlayer/AVPlayer/KSPlayerLayer.swift | 2 +- Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Sources/KSPlayer/AVPlayer/KSPlayerLayer.swift b/Sources/KSPlayer/AVPlayer/KSPlayerLayer.swift index 6f0a01c0b..987925001 100644 --- a/Sources/KSPlayer/AVPlayer/KSPlayerLayer.swift +++ b/Sources/KSPlayer/AVPlayer/KSPlayerLayer.swift @@ -298,7 +298,7 @@ open class KSPlayerLayer: UIView { if time.isInfinite || time.isNaN { completion(false) } - if player.isReadyToPlay { + if player.isReadyToPlay, player.seekable { player.seek(time: time) { [weak self] finished in guard let self else { return } if finished, autoPlay { diff --git a/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift b/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift index 3858f173b..7ac4c5622 100644 --- a/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift +++ b/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift @@ -18,8 +18,6 @@ public struct KSVideoPlayerView: View { private var playerCoordinator = KSVideoPlayer.Coordinator() @Environment(\.dismiss) private var dismiss - @FocusState - private var controllerFocused: Bool public let options: KSOptions @State public var url: URL { @@ -160,9 +158,7 @@ public struct KSVideoPlayerView: View { } } .onExitCommand { - if controllerFocused { - controllerFocused = false - } else if playerCoordinator.isMaskShow { + if playerCoordinator.isMaskShow { playerCoordinator.isMaskShow = false } else { dismiss()