ColiseuPlayer is an audio player framework written in Swift, created for Coliseu app. It uses AVFoundation.
import AVFoundation
import ColiseuPlayer
class ViewController: UIViewController, ColiseuPlayerDataSource, ColiseuPlayerDelegate {
let player = ColiseuPlayer()
override func viewDidLoad() {
super.viewDidLoad()
self.player.startSession()
self.player.dataSource = self
var list = [AudioFile]()
if let path = Bundle.main.path(forResource: "sampleAudio", ofType: "m4a") {
let urlFile = URL(fileURLWithPath: path)
let audio = AudioFile(url: urlFile)
audio.artwork = UIImage(named: "image-cover-artwork")
list.append(audio)
}
if list.count > 0 {
// Play first song (it will continue playing with the current playlist)
player.playSong(index: 0, songsList: list)
}
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
self.player.stopSession()
}
override func remoteControlReceived(with event: UIEvent?) {
self.player.didReceiveRemoteControl(event: event)
}
func audioRepeatType(in player: ColiseuPlayer) -> ColiseuPlayerRepeat {
return .all
}
func audioWillShuffle(in player: ColiseuPlayer) -> Bool {
return true
}
}
To install it, simply add the following line to your Cartfile:
github "ricardopereira/ColiseuPlayer"
Then run carthage update
.
Follow the current instructions in Carthage's README for up to date installation instructions.
To install it, simply add the following line to your Podfile:
pod 'ColiseuPlayer'
You will also need to make sure you're opting into using frameworks:
use_frameworks!
Then run pod install
with CocoaPods 1.7.0 or newer.
ColiseuPlayer in your project requires the following steps:_
cd
-ing into your top-level project directory, and entering the command git submodule add https://github.com/ricardopereira/coliseu.ios.player.git
ColiseuPlayer
folder, and drag ColiseuPlayer.xcodeproj
into the file navigator of your app project.ColiseuPlayer.framework
.+
button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add ColiseuPlayer.framework
.ColiseuPlayer is released under the MIT license. See LICENSE for details.