类型 库 修订 版本 2024.3703 关键词 按需资源, onDemandResources 平台 tvOS, iOS 另请参阅 Apple TV 和 tvOS (指南)
onDemandResources 插件为 Apple 的 按需资源 提供了一个接口,适用于 tvOS。
使用
本质上,
您不应该为文件夹及其嵌套的子文件夹分配唯一的标签。例如,如果您为 `assets/images` 分配了一个标签,则不应为 `assets/images/level1` 分配单独的标签,因为 `level1` 资源本身已包含在更广泛的标签中。
如果操作系统需要存储空间,它可能会自动循环遍历标签并删除已下载的内容。默认情况下,最近未使用的资源将优先被删除,但您可以使用 onDemandResources.setPreservationPriority() 管理删除行为。
要使用此插件,请在 `build.settings` 的 `plugins` 表中添加一个条目。添加后,构建服务器将在构建阶段集成该插件。
settings = { plugins = { ["plugin.onDemandResources"] = { publisherId = "com.coronalabs" }, }, }
要配置
此外,您可以包含一个可选的 `type` 键,其值可以是以下两者之一:
`"install"` — 当从 App Store 下载应用程序时,将立即下载这些资源。这对于应用程序首次启动时可能立即需要的资源非常有用。与简单地
`"prefetch"` — 这些资源将在从 App Store 下载应用程序后立即开始在后台下载。
settings = { tvos = { onDemandResources = { { tag="introMusic", resource="intro.mp4", type="prefetch" }, { tag="imgTutorial", resource="img/tutorial", type="install" }, { tag="imgL1", resource="img/level1" }, }, }, iphone = { onDemandResources = { { tag="introMusic", resource="intro.mp4", type="prefetch" }, { tag="imgTutorial", resource="img/tutorial", type="install" }, { tag="imgL1", resource="img/level1" }, }, }, }