API Reference
Functions
Audio
getAssets

getAssets(assetConfig: AssetConfig)

This is a function which return the assets(images/audios/videos) based on the mediaType provided.

interface AssetConfig {
  limit?: number;
  offset?: number;
  mediaType?: string;
  palette?: boolean;
}
ℹ️

All properties are optional. Can be called as getAssets({})

limit

  • Number of assets that will be fetched getAssets({limit: 70}).
  • This is optional getAssets({}).
  • Provide 0 to fetch all the available assets getAssets({limit: 0}).
  • Default value - 50

offset

  • Number of assets to skip from the start (or) Number from where assets will start fetching getAssets({offset: 70}).
  • This is optional getAssets({}).
  • Default value - 0

mediaType

  • The type of asset that will be fetched.
  • Possible values are audio, image, video.
  • Default value - audio

palette

  • Whether to get palette in the data or not. More details about this is present in returns section.
  • Including this will increase the read time by a small amount based on the number of audio files on the device.

Examples: Let's say there are 10 assets.

questionFunction call
Fetch first 7 assets(asset1 to asset 7)?getAssets({limit: 7})
Fetch last 3 assets(asset8 to asset10)?getAssets({limit: 3, offset: 7})
Fetch all the assetsgetAssets({limit: 0})
Default casegetAssets({})

Summary

propertyDescription
limitNumber of songs that will be fetched.
offsetNumber from where assets will start fetching.
mediaTypeMediatype that will be fetched.

Returns:

interface Assets {
  assets: Array<Asset>;
  totalCount: number;
  endCursor: number;
  hasNextPage: boolean;
}

assets

  • An array of objects, like array of image/audio/video files according the give mediaType.
propertyDescription
totalCountTotal count of image/audio/video files available on the device.
endCursor
  • This the last number in the assets that are fetched.
  • If you are fetching 50 assets per batch, endCursor value will be 50 for the first batch, will be 100 for the second and so on...
hasNextPage
  • This indicates, do we have more assets to fetch or not, according to the limit and offset values given.
  • false indicates, there are no assets to fetch i.e all the available assets are fetched.

Audio

interface Asset {
  _id: string;
  title: string;
  displayName: string;
  artist: string;
  duration: string;
  album: string;
  path: string;
  uri: string;
  artwork: string;
  artwork2: string;
  palette?: Array<string>;
}
propertyDescription
_idid of the audio.
titletitle of the audio. This will not have extension of the audio in it.
displayNamedisplayName of the audio. This will have extension of the audio in it.
artistartist of the audio.
durationduration of the audio in milliseconds.
albumalbum of the audio to which it belongs to.
pathpath of the audio.
uricontent uri of the audio.
artworkartwork uri of the audio.
artwork2another artwork uri of the audio, in case if artwork uri doesn't work.
mimeTypemimeType of the audio.
palette
  • This is an array of 2 colors out of which one is light(1st color) shade and the other is dark(2nd color) shade
  • The colors are picked from the artwork image of the audio file.
  • This can be used as background color for playing now screen.