Skip to content

onlyyoujack/mobileplayer-ios

Repository files navigation

MobilePlayer CocoaPods

Number of Tests Dependencies Ready In Progress Post an issue

[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.

Table of Contents

  1. Installation
  2. Usage
  3. Documentation
  4. Software License

Installation

There are various ways you can get started with using MobilePlayer in your projects.

Add the following line in your Podfile.

pod "MobilePlayer"

Add the following line to your Cartfile.

github "mobileplayer/mobileplayer-ios"

Git Submodule

Open the Terminal app and cd to your project directory. Then run

git submodule add [email protected]:mobileplayer/mobileplayer-ios.git

This should create a folder named MobilePlayer inside your project directory. After that, drag and drop MobilePlayer/MobilePlayer.xcodeproj into your project in Xcode and add the MobilePlayer.framework in the Embedded Binaries section of your target settings under the General tab.

Usage

If you were previously using MPMoviePlayerViewController, changing

let playerVC = MPMoviePlayerViewController(contentURL: videoURL)

to

let playerVC = MobilePlayerViewController(contentURL: videoURL)

is enough. Make sure you don't forget to

import MobilePlayer

Customizing the Player

In most cases though you would want to customize the player. You can do this by creating a configuration JSON file or programmatically.

Configuration File

Here is a sample configuration file if you just want to add a watermark to the bottom right corner of the player.

{
  "watermark": {
    "image": "CompanyLogo"
  }
}

In this case you need to have an image asset named CompanyLogo in your project. After that you create a configuration object using the file and initialize your player using that.

guard let configFileURL = NSBundle.mainBundle().URLForResource("PlayerConfig", withExtension: "json") else {
  fatalError("Unable to load player configuration file")
}
let playerVC = MobilePlayerViewController(contentURL: videoURL, config: MobilePlayerConfig(fileURL: configFileURL))

Programmatic Configuration

The above example done without using any JSON files looks like the following.

let playerVC = MobilePlayerViewController(
  contentURL: videoURL,
  config: MobilePlayerConfig(dictionary: [
    "watermark": WaterMarkConfig(dictionary: [
      "image": "CompanyLogo"
    ])
  ])
)

Advanced Configuration

You can edit the player interface completely, add new buttons with custom actions, and way more using configuration objects and files. Check the MobilePlayerConfig class and other configuration class documentations for a full list of things you can do.

A fully customized player configuration file can look like this.

Documentation

The entire documentation for the library can be found here.

Software 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/

About

A powerful and completely customizable media player for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.4%
  • Objective-C 1.1%
  • Other 1.5%