Provide the same interactive playback of Live Photos as in the iOS Photos app.
PHLive class provides a way to display Live Photos—pictures, taken on compatible hardware, that include motion and sound from the moments just before and after their capture. A Live Photo view provides the same interactive playback features found in the Photos app.
In iOS and tvOS, you can fetch Live Photo objects to display in a Live Photo view with the
PHLive class in the Photos framework. In macOS, the
PHLive class provides access to Live Photos being edited in a photo editing extension for the Photos app.
To display Live Photo content on the web, use the LivePhotosKit JS framework.
Control Live Photo Playback
After obtaining a
PHLive object, use a Live Photo view to display the photo and control playback of its motion and sound content. In iOS and tvOS, you can obtain Live Photos from the user's photo library using the
PHImage classes, or by creating one from asset resources exported from a photo library. In macOS, Live Photos are available only when editing Live Photo content in a photo editing extension that runs in the Photos app—see the
PHContent class to access Live Photos in an editing session.
By default, a Live Photo view uses its own gesture recognizer to allow the user to play the motion and sound content of a Live Photo with the same interactions and visual effects seen in the Photos app. To customize this gesture recognizer—for example, to install it on a different view for proper event handling in your app’s view hierarchy—use the
Typically, an app doesn't need to directly control Live Photo playback. In some situations, however, it can be useful to briefly animate the view to indicate to the user that a picture is a Live Photo. To do this, use the
start method with the