Anas Ikhlas
Anas Ikhlas

Reputation: 117

Expo MediaLibrary.getAssetsAsync({album:album}) is not returning album - React Native

I am using Expo MediaLibrary to get videos from a specific folder and I am facing this problem.

MediaLibrary.getAssetsAsync() shows there are no media inside an album. while there are media inside the folder.

Code:

  let album = await MediaLibrary.getAlbumAsync("GrabTube")
  console.log(album )
  let assets = await MediaLibrary.getAssetsAsync({album:album })
  console.log(assets)

response:

Object {
  "assetCount": 1,
  "id": "876214992",
  "title": "GrabTube",
}
Object {
  "assets": Array [],
  "endCursor": "0",
  "hasNextPage": false,
  "totalCount": 0,
}

In the first console.log, it shows there is one item/asset inside the folder. But as shown inside the second console.log it shows the folder is empty.

Is there any fix for this?

Upvotes: 1

Views: 1552

Answers (1)

Vinícius
Vinícius

Reputation: 51

For some reason it's necessary to define the mediaType even when you have already defined the album...

to me the solution was change from :

let assets = await MediaLibrary.getAssetsAsync({album:album })

to:

let assets = await MediaLibrary.getAssetsAsync({album:album, mediaType:'audio' })

Upvotes: 2

Related Questions