From 67157c9d5edac43a7e6a5faad322e38cb8912ae5 Mon Sep 17 00:00:00 2001 From: Joel Bell Date: Mon, 13 Mar 2017 21:43:18 -0700 Subject: [PATCH] Adding Autoplay Switch: Issue #65 --- Source/Jukebox.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Jukebox.swift b/Source/Jukebox.swift index b7d0200..e2c66a1 100644 --- a/Source/Jukebox.swift +++ b/Source/Jukebox.swift @@ -218,6 +218,7 @@ open class Jukebox: NSObject, JukeboxItemDelegate { } // MARK:- Properties - + public var autoplay = true fileprivate var player : AVPlayer? fileprivate var progressObserver : AnyObject! @@ -477,7 +478,7 @@ open class Jukebox: NSObject, JukeboxItemDelegate { } func playerItemDidPlayToEnd(_ notification : Notification){ - if playIndex >= queuedItems.count - 1 { + if playIndex >= queuedItems.count - 1 || !autoplay { stop() } else { play(atIndex: playIndex + 1)