首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >苹果tvOS视频下载

苹果tvOS视频下载
EN

Stack Overflow用户
提问于 2017-03-28 07:02:34
回答 1查看 315关注 0票数 0

我是一个专业的新手。我想从url下载一个视频,并在ViewController中显示它。当我尝试使用ios设备时,视频将被下载并与fine.But一起使用tvOS,而视频不会被下载。

为什么这么..?

我如何下载和播放的视频在苹果电视。

这是我的密码

设backgroundSessionConfiguration =backgroundSessionConfiguration "backgroundSession")

代码语言:javascript
复制
    backgroundSession = Foundation.URLSession(configuration: backgroundSessionConfiguration, delegate: self, delegateQueue: OperationQueue.main)

    let url = URL(string: "myURl")!
    downloadTask = backgroundSession.downloadTask(with: url)
    downloadTask.resume()

函数urlSession(_ session: URLSession,downloadTask: URLSessionDownloadTask,didFinishDownloadingTo location: URL){

代码语言:javascript
复制
    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")
        }
    }
}  
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-29 18:12:07

tvOS中对本地存储有一些限制

您的应用程序只能访问设备本地的500 KB持久存储(使用NSUserDefaults类)。在这个有限的本地存储之外,当空间很小时,所有其他数据都必须由操作系统进行清理。

您可以查看本文档以获得更多详细信息:PG/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43062697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档