• This repository has been archived on 16/Jan/2023
  • Stars
    star
    119
  • Rank 287,362 (Top 6 %)
  • Language
    Swift
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An extensible media player for iOS [deprecated]

DEPRECATED

⛔️ This project is no longer supported.

Clappr for iOS and tvOS

image

Clappr is an extensible media player for iOS and tvOS.

Installation

CocoaPods

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 Podfile:

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

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 Cartfile:

github "clappr/clappr-ios"  ~> 0.9.0

Run carthage update to build the framework and drag the built Clappr.framework into your Xcode project.

Usage

iOS

Create

let options = [kSourceUrl : "http://clappr.io/highline.mp4"]
let player = Player(options: options)

Add it in your view

player.attachTo(yourView, controller: self)

Media Control

It's a built-in plugin (i.e..: it can be replaced by your own plugin) that can display media control components, eg.: play/pause button, seekbar, video information such as title and/or description, etc.

Under the hood is a set of stack views divided into panels and position, that can be used to organize the components on the screen.

  • Panels: defines in which part of the screen the plugin will be rendered. The options are top, center, bottom and modal.

  • Position: defines in which part of the panel the plugin will be rendered. The options are left, center, right and none.

Clappr comes with four default components: play/pause button, seekbar, fullscreen button, and time indicator. With them, the user can fully interact with the playback. You can customize it with your own elements, see below:

Media Control Elements

You can add your own components into the MediaControl by creating your own Media Control Element.

To do so, you must:

  • Inherit from MediaControl.Element;
  • Define in which panel and position the element will be rendered;
  • Have a unique name;

If you provide the same name that an existing plugin (built-in), the plugin will override the existent plugin.

You can see some examples:

tvOS

Create

let options = [kSourceUrl : "https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8"]
let player = Player(options: options)

Register Custom Plugins

In order to register a custom plugin is necessary to pass the plugin type to Player before initialize it, using the static method register as the example below:

let plugins = [PluginExemplo.self]
WMPlayer.register(plugins: plugins)

var player = WMPlayer(options: options)

player.attachTo(playerContainer, controller: self)

The Player does not support adding or removing plugins at runtime so it is necessary register the plugins before its initialization. In case player be destroyed and recreated, all plugins registered will be reused, like the example below:

let firstTimePlugins = [PluginExemploA.self]
WMPlayer.register(plugins: firstTimePlugins)

var player = WMPlayer(options: options)

let secondTimePlugins = [PluginExemploB.self]
WMPlayer.register(plugins: secondTimePlugins)

// PluginExemploB will not be used in this instance of Player
player.attachTo(playerContainer, controller: self) 

player.destroy()

// PluginExemploA and PluginExemploB will be used in this instance of Player
player = WMPlayer(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:

kMediaControl: false

You can read more about options here.

Playback State

You can check the playback state by using the state property of Player and Playback. The states are:

@objc public enum PlaybackState: Int {
    case none = 0
    case idle = 1
    case playing = 2
    case paused = 3
    case stalling = 4
    case error = 5
}

Events

The player throw's a list of events that can be useful to your application.

Options

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.

Capabilities Tab

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.

License

You can find it here.

Sponsor

image

More Repositories

1

clappr

🎬 An extensible media player for the web.
JavaScript
6,919
star
2

clappr-level-selector-plugin

Clappr Level Selector Plugin
JavaScript
74
star
3

dash-shaka-playback

A dash playback (based on shaka-player) for 🎬 Clappr
JavaScript
72
star
4

clappr-android

An extensible media player for Android.
Kotlin
67
star
5

clappr-core

Core components of the Clappr player architecture
JavaScript
59
star
6

clappr-stats

A clappr plugin to report playback statuses (timers: session, buffering, watch and counters: play, pause, error, fps)
JavaScript
41
star
7

clappr-chromecast-plugin

Chromecast support for clappr
JavaScript
37
star
8

clappr-plugins

Main plugins for the Clappr project
JavaScript
31
star
9

hlsjs-playback

Clappr HLS Playback based on hls.js
JavaScript
29
star
10

generator-clappr-plugin

Generator that scaffolds out a clappr plugin
JavaScript
19
star
11

clappr-html5-tvs-playback

A Clappr HTML5 playback for smart TVs based on HbbTV 2.0.1 specs
JavaScript
10
star
12

clappr-speech-control-plugin

Control Clappr player with your voice
JavaScript
9
star
13

clappr-docs

Clappr general implementation documentation
JavaScript
7
star
14

website

Clappr Website
HTML
6
star
15

watermark

πŸ’¦ Watermark plugin for Clappr
JavaScript
4
star
16

clappr-pip

Clappr plugin for adding OS-based picture-in-picture support.
JavaScript
3
star
17

clappr-playback-name-plugin

A simple plugin for Clappr that adds a label with the playback's name
JavaScript
3
star
18

clappr-samples

A collection of samples and examples on how to work with Clappr.
HTML
2
star
19

flash-playback

Clappr basic Flash playback
JavaScript
2
star
20

clappr.github.io

Clappr's official documentation
HTML
2
star
21

retry-utils

Plug and play lib that implements a retry mechanism using exponential backoff pattern.
JavaScript
2
star
22

flashls-playback

[WIP] Clappr Flashls based playback
JavaScript
1
star
23

clappr-ima-parser

A Clappr plugin to communicate with IMA and play ads
JavaScript
1
star
24

clappr-zepto

JavaScript
1
star