mirror of
https://github.com/yattee/yattee.git
synced 2024-12-24 22:43:41 +00:00
Prevent multiple seeks
This commit is contained in:
parent
2491706ba2
commit
9a91b9911b
@ -15,6 +15,8 @@ final class MPVClient: ObservableObject {
|
|||||||
var glView: MPVOGLView!
|
var glView: MPVOGLView!
|
||||||
var backend: MPVBackend!
|
var backend: MPVBackend!
|
||||||
|
|
||||||
|
var seeking = false
|
||||||
|
|
||||||
func create(frame: CGRect) -> MPVOGLView {
|
func create(frame: CGRect) -> MPVOGLView {
|
||||||
glView = MPVOGLView(frame: frame)
|
glView = MPVOGLView(frame: frame)
|
||||||
|
|
||||||
@ -121,13 +123,27 @@ final class MPVClient: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func seek(relative time: CMTime, completionHandler: ((Bool) -> Void)? = nil) {
|
func seek(relative time: CMTime, completionHandler: ((Bool) -> Void)? = nil) {
|
||||||
command("seek", args: [String(time.seconds)]) { _ in
|
guard !seeking else {
|
||||||
|
logger.warning("ignoring seek, another in progress")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
seeking = true
|
||||||
|
command("seek", args: [String(time.seconds)]) { [weak self] _ in
|
||||||
|
self?.seeking = false
|
||||||
completionHandler?(true)
|
completionHandler?(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func seek(to time: CMTime, completionHandler: ((Bool) -> Void)? = nil) {
|
func seek(to time: CMTime, completionHandler: ((Bool) -> Void)? = nil) {
|
||||||
command("seek", args: [String(time.seconds), "absolute"]) { _ in
|
guard !seeking else {
|
||||||
|
logger.warning("ignoring seek, another in progress")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
seeking = true
|
||||||
|
command("seek", args: [String(time.seconds), "absolute"]) { [weak self] _ in
|
||||||
|
self?.seeking = false
|
||||||
completionHandler?(true)
|
completionHandler?(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ struct PlayerControls: View {
|
|||||||
static let animation = Animation.easeInOut(duration: 0)
|
static let animation = Animation.easeInOut(duration: 0)
|
||||||
|
|
||||||
private var player: PlayerModel!
|
private var player: PlayerModel!
|
||||||
|
|
||||||
@EnvironmentObject<PlayerControlsModel> private var model
|
@EnvironmentObject<PlayerControlsModel> private var model
|
||||||
|
|
||||||
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
||||||
|
Loading…
Reference in New Issue
Block a user