briankeane / PlayolaCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MacDown logo

Create, program, and listen to your own internet radio station.

Installation

Via Cocoapods:

pod install 'playolaCore', '~>0.0.5'

Usage

Player:

Play a user's station:
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)
      } 
}

Other commands:

	player.stop()      // stops a station

Events:

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

Example App:

See the example app at https://github.com/briankeane/PlayolaCoreExample.git

About

License:Other


Languages

Language:Swift 56.8%Language:Objective-C 41.6%Language:C++ 0.8%Language:C 0.5%Language:Ruby 0.3%