Create, program, and listen to your own internet radio station.
pod install 'playolaCore', '~>0.0.5'
import PlayolaCore
function playStation() {
let player = PlayolaStationPlayer().sharedInstance()
player.loadUserAndPlay(userID: "59508b2eac42570400cdb67d")
.done { (void) -> Void in
print("starting!")
}.catch { (error) -> Void in
print("there was an error starting your station.")
print(error)
}
}
player.stop() // stops a station
Playola events are stored as static properties on the class PlayolaStationPlayerEvents. Listening and responding to events is easy:
NotificationCenter.default.addObserver(forName: PlayolaStationPlayerEvents.loadingStationProgress, object: nil, queue: .main) {
(notification) -> Void in
if let userInfo = notification.userInfo {
if let downloadProgress = userInfo["downloadProgress"] as? Double {
print("\(downloadProgress * 100)% complete")
}
}
}
Available events are:
.startedPlayingStation
.stoppedPlayingStation
.startedLoadingStation
.loadingStationProgress
.finishedLoadingStation
.nowPlayingChanged
See the example app at https://github.com/briankeane/PlayolaCoreExample.git