From b259f8856051c9edf932d529780302498e0812e1 Mon Sep 17 00:00:00 2001 From: Musa Date: Mon, 13 Mar 2017 12:18:18 +0300 Subject: [PATCH] fix start delay issue --- Source/Jukebox.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Source/Jukebox.swift b/Source/Jukebox.swift index b7d0200..4df8d1c 100644 --- a/Source/Jukebox.swift +++ b/Source/Jukebox.swift @@ -139,7 +139,11 @@ extension Jukebox { player.seek(to: CMTimeMake(Int64(second), 1)) item.update() if shouldPlay { - player.play() + if #available(iOS 10.0, *) { + player?.playImmediately(atRate: 1.0) + } else { + player?.play() + } if state != .playing { state = .playing } @@ -354,7 +358,11 @@ open class Jukebox: NSObject, JukeboxItemDelegate { if state != .playing { startProgressTimer() if let player = player { - player.play() + if #available(iOS 10.0, *) { + player?.playImmediately(atRate: 1.0) + } else { + player?.play() + } } else { currentItem!.refreshPlayerItem(withAsset: currentItem!.playerItem!.asset) startNewPlayer(forItem: currentItem!.playerItem!) @@ -473,7 +481,11 @@ open class Jukebox: NSObject, JukeboxItemDelegate { func handleStall() { player?.pause() - player?.play() + if #available(iOS 10.0, *) { + player?.playImmediately(atRate: 1.0) + } else { + player?.play() + } } func playerItemDidPlayToEnd(_ notification : Notification){