on_audio_query 2.1.2 copy "on_audio_query: ^2.1.2" to clipboard
on_audio_query: ^2.1.2 copied to clipboard

outdated

Flutter Plugin used to query audios/songs infos [title, artist, album, etc..] from device storage.

on_audio_query #

Pub.dev Platforms Languages

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..].

Translations: #

NOTE: Feel free to help with readme translations

Topics: #

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.2

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>

Web:

Since Web Browsers don't offer direct access to their user's file system, this plugin will use the assets folder to "query" the audios files. So, will totally depend of the developer.

  # You don't need add every audio file path, just define the folder.
  assets:
    - assets/
    # If your files are in another folder inside the `assets`:
    - assets/audios/
    # - assets/audios/animals/
    # - assets/audios/animals/cat/
    # ...

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 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 [BG](PlaylistId, AudioId, RequestPermission) bool
removeFromPlaylist (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(); 
  }

LICENSE: #

155
likes
0
pub points
96%
popularity

Publisher

verified publisherlucasjosino.com

Flutter Plugin used to query audios/songs infos [title, artist, album, etc..] from device storage.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, on_audio_query_platform_interface, on_audio_query_web

More

Packages that depend on on_audio_query