代码之家  ›  专栏  ›  技术社区  ›  harshal jadhav

使用AVplayer播放s3视频时出现问题

  •  1
  • harshal jadhav  · 技术社区  · 7 年前

    大家好,我正在尝试使用Avplayer播放s3的视频。现在,如果我播放视频,视频在整个视频缓冲后开始播放。所以我补充说 player.automaticallyWaitsToMinimizeStalling = false

    import UIKit
    import AVFoundation
    import AVKit
    class ViewController: UIViewController {
        var player: AVPlayer!
        var item : AVPlayerItem!
    
        override func viewDidLoad() {
            super.viewDidLoad()
            item = AVPlayerItem(url: URL(string: "https://cent-churchconnect.s3-ap-southeast-2.amazonaws.com/cent-churchconnect/testAdmin/eb8cc8b5-80e0-468a-a2c9-979cf1b5ac76_toystory.mp4")!)
            player = AVPlayer(playerItem: item)
            let controller = AVPlayerViewController()
            present(controller, animated: true) { _ in }
            controller.player = player
            addChildViewController(controller)
            view.addSubview(controller.view)
            controller.view.frame = CGRect(x: 0, y: 50, width: self.view.frame.size.width, height: 300)
            controller.player = player
            controller.showsPlaybackControls = true
            if #available(iOS 10.0, *) {
                player.automaticallyWaitsToMinimizeStalling = false
                player.play()
            } else {
                // Fallback on earlier versions
            }
        }
    }
    
    3 回复  |  直到 7 年前
        1
  •  1
  •   chaitali gorhe    5 年前

    我有同样的问题,下面的步骤对我有效, 尝试使用方法 func playImmediately(atRate:) player.automaticallyWaitsToMinimizeStalling = false 设置正确。

        2
  •  0
  •   Taras Chernyshenko    7 年前

    func playImmediately(atRate:) 而不是 func play()

        3
  •  0
  •   harshal jadhav    6 年前

    我用了可可荚 https://github.com/piemonte/Player .

    可以使用委托方法来控制播放。