Jukebox 0.2.1

Jukebox 0.2.1

LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2016
SPMSupports SPM

Maintained by Teodor Patraș.

Jukebox 0.2.1

Jukebox: audio player in Swift

Jukebox is an iOS audio player written in Swift.


  1. Features
  2. Installation
  3. Supported OS & SDK versions
  4. Usage
  5. Handling remote events
  6. Public interface
  7. Delegation
  8. License
  9. Contact


  • [x] Support for streaming both remote and local audio files
  • [x] Support for streaming live audio feeds
  • [x] Functions to play, pause, stop, replay, play next, play previous, control volume and seek to a certain second.
  • [x] Background mode integration with MPNowPlayingInfoCenter



If you prefer not to use either of the aforementioned dependency managers, you can integrate Jukebox into your project manually.

Supported OS & SDK versions

  • iOS 8.0+
  • Xcode 7+



  • In order to support background mode, append the following to your Info.plist:
  • If you want to stream from http:// URLs, append the following to your Info.plist:

Getting started

1) Create an instance of Jukebox:

// configure jukebox
jukebox = Jukebox(delegate: self, items: [
    JukeboxItem(URL: NSURL(string: "http://www.noiseaddicts.com/samples_1w72b820/2514.mp3")!),
    JukeboxItem(URL: NSURL(string: "http://www.noiseaddicts.com/samples_1w72b820/2958.mp3")!)

2) Play and enjoy:


Handling remote events

In order to handle remote events, you should do the following:

  • First, you need to call for receiving remote events:


  • Secondly, override remoteControlReceivedWithEvent(event:):
override func remoteControlReceived(with event: UIEvent?) {
    if event?.type == .remoteControl {
        switch event!.subtype {
        case .remoteControlPlay :
        case .remoteControlPause :
        case .remoteControlNextTrack :
        case .remoteControlPreviousTrack:
        case .remoteControlTogglePlayPause:
            if jukebox.state == .playing {
            } else {

Public interface

Public methods

 Starts item playback.
public func play()

Plays the item indicated by the passed index

 - parameter index: index of the item to be played
public func play(atIndex index: Int)

 Pauses the playback.
public func pause()

 Stops the playback.
public func stop()

 Starts playback from the beginning of the queue.
public func replay()

 Plays the next item in the queue.
public func playNext()

 Restarts the current item or plays the previous item in the queue
public func playPrevious()

 Restarts the playback for the current item
public func replayCurrentItem()

 Seeks to a certain second within the current AVPlayerItem and starts playing

 - parameter second: the second to seek to
 - parameter shouldPlay: pass true if playback should be resumed after seeking
public func seek(toSecond second: Int, shouldPlay: Bool = false)

 Appends and optionally loads an item

 - parameter item:            the item to be appended to the play queue
 - parameter loadingAssets:   pass true to load item's assets asynchronously
public func append(item: JukeboxItem, loadingAssets: Bool)

 Removes an item from the play queue

 - parameter item: item to be removed
public func remove(item: JukeboxItem)

 Removes all items from the play queue matching the URL

 - parameter url: the item URL
public func removeItems(withURL url : URL)

Public properties

Property Type Description
volume Float volume of the player
currentItem JukeboxItem object encapsulating the meta of the current player item


Jukebox defines a delegate protocol which you can use if you want to be announced when about custom events:

public protocol JukeboxDelegate: class {
    func jukeboxStateDidChange(_ state : Jukebox)
    func jukeboxPlaybackProgressDidChange(_ jukebox : Jukebox)
    func jukeboxDidLoadItem(_ jukebox : Jukebox, item : JukeboxItem)
    func jukeboxDidUpdateMetadata(_ jukebox : Jukebox, forItem: JukeboxItem)


Jukebox is released under the MIT license. See the LICENSE file for details.


You can follow or drop me a line on my Twitter account. If you find any issues on the project, you can open a ticket. Pull requests are also welcome.