A library that provides access to Picture In Picture API for Android only.
expo-pip is not available in Expo Go, learn more about development builds.
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
npx expo install expo-pip
import * as ExpoPip from "expo-pip";
import { useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
export default function App() {
const { isInPipMode } = ExpoPip.useIsInPip();
const [automaticEnterEnabled, setAutomaticEnterEnabled] = useState(false);
return (
<View style={styles.container}>
<Text>{isInPipMode ? "In Pip Mode 😎" : "Not In Pip Mode"}</Text>
{!isInPipMode && (
<>
<Button
onPress={() =>
ExpoPip.enterPipMode({
width: 200,
height: 300,
})
}
title="Go to Picture In Picture Mode"
/>
<Button
onPress={() => {
const newValue = !automaticEnterEnabled;
setAutomaticEnterEnabled(newValue);
ExpoPip.setAutoEnterEnabled(newValue);
}}
title={`Toggle automaticEnter: ${automaticEnterEnabled ? "on" : "off"}`}
/>
</>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
import * as ExpoPip from "expo-pip";
const { isInPipMode } = ExpoPip.useIsInPip();
ExpoPip.setAutoEnterEnabled(true);
ExpoPip.setAspectRatio({ width: 200, height: 300 });
ExpoPip.enterPipMode({ width: 200, height: 300 });
Params are opcional. Defaults values are 200 width and 300 height.
Contributions are very welcome! Please refer to guidelines described in the contributing guide.