Search code examples
tvosasset-catalog

How to include 1x 1080p and 2x 4K video assets for tvOS


I have an app that plays videos using AVFoundation APIs. These videos are currently placed into the project as separate files. They're 1080p videos, but now I have new 4K versions that I would like to use when the app is run on 4K Apple TVs, and it should continue using the 1080p assets on HD Apple TVs. I don't want both resolutions included in the app as that would dramatically increase the download size. App thinning does this for image assets placed in the asset catalog for 1x and 2x scales, but unfortunately it seems this isn't available for videos. Is there a way to provide 1x and 2x video assets such that the appropriate resolution is provided based on the Apple TV hardware downloading the app? Perhaps with on-demand resources? I do want the assets to always be available - the user shouldn't have to download them after the app is installed.


Solution

  • In response to feedback I submitted, I was informed this is possible if you use a Data Asset in Asset Catalog and the NSDataAsset API to retrieve the video. Tag the 4K version of the asset with the “APPLE 3” graphics feature class and put the 1080p version in the Any/Any slot. This will ensure the 4K version of the video asset is included for 4K Apple TV devices and the 1080p version is included for the others.