RocketChat/RCiOSMobilePlayer

Name: RCiOSMobilePlayer

Owner: Rocket.Chat

Description: :iphone: :movie_camera: A powerful and completely customizable media player for iOS

Created: 2018-04-26 11:55:07.0

Updated: 2018-04-26 11:55:44.0

Pushed: 2018-04-23 16:01:56.0

Homepage: http://mobileplayer.io

Size: 62436

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

logo

MobilePlayer CocoaPods

codebeat badge CocoaPods Carthage compatible Dependencies Ready [StackOverflow](http://stackoverflow.com/questions/ask?tags=mobile player+ios+swift+video player) Join the chat at https://gitter.im/mobileplayer/mobileplayer-ios

A powerful and completely customizable media player for iOS.

introduction

Table of Contents

  1. Features
  2. Installation
  3. Usage
  4. Customization
  5. Skinning
  6. Showing overlays
  7. Showing timed overlays
  8. Pre-roll
  9. Pause overlay
  10. Post-roll
  11. Examples
  12. Documentation
  13. License

Features

Future plans

Installation

CocoaPods

Add the following line in your Podfile.

"MobilePlayer"
Carthage

Add the following line to your Cartfile.

ub "mobileplayer/mobileplayer-ios"

Usage

rt MobilePlayer

playerVC = MobilePlayerViewController(contentURL: videoURL)
erVC.title = "Vanilla Player - \(videoTitle)"
erVC.activityItems = [videoURL] // Check the documentation for more information.
entMoviePlayerViewControllerAnimated(playerVC)

example-plain

Customization

Initialize using local configuration file

bundle = NSBundle.mainBundle()
config = MobilePlayerConfig(fileURL: bundle.URLForResource(
atermarkedPlayer",
thExtension: "json")!)
playerVC = MobilePlayerViewController(
ntentURL: videoURL,
nfig: config)
erVC.title = "Watermarked Player - \(videoTitle)"
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)

Initialize using remote configuration data

d let configURL = NSURL(string: "https://goo.gl/c73ANK") else { return }
playerVC = MobilePlayerViewController(
ntentURL: videoURL,
nfig: MobilePlayerConfig(fileURL: configURL))
erVC.title = "Watermarked Player - \(videoTitle)"
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)

Configuration data


atermark": {
"image": "MovielalaLogo"


Without a configuration file URL

playerVC = MobilePlayerViewController(
ntentURL: videoURL,
nfig: MobilePlayerConfig(
dictionary: ["watermark": ["image": "MovielalaLogo"]]))
erVC.title = "Watermarked Player - \(videoTitle)"
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)

Result example-customization

Skinning

atermark": {
"image": "MovielalaLogo",
"position": "topRight"

opBar": {
"backgroundColor": ["#a60500b0", "#a60500a0"],
"elements": [
  {
    "type": "button",
    "identifier": "close"
  },
  {
    "type": "slider",
    "identifier": "playback",
    "trackHeight": 6,
    "trackCornerRadius": 3,
    "minimumTrackTintColor": "#eee",
    "availableTrackTintColor": "#9e9b9a",
    "maximumTrackTintColor": "#cccccc",
    "thumbTintColor": "#f9f9f9",
    "thumbBorderWidth": 1,
    "thumbBorderColor": "#fff",
    "marginRight": 4
  }
]

ottomBar": {
"backgroundColor": ["#a60500a0", "#a60500b0"],
"elements": [
  {
    "type": "label",
    "text": "Now Watching",
    "font": "Baskerville",
    "size": 12,
    "marginLeft": 8,
    "marginRight": 8
  },
  {
    "type": "label",
    "identifier": "title",
    "size": 14
  },
  {
    "type": "button",
    "identifier": "action"
  },
  {
    "type": "toggleButton",
    "identifier": "play"
  }
]


For all available identifiers, check the documentation or here. Same identifier value shouldn't be used more than once in a single configuration.

Result example-skinning

Example designs example-design-skinning

Showing overlays
playerVC = MobilePlayerViewController(contentURL: videoURL)
erVC.title = videoTitle
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)
uctStore.getProduct("1", success: { product in
ard let product = product else { return }
ayerVC.showOverlayViewController(
BuyOverlayViewController(product: product))

example-overlay

Showing timed overlays
playerVC = MobilePlayerViewController(contentURL: videoURL)
erVC.title = videoTitle
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)
uctStore.getProductPlacementsForVideo(
deoID,
ccess: { productPlacements in
guard let productPlacements = productPlacements else { return }
for placement in productPlacements {
  ProductStore.getProduct(placement.productID, success: { product in
    guard let product = product else { return }
    playerVC.showOverlayViewController(
      BuyOverlayViewController(product: product),
      startingAtTime: placement.startTime,
      forDuration: placement.duration)
  })
}

example-timed-overlays

Pre-roll
playerVC = MobilePlayerViewController(
ntentURL: videoURL,
erollViewController: PrerollOverlayViewController())
erVC.title = videoTitle
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)

example-preroll

Pause overlay
playerVC = MobilePlayerViewController(
ntentURL: videoURL,
useOverlayViewController: PauseOverlayViewController())
erVC.title = videoTitle
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)

Result example-pause-overlay

Example designs example-design-pause-overlay

Post-roll
playerVC = MobilePlayerViewController(
ntentURL: videoURL,
strollViewController: PostrollOverlayViewController())
erVC.title = videoTitle
erVC.activityItems = [videoURL]
entMoviePlayerViewControllerAnimated(playerVC)

Result example-postroll

Example designs example-design-postroll

Examples

After cloning the repo, run the MobilePlayerExamples target to see examples for many use cases. examples

Documentation

The entire documentation for the library can be found here.

License

The use of the MobilePlayer open source edition is governed by a Creative Commons license. You can use, modify, copy, and distribute this edition as long as it?s for non-commercial use, you provide attribution, and share under a similar license. http://mobileplayer.io/license/


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.