私は迅速かつtvOSの初心者です。私は、URLからビデオをダウンロードし、それをViewControllerに表示したいと思います。私はiosデバイスでビデオをダウンロードしようとしていますが、tvOSではビデオはダウンロードされません。ビデオAppleでダウンロードtvOS
どうしてそうですか?
Apple TVでビデオをダウンロードして再生するにはどうすればよいですか?
backgroundSession = Foundation.URLSession(configuration: backgroundSessionConfiguration, delegate: self, delegateQueue: OperationQueue.main)
let url = URL(string: "myURl")!
downloadTask = backgroundSession.downloadTask(with: url)
downloadTask.resume()
FUNCのurlSession(_セッション:URLSession、 downloadTask:URLSessionDownloadTask、 didFinishDownloadingTo場所:URL:ここに
は私のコードせbackgroundSessionConfiguration = URLSessionConfiguration.background( "backgroundSession" withIdentifier)であります){
let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentDirectoryPath:String = path[0]
let fileManager = FileManager()
let destinationURLForFile = URL(fileURLWithPath: documentDirectoryPath.appendingFormat("/file.mp4"))
if fileManager.fileExists(atPath: destinationURLForFile.path){
showFileWithPath(path: destinationURLForFile.path)
}
else{
do {
try fileManager.moveItem(at: location, to: destinationURLForFile)
// show file
showFileWithPath(path: destinationURLForFile.path)
}catch{
print("An error occurred while moving file to destination url")
}
}
}
あなたは説明できますあなたが試したことをしようとするとどのようなエラーが表示されますか? –
ダウンロードしたファイルを0バイトで取得しています – remyr3my