[英]How to access photos taken within a camera app in react native expo?
我使用 expo 攝像頭模塊制作了一個攝像頭應用程序,現在我正在嘗試訪問此應用程序中的特定相冊,就像移動原生攝像頭應用程序一樣。 我嘗試按照我看到的一些模糊說明創建一個 function ,但我不知道這是正確的路徑。
//trying to access photos taken through the square
const albumName = "Gryffindor";
async function seePhotos() {
const getTakenPhotos = await MediaLibrary.getAssetsAsync({
first: 20,
album: albumName,
sortBy: ["creationTime"],
});
console.log(getTakenPhotos.assets);
return MediaLibrary.getAssetsAsync.asset.uri;
}
<View style={{ flex: 1, alignItems: "center" }}>
<Icon name="square" size={50} color="white" onPress={seePhotos} />
</View>;
用這個替換上面的代碼
const albumName = "Gryffindor";
const seePhotos = async () => {
try {
const getTakenPhotos = await MediaLibrary.getAssetsAsync({
first: 20,
album: albumName,
sortBy: MediaLibrary.SortBy.creationTime, // Should be written like this
});
console.log(getTakenPhotos.assets); // Check Your console
} catch (error) {
console.log(error); // In case of any error
}
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.