Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
Igor Oliveira edited this page May 29, 2017 · 5 revisions

Build Status

Clappr for iOS

image

Installation

The easiest way is through CocoaPods. Simply add the dependency to your Podfile and then pod install:

pod 'Clappr', '~> 0.4'

Using the Player

Create
let options = [kSourceUrl : "http://clappr.io/highline.mp4"]
let player = Player(options: options)
Add it in your view
player.attachTo(yourView, controller: self)
Listen to Events
player.on(Event.playing) { userInfo in
    print("on Play")
}

You can find public events on Events enum and listed bellow:

  • bufferUpdate
  • positionUpdate
  • ready
  • stalled
  • willUpdateAudioSource
  • didUpdateAudioSource
  • willUpdateSubtitleSource
  • didUpdateSubtitleSource
  • disableMediaControl
  • enableMediaControl
  • didComplete
  • willPlay
  • playing
  • willPause
  • didPause
  • willStop
  • didStop
  • airPlayStatusUpdate
  • requestFullscreen
  • exitFullscreen
  • error: userInfo can contain the error that caused the event.

Built-in Plugins

To add plugins parameters use the options parameter on constructor. Example:

let options = [kSourceUrl : "http://clappr.io/highline.mp4", pluginParameter1: "value1", pluginParameter2: true]
let player = Player(options: options)
Source

Set the video source url with kSourceUrl : "http://clappr.io/highline.mp4".

Poster

Define a poster by adding kPosterUrl: "http://url/img.png" on your options. It will appear before the video starts, disappear on play and go back when video finishes.

Playback not supported custom message

Add kPlaybackNotSupportedMessage : 'Your custom message' to define a custom message to be displayed for not supported videos.

AutoPlay

Add kAutoPlay: true if you want the video to play automatically.

Start At

Define a start position in seconds with kStartAt : x. Default is 0.

Fullscreen

Define if video should start in fullscreen mode with kFullscreen: true. Default is false.

FullscreenDisabled

Add kFullscreenDisabled: true to disable fullscreen button. Default is false.

MimeType

Add kMimeType: 'selected mimetype' if you need to use a url without extension.

Media Control

Adding a custom media control is possible by informing the Type of your class via kMediaControl : YourCustomControl.self

License

You can find it here.

Sponsor

image

Clone this wiki locally