CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

ACRadioPlayer 0.3.0

ACRadioPlayer 0.3.0

Maintained by Joe McMahon.



 
Depends on:
ACWebSocketClient~> 0.1.9
Kingfisher~> 8.0
 


ACRadioPlayer

ACRadioPlayer

CI Status CI Status Version License Platform

ACRadioPlayer is an extended version of FRadioPlayer. It too provides a wrapper around AVPlayer to handle internet radio playback, but adds support for radio stations hosted on Azuracast.

Specifically, it uses Azuracast's websocket SSE high-frequency updates to provide more metadata than FRadioPlayer could:

  • Artwork comes directly from your Azuracast server, and does not require iTunes or Spotify.
  • Album name is available in addition to the artist and track.
  • Track time and elapsed time provided if available.
  • Track history (album, title, artist, and artwork) are available (if configured on the Azuracast server).

Please note that the project is currently still in flux, and some features are still being implemented/altered.

The sample projects are in the process of being updated to use the new library. The current version of the library is simply a renamed version of FRadioPlayer, tweaked so that the library name is different and all current code works.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

ACRadioPlayer

Features

  • Support internet radio URL playback
  • Real-time push updates of metadata
  • Update and show album artwork (extracted by Azuracast from track metadata)
  • Automatic handling of interruptions
  • Automatic handling of route changes
  • Support bluetooth playback
  • Swift 5
  • Full documentation (NOTE: still in process; updates required for new APIs)
  • Network interruptions handling
  • Support for Carthage
  • Support for macOS
  • Support for tvOS
  • Support for Swift Package Manager SPM
  • Support for Audio Taps
  • Support for Audio Recording

Requirements

  • macOS 10.12+
  • iOS 13.5+
  • tvOS 10.0+
  • Xcode 13+
  • Swift 5

Installation

We currently suggest you use Swift Pacjage Manager to install ACRadioPlayer. We are currently working on getting the other installation options working.

CocoaPods

ACRadioPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ACRadioPlayer'

Carthage

ACRadioPlayer is available through Carthage. To install it, simply add the following line to your Cartfile:

github "joemcmahon/ACRadioPlayer" ~> 0.1.10

Swift Package Manager

ACRadioPlayer is available through SPM. To install it, simply add the following dependency to your Package.swift file:

.package(url: "https://github.com/joemcmahon/ACRadioPlayer.git", from: "0.1.18")

Manual

Drag the Source folder into your project.

Usage

Basics

  1. Import ACRadioPlayer (if you are using Cocoapods)
import ACRadioPlayer
  1. Get the singleton ACRadioPlayer instance
let player = ACRadioPlayer.shared
  1. Set the delegate for the player
player.delegate = self
  1. Set the radio URL
player.radioURL = URL(string: "http://example.com/station.mp3")

Properties

  • isAutoPlay: Bool The player starts playing when the radioURL property gets set. (default == true)

  • rate: Float? Read only property to get the current AVPlayer rate.

  • isPlaying: Bool Read only property to check if the player is playing.

  • state: ACRadioPlayerState Player current state of type ACRadioPlayerState.

  • playbackState: ACRadioPlaybackState Playing state of type ACRadioPlaybackState.

Playback controls

  • Play
player.play()
  • Pause
player.pause()
  • Stop
player.stop()
  • Toggle playing state
player.togglePlaying()

Delegate methods

Called when player changes state

func radioPlayer(_ player: ACRadioPlayer, playerStateDidChange state: ACRadioPlayerState)

Called when the playback changes state

func radioPlayer(_ player: ACRadioPlayer, playbackStateDidChange state: ACRadioPlaybackState)

Called when player changes the current player item

func radioPlayer(_ player: ACRadioPlayer, itemDidChange url: URL?)

Called when player item changes the timed metadata value

func radioPlayer(_ player: ACRadioPlayer, metadataDidChange artistName: String?, trackName: String?)

Note: this API is currently being updated to handle the more complex metadata available from Azuracast.

Apps using this library

For more complete app features, check out RadioSpiral based on ACRadioPlayer. Currently under development; will be updated to use more Azuracast features as ACRadioPlayer makes them available.

RadioSpiral demo screens

Hacking

The Xcode project is generated automatically from project.yml using XcodeGen. It's only checked in because Carthage needs it, do not edit it manually.

$ mint run yonaskolb/xcodegen
💾  Saved project to ACRadioPlayer.xcodeproj

Author

Joe McMahon, based on work by Fethi El Hassasna

License

ACRadioPlayer is available under the MIT license. See the LICENSE file for more info.