0

我用 expo 相机模块制作了一个相机应用程序,我现在正试图访问这个应用程序中的特定相册,就像它发生在移动原生相机应用程序中一样。我尝试按照我看到的一些模糊说明创建一个类似的函数,但我不知道这是正确的路径。

//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>;
4

1 回答 1

0

用这个替换上面的代码

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
  }
};
于 2021-04-11T12:55:51.493 回答