Play / Pause AVPlayerViewController issue in iOS

I am working on an iOS app. This application database is on the carrier NEWS.

I play a short video with highlighted news. I ran into a stranger's problem AVPlayerViewController.

When I play a video, everything is fine. When I go into offline video playback in buffer format, and after the video buffer, the video stops, but progress bar(Slider)continuously in playback mode, when the video is stopped.

For more resolution see this GIF image:

Please follow this link to understand the test.

This is my player code.

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.playVideo()
    }

    func playVideo(){
        let videoURL = NSURL(string: "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8")
        let player = AVPlayer(URL: videoURL!)
        let playerController = AVPlayerViewController()
        playerController.player = player
        self.addChildViewController(playerController)
        self.view.addSubview(playerController.view)
        playerController.view.frame = self.view.frame
        player.play()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
0
source share
1

, gif. (https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4), .

, , AVPlayerViewController.

:

let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(URL: videoURL!)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.presentViewController(playerViewController, animated: true) {
    playerViewController.player!.play()
}

. ui, AVPlayerViewController, .

UPDATE:

Reachaility :

class MyViewController: UIViewController {
  var reachability: Reachability?

  override func viewDidLoad() {
    super.viewDidLoad()

    reachability = try? Reachability.reachabilityForInternetConnection()
    reachability?.whenUnreachable = { _ in
      player.pause()
    }
    try? reachability?.startNotifier()
0

Source: https://habr.com/ru/post/1618172/


All Articles