Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

on_audio_query

on_audio_query is a flutter plugin used to query audios/songs infos [title, artist, album, etc..] from device storage.

help:

any problem? issues

any suggestion? pull request

extensions:

  • on_audio_room – used to store audio [favorites, most played, etc..].

gif examples:

songs albums playlists artists

platforms:

methods android ios web
querysongs ✔️ ✔️ ✔️
queryalbums ✔️ ✔️ ✔️
queryartists ✔️ ✔️ ✔️
queryplaylists ✔️ ✔️
querygenres ✔️ ✔️ ✔️
queryaudiosfrom ✔️ ✔️ ✔️
querywithfilters ✔️ ✔️ ✔️
queryartwork ✔️ ✔️ ✔️
createplaylist ✔️ ✔️
removeplaylist ✔️
addtoplaylist ✔️ ✔️
removefromplaylist ✔️
renameplaylist ✔️
moveitemto ✔️
permissionsrequest ✔️ ✔️
permissionsstatus ✔️ ✔️
querydeviceinfo ✔️ ✔️ ✔️

✔️ -> supported

❌ -> not supported

see all platforms methods support

how to install:

add the following code to your pubspec.yaml:

dependencies:
  on_audio_query: ^2.1.0

request permission:

android:

to use this plugin add the following code to your androidmanifest.xml

<manifest> ...

  <uses-permission android:name="android.permission.read_external_storage"/>
  <uses-permission android:name="android.permission.write_external_storage"/>

</manifest>

ios:

to use this plugin add the following code to your info.plist

	<key>nsapplemusicusagedescription</key>
	<string>..add a reason..</string>

some features:

  • optional and built-in storage read and write permission request
  • get all audios/songs.
  • get all albums and album-specific audios.
  • get all artists and artist-specific audios.
  • get all playlists and playlists-specific audios.
  • get all genres and genres-specific audios.
  • get all query methods with specific keys [search].
  • create/delete/rename playlists.
  • add/remove/move specific audios to playlists.
  • specific sort types for all query methods.

todo:

  • add better performance for all plugin.
  • add support to web/windows/macos/linux.
  • option to remove songs.
  • fix bugs.

how to use:

onaudioquery() // the main method to start using the plugin.

all types of methods on this plugin:

query methods

methods parameters return
querysongs (sorttype, ordertype, uritype, requestpermission) list<songmodel>
queryalbums (sorttype, ordertype, uritype, requestpermission) list<albummodel>
queryartists (sorttype, ordertype, uritype, requestpermission) list<artistmodel>
queryplaylists (sorttype, ordertype, uritype, requestpermission) list<playlistmodel>
querygenres (sorttype, ordertype, uritype, requestpermission) list<genremodel>
queryaudiosfrom (type, where, requestpermission) list<songmodel>
querywithfilters (argsval, withfilterstype, args, requestpermission) list<dynamic>
queryartwork (id, type, format, size, requestpermission) uint8list?

playlist methods

methods parameters return
createplaylist (playlistname, requestpermission) bool
removeplaylist (playlistid, requestpermission) bool
addtoplaylist [nt-bg](playlistid, audioid, requestpermission) bool
removefromplaylist [nt](playlistid, audioid, requestpermission) bool
renameplaylist (playlistid, newname, requestpermission) bool
moveitemto [nt](playlistid, from, to, requestpermission) bool

permissions/device methods

methods parameters return
permissionsrequest (retryrequest) bool
permissionsstatus bool
querydeviceinfo devicemodel

artwork widget

now [queryartworkwidget] support all android versions.

  widget someothername() async {
    return queryartworkwidget(
      id: songid, 
      type: artworktype.audio,
    );
  }

see more: queryartworkwidget

abbreviations

[nt] -> need tests

[bg] -> bug on android 10/q

examples:

querysongs

  somename() async {
    // default: 
    // songsorttype.title, 
    // ordertype.asc_or_smaller,
    // uritype.external, 
    list<songmodel> something = await onaudioquery().querysongs();
  }

queryalbums

  somename() async {
    // default: 
    // albumsorttype.album, 
    // ordertype.asc_or_smaller 
    list<albummodel> something = await onaudioquery().queryalbums();
  }

queryartists

  somename() async {
    // default: 
    // artistsorttype.artist, 
    // ordertype.asc_or_smaller 
    list<artistmodel> something = await onaudioquery().queryartists();
  }

queryplaylists

  somename() async {
    // default: 
    // playlistsorttype.name, 
    // ordertype.asc_or_smaller 
    list<playlistmodel> something = await onaudioquery().queryplaylists();
  }

querygenres

  somename() async {
    // default: 
    // genresorttype.name, 
    // ordertype.asc_or_smaller 
    list<genremodel> something = await onaudioquery().querygenres();
  }

queryartwork

note: only works in android >= q/10

  somename() async {
    // default: artworkformat.jpeg, 200 and false
    uint8list something = await onaudioquery().queryartwork(
        songid, 
        artworktype.audio, 
        ...,
      );
  }

or you can use a basic and custom widget.
see example queryartworkwidget

querywithfilters

  somename() async {
    // default: args.title and false
    // argstypes: audiosargs, albumsargs, playlistsargs, artistsargs, genresargs
    list<dynamic> something = await onaudioquery().querywithfilters(
        "sam smith", 
        withfilterstype.artists,
      );

    // after getting the result from [querywithfilters], convert this list using:
    list<typemodel> convertedlist = something.totypemodel();

    // example:
    list<songmodel> convertedsongs = something.toartistmodel(); 
  }

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.