I'm trying to figure it out, but can't find any useful information. I only found this:
PHAssetResourceManager.defaultManager().writeDataForAssetResource(assetRes,
toFile: fileURL, options: nil, completionHandler:
{
// Video file has been written to path specified via fileURL
}
but I'm ashamed to say I have no idea how to play it out. I've created a UIImagePickerController and loaded an Image from the Camera Roll.
Use this code to get the video from live photo:
Basically what you have to do is that you first need to fetch the
PHLivePhoto
object from yourPHAsset
. After that, you will have to traverse all the asset resources within your live photo and check if it is of typePHAssetResourceTypePairedVideo
.If yes, you got your video. Now you will require to save it to some temporary directory as I did here and use this file for whatever purpose you may have.
To Play this video, you can use the following code:
Feel free to ask if you need any clarification.
P.S.- I made a few changes in this method to remove dependency of my application's code so the above code is untested, however I feel it should work as expected.