ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - MillmanY/MMPlayerView: Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook
Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook  - GitHub - MillmanY/MMPlayerView: Custom AVPlayerLayer on view and transition player with good effect ...
Visit Site

GitHub - MillmanY/MMPlayerView: Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

GitHub - MillmanY/MMPlayerView: Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

MMPlayerView

paypal

CI Status Version License Platform

Demo-Swift

List / Shrink / Transition / Landscape

list shrink transition landscape

MMPlayerLayer

ex. use when change player view frequently like tableView / collectionView
import MMPlayerView
mmPlayerLayer.playView = cell.imgView
mmPlayerLayer.getStatusBlock { [weak self] (status) in

}
self.mmPlayerLayer.set(url: DemoSource.shared.demoData[indexPath.row].play_Url)
self.mmPlayerLayer.resume()

Transition

##PresentedViewController
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

Landscape

1.Set MMPlayerLayer
   // roation screen to landscape can change player to fullscreen
   mmplayerLayer.fullScreenWhenLandscape = true
   
2. Set from code
   mmplayerLayer.setOrientation(.landsacpeLeft)
   
3. Observer
  mmPlayerLayer.getOrientationChange { (status) in
        print("Player OrientationChange \(status)")
  }

Cover View

landscape

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

Progress

// 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()
 }
 

Cache

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    
    stored
}

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: 

) // 
}

Downloader

        var downloadObservation: MMPlayerObservation?

        downloadObservation = MMPlayerDownloader.shared.observe(downloadURL: downloadURL) { [weak self] (status) in
            switch status {
            case .cancelled:
                print("Canceld")
            case .completed:
                DispatchQueue.main.async {
                    self?.downloadBtn.setTitle("Delete", for: .normal)
                    self?.downloadBtn.isHidden = false
                    self?.progress.isHidden = true
                }
            case .downloading(let value):
                self?.downloadBtn.isHidden = true
                self?.progress.isHidden = false
                self?.progress.progress = value
                print("Exporting \(value) \(downloadURL)")
            case .failed(let err):
                DispatchQueue.main.async {
                    self?.downloadBtn.setTitle("Download", for: .normal)
                }
                
                self?.downloadBtn.isHidden = false
                self?.progress.isHidden = true
                print("Download Failed \(err)")
            case .none:
                DispatchQueue.main.async {
                    self?.downloadBtn.setTitle("Download", for: .normal)
                }
                self?.downloadBtn.isHidden = false
                self?.progress.isHidden = true
            case .exist:
                DispatchQueue.main.async {
                    self?.downloadBtn.setTitle("Delete", for: .normal)
                }
                self?.downloadBtn.isHidden = false
                self?.progress.isHidden = true
            }

Delete

        if let info = MMPlayerDownloader.shared.localFileFrom(url: downloadURL)  {
            MMPlayerDownloader.shared.deleteVideo(info)
        }

Subtitle

     let subTitleStr = Bundle.main.path(forResource: "test", ofType: "srt")!
         if let str = try? String.init(contentsOfFile: subTitleStr) {
             self.mmPlayerLayer.subtitleSetting.subtitleType = .srt(info: str)
             self.mmPlayerLayer.subtitleSetting.defaultTextColor = .red
             self.mmPlayerLayer.subtitleSetting.defaultFont = UIFont.boldSystemFont(ofSize: 20)
         }
     }

Shrink

    // Return a view which you want back
    self.mmPlayerLayer.shrinkView(onVC: self, isHiddenVC: false) { [weak self] () -> UIView? in
        guard let self = self, let path = self.findCurrentPath() else {return nil}
        let cell = self.findCurrentCell(path: path) as! PlayerCell
        self.mmPlayerLayer.set(url: cell.data!.play_Url)
        self.mmPlayerLayer.resume()
        return cell.imgView
    }
    // Check player is shrink or not
    self.mmPlayerL.isShrink

Demo-SwiftUI

Control

let control = MMPlayerControl()
//Play
control.set(url: self.videoList[idx].play_Url)
control.resume()
//InValidate
control.invalidate()
//Observation parameter
@Published
public var orientation: PlayerOrientation = .protrait
@Published
public var timeInfo = TimeInfo()
@Published
public var isMuted = false
@Published
public var isBackgroundPause = true
@Published
@Published
public var repeatWhenEnd: Bool = false
@Published
public var isLoading: Bool = false
public var cacheType: PlayerCacheType = .none
@Published
public private(set) var isCoverShow = false
@Published
public var autoHideCoverType = CoverAutoHideType.disable
public var coverAnimationInterval = 0.3
@Published
public var error: MMPlayerViewUIError?

Init View

let player = MMPlayerViewUI(control: self.control, cover: CoverAUI())

Download

view.modifier(MMPlayerDownloaderModifier(url: obj.play_Url!, status: $downloadStatus))

Transition Player

//func playerTransition<Content: View>(view: Content, from: CGRect?) -> AnyTransition
if showDetailIdx != nil {
    DetailView(obj: self.playListViewModel.videoList[showDetailIdx!], showDetailIdx: $showDetailIdx)
       .edgesIgnoringSafeArea(.all)
       .transition(.playerTransition(view: MMPlayerViewUI(control: control) ,from: fromFrame))
        .zIndex(1)
}
// Trigger transition
withAnimation { 
      self.fromFrame = obj.frame
      self.showDetailIdx = offset
}

Requirements

iOS 12.0+
Swift 5.0+

Installation

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

Swift 5 
pod 'MMPlayerView'

Author

[email protected]

License

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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory