我正在尝试从我的网络路径播放视频文件
\\alan\movies\kids\alladin.mp4。
我可以从我的 Mac 上查看和浏览目录。
如果我将视频文件添加为项目的一部分,下面的代码可以正常工作
import UIKit
import AVFoundation
import AVKit
class ViewController: AVPlayerViewController {
@IBOutlet var vwVideoView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
playVideo()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
private func playVideo() {
if let path = NSBundle.mainBundle().pathForResource("Alladin", ofType: "mp4") {
let url = NSURL(fileURLWithPath: path)
player = AVPlayer(URL: url)
}
else {
print("Oops, something wrong when playing video")
}
}
}
我将视频文件从网络文件夹复制到我的本地电影文件夹,如下所示
NSBundle.mainBundle().pathForResource("file://localhost/Users/alan/Movies/test/Alladin", ofType: "mp4")
视频文件仍未播放。这甚至可以从网络播放视频文件吗?
问候,-艾伦-