2017-03-28 6 views
0

私は迅速かつ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

あなたは説明できますあなたが試したことをしようとするとどのようなエラーが表示されますか? –

+0

ダウンロードしたファイルを0バイトで取得しています – remyr3my

答えて

1

ローカルストレージに関するtvOSの制限

アプリケーションは、(NSUserDefaultsクラスを使用して)デバイスに対してローカルな500 KBの永続ストレージにのみアクセスできます。この限定されたローカルストレージの外側の空間が低い場合には、他のすべてのデータがオペレーティングシステムによってパージ可能でなければなりません...

あなたは更なる詳細については、このマニュアルを見てみることができます。 https://developer.apple.com/library/content/documentation/General/Conceptual/AppleTV_PG/

関連する問題