[](http://stackoverflow.com/questions/ask?tags=mobile player+ios+swift+video player)
A powerful and completely customizable media player for iOS.
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"
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.
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
In most cases though you would want to customize the player. You can do this by creating a configuration JSON file or programmatically.
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))
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"
])
])
)
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.
The entire documentation for the library can be found here.
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/