Skip to main content
Glama
live-photo.md2.37 kB
--- title: LivePhoto description: A library that allows displaying Live Photos on iOS. sourceCodeUrl: https://github.com/expo/expo/tree/sdk-52/packages/expo-live-photo packageName: expo-live-photo platforms: ["ios"] isNew: true --- ## Installation ## Usage Here's a simple example of `expo-live-photo` usage combined with `expo-image-picker`. ```tsx const viewRef = useRef<LivePhotoViewType>(null); const [livePhoto, setLivePhoto] = useState<LivePhotoAsset | null>(null); const pickImage = async () => { const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ['livePhotos'], }); if (!result.canceled && result.assets[0].pairedVideoAsset?.uri) { setLivePhoto({ photoUri: result.assets[0].uri, pairedVideoUri: result.assets[0].pairedVideoAsset.uri, }); } else { console.error('Failed to pick a live photo'); } }; if (!LivePhotoView.isAvailable()) { return ( <View style={styles.container}> <Text>expo-live-photo is not available on this platform 😕</Text> </View> ); } return ( <View style={styles.container}> <LivePhotoView ref={viewRef} source={livePhoto} style={[styles.livePhotoView, { display: livePhoto ? 'flex' : 'none' }]} onLoadComplete={() => { console.log('Live photo loaded successfully!'); }} onLoadError={error => { console.error('Failed to load the live photo: ', error.message); }} /> <View style={livePhoto ? styles.pickImageCollapsed : styles.pickImageExpanded}> </View> <Button title="Start Playback Hint" onPress={() => viewRef.current?.startPlayback('hint')} /> <Button title="Start Playback" onPress={() => viewRef.current?.startPlayback('full')} /> <Button title="Stop Playback" onPress={() => viewRef.current?.stopPlayback()} /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', paddingVertical: 20, paddingHorizontal: 40, }, livePhotoView: { alignSelf: 'stretch', height: 300, }, pickImageExpanded: { alignSelf: 'stretch', height: 300, justifyContent: 'center', }, pickImageCollapsed: { marginVertical: 10, }, button: { marginVertical: 10, }, }); ``` ## API ```js ```

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jaksm/expo-docs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server