The easiest way is through CocoaPods. Simply add the dependency to your Podfile
and then pod install
:
pod 'Clappr', '~> 0.7.1'
let options = [kSourceUrl : "http://clappr.io/highline.mp4"]
let player = Player(options: options)
player.attachTo(yourView, controller: self)
The player throw's a list of events that can be useful to your application.
You can add options to the player. Here you can see the list of available options and how to use it.
To enable external playback while your app is in background, you should include the audio
value to your app's Background Modes capabilities.
Add the key UIBackgroundModes
. Just after adding it to your Info.plist file, Xcode will translate to a more readable value Required background modes
, which represents an array of values. Then, add a new item with value audio
, which will be translated to App plays audio or streams audio/video using Airplay
.
Click on the target that represents your app. Open the Capabilities tab, and there, you'll see the list of available capabilities. One of them is the Background Modes
. Change its toggle to on
and mark the Audio, Airplay, and Picture in Picture
checkbox.
You can find it here.