Clappr for iOS and tvOS
Clappr is an extensible media player for iOS and tvOS.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate Clappr into your Xcode project using CocoaPods, specify it to a target in your
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! target '<Your Target Name>' do pod 'Clappr', '~> 0.9.0' end
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update $ brew install carthage
To integrate Clappr into your Xcode project using Carthage, specify it in your
github "clappr/clappr-ios" ~> 0.9.0
carthage update to build the framework and drag the built
Clappr.framework into your Xcode project.
let options = [kSourceUrl : "http://clappr.io/highline.mp4"] let player = Player(options: options)
Add it in your view
player.attachTo(yourView, controller: self)
let options = [kSourceUrl : "https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8"] let player = Player(options: options)
Add to your controller
addChildViewController(player) player.view.frame = view.bounds view.addSubview(player.view) player.didMove(toParentViewController: self)
The default configuration assumes fullscreen in tvOS, ensure that the corresponding attached view fills all the window area.
Player also supports embedded mode. For this you'll have to disable MediaControl through options:
You can read more about options here.
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.
External Playback in Background
To enable external playback while your app is in background, you should include the
audio value to your app's Background Modes capabilities.
Manually editing Info.plist
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.