Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook
Clone or download
Latest commit 33c2af9 Oct 8, 2018
Failed to load latest commit information.
Example #3.1.3 May 19, 2018
MMPlayerView 3.1.3 May 19, 2018
demo update cover Aug 26, 2017
.gitignore Initial commit Jun 20, 2017
.swift-version ##3.0.1 Sep 20, 2017
.travis.yml Initial commit Jun 20, 2017
LICENSE Initial commit Jun 20, 2017
MMPlayerView.podspec 3.1.3 May 19, 2018 Update Oct 8, 2018
_Pods.xcodeproj Initial commit Jun 20, 2017



CI Status Version License Platform


List / Shrink / Transition / Landscape

list shrink transition landscape


ex. use when change player view frequently like tableView / collectionView
import MMPlayerView
mmPlayerLayer.playView = cell.imgView
mmPlayerLayer.set(url:, state: { (status) in 


let url = URL.init(string: "")!
playView.replace(cover: CoverA.instantiateFromNib())
playView.set(url: url, thumbImage: #imageLiteral(resourceName: "seven")) { (status) in
    switch status {
       case ....


1. Set transition config
    required init?(coder aDecoder: NSCoder) {
       super.init(coder: aDecoder)
        self.mmPlayerTransition.present.pass { (config) in
            // setting
2. Set MMPLayerToProtocol on PresentedViewController
3. Set MMPlayerPrsentFromProtocol on PresentingViewController


ex. only set present transition can use shrink video
(self.presentationController as? PassViewPresentatinController)?.shrinkView()


1.Set AppDelegate
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) ->        
    UIInterfaceOrientationMask {
    if window == MMLandscapeWindow.shared {
        return .allButUpsideDown
    } else {
        return ....
2. Observer orientation when landscape call function
    MMLandscapeWindow.shared.makeKey(root: full, playLayer: self.mmPlayerLayer, completed: {

Cover View


## add cover item view on player
play.replace(cover: CoverA.instantiateFromNib())


// Custom your progress view and it will add on player center
// view need to implement ProgressProtocol, and add progress in this view, when start/stop control what need to do
.custom(view: <#T##MMProgressProtocol#>)
 public protocol MMProgressProtocol {
     func start()
     func stop()


playerLayer.cacheType = .memory(count: 10)
public enum MMPlayerCacheType {
    case none
    case memory(count: Int) // set this to cache seek time in memory and if cache out of count will remove first you    

Layer Protocol

// detect if touch in videoRect
// if touch out of videoRect will not trigger show/hide cover view event
public protocol MMPlayerLayerProtocol: class {

func touchInVideoRect(contain: Bool) // 


public enum MMPlayerCoverAutoHideType {
    case autoHide(after: TimeInterval)
    case disable

public enum MMPlayerCacheType {
   case none // set no cache and remove all
   case memory(count: Int) // cache player seek time in memory
public enum CoverViewFitType {
  case fitToPlayerView // coverview fit with playerview
  case fitToVideoRect // fit with VideoRect
public enum ProgressType {
   case `default`
   case none
   case custom(view: ProgressProtocol)
public var autoHideCoverType = MMPlayerCoverAutoHideType.autoHide(after: 3.0) // Default hide after 3.0 , set disable to close auto hide cover            
public var progressType: MMPlayerView.ProgressType  
public var coverFitType: MMPlayerView.CoverViewFitType
public var changeViewClearPlayer: Bool // rest url when change view 
lazy public var thumbImageView: UIImageView 
public var playView: UIView?
public var coverView: UIView? { get }
public var autoPlay: Bool // when MMPlayerView.MMPlayerPlayStatus == ready auto play video
public var currentPlayStatus: MMPlayerView.MMPlayerPlayStatus 
public var cacheType: MMPlayerCacheType = .none
public var playUrl: URL?
public func showCover(isShow: Bool)
public func setCoverView(enable: Bool)
public func delayHideCover()
public func replace<T: UIView>(cover:T) where T: CoverViewProtocol
public func set(url: URL?, state: ((MMPlayerView.MMPlayerPlayStatus) -> Swift.Void)?)
public func startLoading() // if loading finish autoPlay = false, need call where you want
public weak var mmDelegate: MMPlayerLayerProtocol?


iOS 8.0+
Xcode 8.0+
Swift 3.0+, 4.0+


MMPlayerView is available through CocoaPods. To install it, simply add the following line to your Podfile:

Swift 3 
pod 'MMPlayerView', '~> 2.1.8'
Swift 4 (> 3.0.1)
pod 'MMPlayerView'



MMPlayerView is available under the MIT license. See the LICENSE file for more info.