我正在使用DKImagePicker
来选择多种图片和视频。我正在拍摄图片,但我不知道如何获取视频?
分享以下我目前尝试过的代码
请指导。
func setImage()
{
let pickerController = DKImagePickerController()
pickerController.showsCancelButton = true
pickerController.showsEmptyAlbums = false
pickerController.didSelectAssets = { (assets: [DKAsset]) in
print("didSelectAssets")
self.assets1 = assets
print(assets.count)
for asset in assets {
asset.fetchImageWithSize(PHImageManagerMaximumSize, completeBlock: { image, info in
if let img = image {
// let fixOrientationImage=img.fixOrientation()
User.sharedInstance.arrRoomGalleryImages.addObject(img)
print("array after selecting images and videos", User.sharedInstance.arrRoomGalleryImages)
kAppDelegate.imageSelected = true
}
})
}
}
if(!(kAppDelegate.imageSelected))
{
self.presentViewController(pickerController, animated: true) {}
}
}
答案 0 :(得分:0)
要获取视频,DKAsset有一个属性isVideo。利用它。
for asset in self.assets {
if asset.isVideo == true {
asset.fetchAVAsset(.None, completeBlock: { video, info in
})
} else {
asset.fetchImageWithSize(PHImageManagerMaximumSize, completeBlock: { image, info in
if let img = image {
// let fixOrientationImage=img.fixOrientation()
User.sharedInstance.arrRoomGalleryImages.addObject(img)
print("array after selecting images and videos", User.sharedInstance.arrRoomGalleryImages)
kAppDelegate.imageSelected = true
}
})
}
}