It is simple and easy to use video player with playback controls written in Swift.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate GPVideoPlayer into your Xcode project using CocoaPods, specify it in your Podfile
:
target 'sampleproj' do
use_frameworks!
pod 'GPVideoPlayer'
end
Then, run the following command:
$ pod install
First import GPVideoPlayer in the file where you are going to use it, for example in a UIViewController
.
import GPVideoPlayer
Create a GPVideoPlayer object using the view's bounds where you want to show the player and add it as a subView
.
if let player = GPVideoPlayer.initialize(with: self.view.bounds) {
self.view.addSubview(player)
//Player customization...
}
In the above example, I'm adding player to the viewController's subView
.
Load the player with the URLs of the videos.
let url1 = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!
let videoFilePath = Bundle.main.path(forResource: "video", ofType: "mp4")
let url2 = URL(fileURLWithPath: videoFilePath!)
player.loadVideos(with: [url1, url2])
4. Additional customization parameters.
```swift
player.isToShowPlaybackControls = true
player.isMuted = true
player.playVideo()
To run the example project,
GPVideoPlayer -> Example -> GPVideoPlayer.xcworkspace
GPVideoPlayer is available under the MIT license. See the LICENSE file for more info.