2017-09-17 2 views
0

Ich möchte Timeshifting (für Live-Streaming-Videos) Feature in iOS-Player verwenden, aber ich fand keine Bibliothek, die Timeshifting unterstützt. Ich las Dokumente von vielen Bibliotheken wie diese:Wie funktioniert die HLS-Timeshifting-Funktion in iOS (AVFoundation oder anderen Drittanbieter-Bibliotheken) wie ExoPlayer in Android?

1- piemonte 2- kaltura

In Android, Google ExoPlayer vorstellen, die uns leicht diese Funktion geben. Wie kann ich diese Funktion in iOS (von swift) implementieren? oder gibt es eine Bibliothek, die das implementiert?

+0

wollen Sie Video-Player Streaming implementieren? – Yuyutsu

+0

@Yuyutsu Nein, fügen Sie einfach diese Funktion zum Media Player hinzu –

Antwort

1

Try this:

 @IBOutlet weak var liveView: UIView! //Add `UIView` on your ViewController and create @IBOutlet for it. 
     var player = AVPlayer() 
     let playerViewController = AVPlayerViewController() 
     override func viewDidLoad() { 
      player = AVPlayer(url: URL(string:"Your_HLS_URL")!) 
      playerViewController.player = self.player 
      playerViewController.player?.play() 
      self.configureChildViewController(childController: self.playerViewController, onView: self.liveView) 

     } 

     func configureChildViewController(childController: UIViewController, onView: UIView?) { 
      var holderView = self.view 
      if let onView = onView { 
       holderView = onView 
      } 
      addChildViewController(childController) 
      holderView?.addSubview(childController.view) 
      constrainViewEqual(holderView: holderView!, view: childController.view) 
      childController.didMove(toParentViewController: self) 
     } 

     func constrainViewEqual(holderView: UIView, view: UIView) { 
      view.translatesAutoresizingMaskIntoConstraints = false 
      //pin 100 points from the top of the super 
      let pinTop = NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, 
              toItem: holderView, attribute: .top, multiplier: 1.0, constant: 0) 
      let pinBottom = NSLayoutConstraint(item: view, attribute: .bottom, relatedBy: .equal, 
               toItem: holderView, attribute: .bottom, multiplier: 1.0, constant: 0) 
      let pinLeft = NSLayoutConstraint(item: view, attribute: .left, relatedBy: .equal, 
              toItem: holderView, attribute: .left, multiplier: 1.0, constant: 0) 
      let pinRight = NSLayoutConstraint(item: view, attribute: .right, relatedBy: .equal, 
               toItem: holderView, attribute: .right, multiplier: 1.0, constant: 0) 

      holderView.addConstraints([pinTop, pinBottom, pinLeft, pinRight]) 
     } 
Verwandte Themen