如何获取屏幕录像视频

How to fetch screen recordings video

我们知道,我们可以像这样用PhotoKit框架获取截图照片,

 let collection = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumScreenshots, options: fetchOption)

但是如何获取屏幕录像视频?

试试这个⬇️

func openVideoGallery() {
    let picker = UIImagePickerController()
    picker.delegate = self
    picker.sourceType = .savedPhotosAlbum
    picker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .savedPhotosAlbum)!
    picker.mediaTypes = ["public.movie"]      
    picker.allowsEditing = false
    present(picker, animated: true, completion: nil)
}

现在实施委托方法来检索选定的视频。

if let res = PHAssetResource.assetResources(for: asset).first {
       if res.originalFilename.hasPrefix("RPReplay") {              
          screenRecordings.append(asset.localIdentifier)
       } 
}