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.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- 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
- macOS 10.12+
- iOS 13.5+
- tvOS 10.0+
- Xcode 13+
- Swift 5
We currently suggest you use Swift Pacjage Manager to install ACRadioPlayer. We are currently working on getting the other installation options working.
ACRadioPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ACRadioPlayer'
ACRadioPlayer is available through Carthage. To install it, simply add the following line to your Cartfile:
github "joemcmahon/ACRadioPlayer" ~> 0.1.10
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")
Drag the Source
folder into your project.
- Import
ACRadioPlayer
(if you are using Cocoapods)
import ACRadioPlayer
- Get the singleton
ACRadioPlayer
instance
let player = ACRadioPlayer.shared
- Set the delegate for the player
player.delegate = self
- Set the radio URL
player.radioURL = URL(string: "http://example.com/station.mp3")
-
isAutoPlay: Bool
The player starts playing when theradioURL
property gets set. (default ==true
) -
rate: Float?
Read only property to get the currentAVPlayer
rate. -
isPlaying: Bool
Read only property to check if the player is playing. -
state: ACRadioPlayerState
Player current state of typeACRadioPlayerState
. -
playbackState: ACRadioPlaybackState
Playing state of typeACRadioPlaybackState
.
- Play
player.play()
- Pause
player.pause()
- Stop
player.stop()
- Toggle playing state
player.togglePlaying()
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.
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.
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
Joe McMahon, based on work by Fethi El Hassasna
ACRadioPlayer is available under the MIT license. See the LICENSE file for more info.