gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 15:24:34 26 4
gpt4 key购买 nike

大家好,我正在尝试使用 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
}
}
}

最佳答案

我在以下对我有用的步骤中遇到了同样的问题,尝试使用方法 func playImmediately(atRate:) 并确保属性 player.automaticallyWaitsToMinimizeStalling = false 设置正确。

关于ios - 使用 AVplayer 从 s3 播放视频时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45457089/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com