Jukebox is an iOS audio player written in Swift.
- Features
- Installation
- Supported OS & SDK versions
- Usage
- Handling remote events
- [Delegation] (#delegation)
- License
- Contact
## Features
- Support for streaming both remote and local audio files
- Support for streaming live audio feeds
- Functions to
play,pause,stop,replay,play next,play previous,control volumeandseekto a certain second. - Background mode integration with
MPNowPlayingInfoCenter
CocoaPods is a dependency manager for Cocoa projects.
CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:
$ gem install cocoapods
To integrate Jukebox into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Jukebox', '~> 0.1.5'
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate Jukebox into your Xcode project using Carthage, specify it in your Cartfile:
github "teodorpatras/Jukebox"
Run carthage update to build the framework and drag the built Jukebox.framework into your Xcode project.
If you prefer not to use either of the aforementioned dependency managers, you can integrate EasyTipView into your project manually.
## Supported OS & SDK versions
- iOS 8.0+
- Xcode 7+
## Usage
- In order to support background mode, append the following to your
Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
- If you want to stream from
http://URLs, append the following to yourInfo.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- 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")!)
])
- Play and enjoy:
jukebox?.play()
In order to handle remote events, you should do the following:
- First, you need to call for receiving remote events:
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
- Secondly, override
remoteControlReceivedWithEvent(event:):
override func remoteControlReceivedWithEvent(event: UIEvent?) {
if event?.type == .RemoteControl {
switch event!.subtype {
case .RemoteControlPlay :
jukebox.play()
case .RemoteControlPause :
jukebox.pause()
case .RemoteControlNextTrack :
jukebox.playNext()
case .RemoteControlPreviousTrack:
jukebox.playPrevious()
case .RemoteControlTogglePlayPause:
if jukebox.state == .Playing {
jukebox.pause()
} else {
jukebox.play()
}
default:
break
}
}
}
## Delegation
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)
}
## License
Jukebox is released under the MIT license. See the LICENSE file for details.
## Contact
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.
