我花了更多时间在这上面然后我很想承认......
如果我从网址硬编码视频,它会启动就好了!但是,如果我将其设置为可重用单元格的变量,则它将无法在启动时播放。
var vid: String!
override func viewDidLoad() {
super.viewDidLoad()
playVideo()
}
func getVid(var url: String) {
if url.hasPrefix("https://streamable.com/") {
let ending = String(url.characters.dropFirst(23))
url = "https://cdn.streamable.com/video/mp4-mobile/"+ending+".mp4"
}
vid = url
}
func playVideo(){
player = AVPlayer(URL: NSURL(string: String(vid))!)
player?.play()
}