2

How to filter screenshots, cinematic videos, and depth-effect photos in PHPicker...

 1 year ago
source link: https://ohmyswift.com/blog/2022/06/26/how-to-filter-screenshots-cinematic-videos-and-depth-effect-photos-in-phpickerviewcontroller/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to filter screenshots, cinematic videos, and depth-effect photos in PHPickerViewController

Jun 26, 2022 • Rizwan Ahmed A • PHPickerViewController

swift, imageassets, phphotopickerviewcontroller, uiimagepikcercontroller, images, phpicker, photolibrary

In iOS 14.0, Apple introduced a new way to pick images from the device’s photo library using PHPickerViewController. (If you are not aware of PHPickerViewController, I strongly recommend you to read about PHPickerViewController first.)

Different apps have different requirements. For example, a hi-res video editing app might be interested in showing cinematic videos and videos. A screenshot stitching app might be interested in showing screenshots upfront. From iOS 16.0, Apple has introduced new APIs, making filtering media very easy. If your app wants to show cinematic videos, you can use the cinematicVideos enum.

PHPickerViewController example of filtering cinematic videos

var configuration = PHPickerConfiguration()
configuration.filter = .cinematicVideos
let picker = PHPickerViewController(configuration: configuration)
present(picker, animated: true)

Similarly, you can filter screenshots, screenRecordings, depthEffectPhotos, and much more. You can read the PHPickerFilter documentation to learn more about the new filter enums.

To filter only screenshots

configuration.filter = .screenshots

To filter only screen recordings

configuration.filter = .screenRecordings

To filter only depth effect photos

configuration.filter = .depthEffectPhotos

The best part is that all the filters except cinematicVideos , depthEffectPhotos, and bursts are backported to iOS 15.0 You can also add compound filters and refine your media results using all and not . They are also backported to iOS 15.0

References

[1] What’s new in the Photos picker

[2] PHPickerViewController

About the author

Support creators

Show your support to indie devs by downloading their apps from the banner displayed below. It will help them build great apps in these tough times.

More articles

OhMySwift Weekly

Interested in learning or upgrading your skills as an iOS/macOS developer? Then this newsletter is for you. Published on Fridays.

No spam, ever. We’ll never share your email address and you can opt out at any time.

Like our articles? Support us!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK