1
我試圖使用AVPlayer處理視頻文件,我在googleDrive,dropbox,riouxsvn和github上的公共文件夾中上傳了一些視頻......它們都不能播放。如何在Swift 2中使用AVPLayer從遠程URL播放視頻
否則我找到了可以工作的樣本,我注意到那些可以在瀏覽器中自動播放的視頻。
玩家不是真正的問題......這個問題與視頻更相關。如果我從可以播放的視頻中挑選出任何網址,視頻會立即在瀏覽器中啓動......如果我在無法播放的網址上播放視頻,您會看到視頻無法播放,我必須將其播放( Dropbox和谷歌驅動器)或在riouxsvn視頻開始下載。
所以我不知道,我不能在互聯網上找到如何解決這個問題。你知道我應該如何以及在哪裏上傳視頻,以便它可以在設備上播放?
@IBAction func playVideoTest(sender: AnyObject) {
//Video URLs that can be played
//let url:NSURL = NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")!
//let url:NSURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!
//Video URLs that can NOT be played
let url:NSURL = NSURL(string: "https://svn.riouxsvn.com/salsa4allmedia/Videos/SampleVideo.mp4")!
//let url:NSURL = NSURL(string: "https://www.dropbox.com/s/kkjwajuo7r1mqox/SampleVideo.mp4?dl=0")!
//let url:NSURL = NSURL(string: "https://drive.google.com/open?id=0B1tAk1RMaHu0T1dVNWFYS1ExS0k")!
//let url:NSURL = NSURL(string: "https://github.com/dervatii/SalsaMedia/blob/master/SampleVideo.MOV")!
var player = AVPlayer()
player = AVPlayer(URL: url)
let playerController = AVPlayerViewController()
playerController.player = player
self.presentViewController(playerController, animated: true) {
player.play()
}
}
Check the result showed in the simulator here