To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 10 or Higher
- Swift 4
AwesomeMedia is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'AwesomeMedia', git: 'https://github.com/iOSWizards/AwesomeMedia.git', tag: '1.9.6.1'
- Create a
var
extendingAwesomeMediaView
. Or extend aUIView
component from the storyboard.
var mediaView: AwesomeMediaView!
- Setup media to play.
mediaView.setup(mediaPath: "http://overmind2.mindvalleyacademy.com/api/v1/assets/267bb3c6-d042-40ea-b1bd-9c9325c413eb.m3u8")
- Assign player layer to self (in case playing video).
mediaView.addPlayerLayer()
- Setup delegate.
AwesomeMedia.shared.playerDelegate = self
extension MediaViewController: AwesomeMediaPlayerDelegate {
public func didChangeSpeed(to: Float, mediaType: AMMediaType) {
print("MediaViewController didChangeSpeed(\(to))")
}
public func didChangeSlider(to: Float, mediaType: AMMediaType) {
print("MediaViewController didChangeSlider(\(to))")
}
public func didStopPlaying(mediaType: AMMediaType) {
print("MediaViewController didStopPlaying")
}
public func didStartPlaying(mediaType: AMMediaType) {
print("MediaViewController didStartPlaying")
}
public func didPausePlaying(mediaType: AMMediaType) {
print("MediaViewController didPausePlaying")
}
public func didFinishPlaying(mediaType: AMMediaType) {
print("FullscreenMediaViewController didFinishPlaying")
}
public func didFailPlaying(mediaType: AMMediaType) {
print("FullscreenMediaViewController didFailPlaying")
}
}
- Setup orientation listener.
AwesomeMedia.shared.addOrientationObserverGoingLandscape(observer: self, selector: #selector(MediaViewController.goToLandscapeController))
func goToLandscapeController() {
performSegue(withIdentifier: "presentFullScreenSegue", sender: self)
}
- Print Logs.
AwesomeMedia.showLogs = true
AwesomeMedia is available under the MIT license. See the LICENSE file for more info.