Merge pull request #79 from nicolassrod/master
FRadioPlayer is a wrapper around AVPlayer to handle internet radio playback.
To run the example project, clone the repo, and run pod install from the Example directory first.
pod install
FRadioPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'FRadioPlayer'
FRadioPlayer is available through Carthage. To install it, simply add the following line to your Cartfile:
github "fethica/FRadioPlayer" ~> 0.1.10
FRadioPlayer is available through SPM. To install it, simply add the following dependency to your Package.swift file:
Package.swift
.package(url: "https://github.com/fethica/FRadioPlayer.git", from: "0.1.18")
Drag the Source folder into your project.
Source
FRadioPlayer
import FRadioPlayer
let player = FRadioPlayer.shared
player.delegate = self
player.radioURL = URL(string: "http://example.com/station.mp3")
isAutoPlay: Bool The player starts playing when the radioURL property gets set. (default == true)
isAutoPlay: Bool
radioURL
true
enableArtwork: Bool Enable fetching albums artwork from the iTunes API. (default == true)
enableArtwork: Bool
artworkSize: Int Artwork image size. (default == 100 | 100x100).
artworkSize: Int
100
rate: Float? Read only property to get the current AVPlayer rate.
rate: Float?
AVPlayer
isPlaying: Bool Read only property to check if the player is playing.
isPlaying: Bool
state: FRadioPlayerState Player current state of type FRadioPlayerState.
state: FRadioPlayerState
FRadioPlayerState
playbackState: FRadioPlaybackState Playing state of type FRadioPlaybackState.
playbackState: FRadioPlaybackState
FRadioPlaybackState
Play
player.play()
Pause
player.pause()
Stop
player.stop()
Toggle playing state
player.togglePlaying()
Called when player changes state
func radioPlayer(_ player: FRadioPlayer, playerStateDidChange state: FRadioPlayerState)
Called when the playback changes state
func radioPlayer(_ player: FRadioPlayer, playbackStateDidChange state: FRadioPlaybackState)
Called when player changes the current player item
func radioPlayer(_ player: FRadioPlayer, itemDidChange url: URL?)
Called when player item changes the timed metadata value
func radioPlayer(_ player: FRadioPlayer, metadataDidChange artistName: String?, trackName: String?)
func radioPlayer(_ player: FRadioPlayer, metadataDidChange rawValue: String?)
Called when the player gets the artwork for the playing song
func radioPlayer(_ player: FRadioPlayer, artworkDidChange artworkURL: URL?)
For more complete app features, check out Swift Radio App based on FRadioPlayer
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.
project.yml
$ mint run yonaskolb/xcodegen 💾 Saved project to FRadioPlayer.xcodeproj
Fethi El Hassasna
FRadioPlayer is available under the MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
FRadioPlayer
FRadioPlayer is a wrapper around AVPlayer to handle internet radio playback.
Example
To run the example project, clone the repo, and run
pod install
from the Example directory first.Features
Requirements
Installation
CocoaPods
FRadioPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:
Carthage
FRadioPlayer is available through Carthage. To install it, simply add the following line to your Cartfile:
Swift Package Manager
FRadioPlayer is available through SPM. To install it, simply add the following dependency to your
Package.swift
file:Manual
Drag the
Source
folder into your project.Usage
Basics
FRadioPlayer
(if you are using Cocoapods)FRadioPlayer
instanceProperties
isAutoPlay: Bool
The player starts playing when theradioURL
property gets set. (default ==true
)enableArtwork: Bool
Enable fetching albums artwork from the iTunes API. (default ==true
)artworkSize: Int
Artwork image size. (default ==100
| 100x100).rate: Float?
Read only property to get the currentAVPlayer
rate.isPlaying: Bool
Read only property to check if the player is playing.state: FRadioPlayerState
Player current state of typeFRadioPlayerState
.playbackState: FRadioPlaybackState
Playing state of typeFRadioPlaybackState
.Playback controls
Play
Pause
Stop
Toggle playing state
Delegate methods
Called when player changes state
Called when the playback changes state
Called when player changes the current player item
Called when player item changes the timed metadata value
Called when player item changes the timed metadata value
Called when the player gets the artwork for the playing song
Swift Radio App
For more complete app features, check out Swift Radio App based on FRadioPlayer
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.Author
Fethi El Hassasna
License
FRadioPlayer is available under the MIT license. See the LICENSE file for more info.