简体   繁体   中英

problems while playing video from s3 using AVplayer

Hi all i am trying to play a video from s3 using Avplayer. Now if i play the video, the video starts playback after the whole video is buffered. so I added player.automaticallyWaitsToMinimizeStalling = false , but now the video automatically pauses

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

我在为我工作的以下步骤中遇到了相同的问题,请尝试使用func playImmediately(atRate:) ,并确保正确设置了属性player.automaticallyWaitsToMinimizeStalling = false

使用方法func playImmediately(atRate:)代替func play()

I used the cocoa pod https://github.com/piemonte/Player .

You can use the delegate methods to control the playback.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM