AVURLAsset / AVPlayerItem from Asset Catalog - avplayeritem

I have a bunch of audio files which I keep in my asset catalog to benefit from the store optimizations that it brings. However, the AVAudioPlayer ideally wants AVURLAssets from which subsequently AVPlayerItems can be created.
Problem is, asset data doesn't have an URL. How do I combine asset catalog assets with AVPlayer?
Apple advises loading the files via NSDataAsset constructor, which doesn't help.

Related

In-Game Asset Downloads Using Play Asset Delivery - Unity

I am making a game and it is going to have a lot of assets in the game and the download size is going to be very big. I am using the Play Asset Delivery to upload my large game to Play Store. More than 90% of the assets are maps. I have a few maps in the game and I don't want them all to be downloaded when the player is installing the game from the Google Play Store. Like Call of Duty Mobile I want the player to be able to download each map individually in runtime.
I separated the assets of every map into a separate assetBundle.
I read the Play Asset Delivery documentation and it seems like I have to use On-demand for each assetBundle.
But the when I build the game and upload it to play store it will download the whole game again. I don't know how to make it not download the on-demand assetBundles.
How do I do that?
is it event possible?
And sorry if my English was bad.
Here's the reference on how you retrieve the assets: Unity Documentation
Basically you need to import the Play Asset Delivery library and call the RetrieveAssetBundleAsync() method to retrieve an AssetBundle.
You can also request asset asynchronously and monitor the download progress.
Here's another reference on how you download the assets. Retrieve assests

Swift 5 Save AVAsset to UserDefaults

Users can scroll through the feed and retrieve videos from my cloud storage.
I would like to cache the videos (which I do successfully temporary in an array) but I want to retrieve the videos also when restarting the App.
Currently, if the user kills the app and starts again the temporary folder is of course empty.
How can I achieve that?
You need to persist the assets. There are several technologies for this, such as files in the user directory, CoreData, SQLite, etc. UserDefaults would not be recommended for such large files.

Unity minimizing app size

I am working on a unity project using vuforia and the vuforia video playback. The project involves adding a lot of mp4 files directly into the project directory because the vuforia video playback needs a local path to the video. The unity project is now up to 3.2 GB, and I just started development. Are there any ways to combat this issue of this app potentially getting way too large?
I recommend storing your larger files in an Asset Bundle. Asset Bundles allow you to store your content online, and download it when necessary (once opened after install, or after the user has paid for the content). You can access your assets locally using the Asset Bundle directory:
Application.dataPath + "/AssetBundles/" + assetBundleName
Compress the files as much as possible until you see some visible quality drop. You just need to find the best combination of video resolution and audio / video bit rates.

iPhone Media Player Framework accessing raw file

I'm interested in using the Media Player framework on iPhone to access audio in the user's library. I want to be able to load a given audio file and then perform some specialised filtering on it.
Ideally I want to be able to directly load the audio file (or portion thereof for streaming) then use the audio converter services to perform decompression. Once I have the linear PCM data I want to perform some filtering on it before supplying the audio directly to an audio queue.
Is this possible on iPhone?
If so, can anyone tell me how I would access the audio file directly? Is it just a matter of using the "URL" to load it using NSFile (Presumably I obtain that through MPMediaItemPropertyAssetURL)? Or do I need to do something more complicated?
Cheers!
The URL you get from MPMediaItemPropertyAssetURL is an Assets Library URL. You can use it to initialize an AVURLAsset. Then create an AVAssetReader with the asset and add to it an AVAssetReaderOutput (instances of AVAssetReaderAudioMixOutput or AVAssetReaderTrackOutput, depending on what you need). This latter object will finally give you access to the media data (-copyNextSampleBuffer).

Play specific local IPhone Video

I am in need for some help as I am stuck with a problem with my current IPhone application. I won't go into every details but the mainline is as follow:
I am currently playing videos from a remote URL. Everthing up to this point is working. But we need to add a certain validation as if the video exists on the local IPhone, play this version and otherwise, get the remote version. I get these informations from an XML feed and have the name of the video and it's remote URL.
I've implemented the ALAssetLibrary as a way to retrieve the locals video and transfered 3-4 videos with custom names. After some struggling, I could play these local video. But while I loop through them, all I get is names like 00001.jpg, etc.
Is there any way to get a local video name ? I don't mind if this needs another library but I would appreciate if someone could point me a way of doing it.
Thanks for your time,
AP
You don't have access to the local filenames, and even if you did those filenames would probably not be what you are expecting (i.e. Apple can and probably does rename them while saving them to the Camera Roll).
You can check the metadata on the ALAssetRepresentation for the video to see if a suitable name or other identifier can be found in there. You might also be able to retrieve the raw data and hash it, but that would fail if Apple does any recoding or metadata alteration when saving the video. If your program itself downloads and saves the videos to the Camera Roll using writeVideoAtPathToSavedPhotosAlbum:completionBlock:, you could store the returned assetURL to remember the correspondence. Or you could save the videos to your app's local storage instead of to the Camera Roll, but that would prevent the user from managing the videos with Apple's photo application and such.