Flutter Audio Query는 개발자가 장치 저장소에서 미디어 메타데이터에 액세스하고 검색할 수 있도록 해주는 Flutter 플러그인입니다. 아티스트, 앨범, 곡, 장르 및 재생목록과 같은 정보를 포함합니다. 이 플러그인은 장치의 음악 라이브러리를 쿼리할 수 있는 간단한 API를 제공하여 음악 플레이어 애플리케이션 또는 미디어 관리 도구 개발에 이상적입니다. 플러그인은 여러 플랫폼에서 작동하지만 특정 플랫폼 지원은 다를 수 있습니다. 복잡한 네이티브 코드 없이도 네이티브 오디오 데이터 소스와의 통합을 간편하게 만듭니다.
사용 사례
음악 플레이어 앱 만들기
미디어 라이브러리 인터페이스 만들기
노래 메타데이터 가져오기
아티스트 및 앨범 세부 정보 표시
사용자 플레이리스트 관리
주요 기능
기기 음악 라이브러리에 대한 액세스
아티스트, 앨범, 곡, 장르, 플레이리스트 지원
간단하고 일관된 API
크로스 플랫폼 호환성
효율적인 데이터 검색
적합한 대상
음악 애플리케이션 개발자
미디어 라이브러리 빌더
오디오 콘텐츠 관리자
Flutter 초보자가 미디어 기능 탐색 중
오프라인 음악 메타데이터가 필요한 앱
고려 사항
플랫폼별 제한 사항이 적용될 수 있습니다
Android 및 iOS에서 적절한 권한이 필요합니다
장치에 저장된 미디어로 제한
미디어 변경에 대한 실시간 업데이트 없음
장치의 미디어 데이터베이스 일관성에 따라 다릅니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter Audio Query
A Flutter plugin, Android only at this moment, that allows you query for audio metadata info about artists, albums, songs audio files and genres available on device storage. All work is made using Android native MediaStore API with ContentResolver API and query methods run in background thread. AndroidX support it's OK!
Note: This plugin is under development, Works in Android devices only and some APIs are not available yet. Feedback, pull request, bug reports and suggestions are all welcome!
Feel free to help!
Example app included
|
|
|
|
Features
Android permissions READ_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE built-in
Get all artists audio info available on device storage
Get artists available from a specific genre
Search for artists matching a name
Artist comes with some album Artwork cover if available
Get all albums info available on device storage
Get albums available from a specific artist
Get albums available from a specific genre
Search albums matching a name
Album artwork included if available
Get songs all songs available on device storage
Get songs from a specific album
Songs already comes with album artwork cover if available
Get availables genre.
Get all playlists available
Create new playlists
Remove playlist
Add songs to playlist
Remove song from playlist
Multiple sort types for Artist, Album, Song, Genre, Playlist.
To get get audio files metadata info you just need FlutterAudioQuery object instance.
///you need include this file only.import'package:flutter_audio_query/flutter_audio_query.dart';
/// create a FlutterAudioQuery instance.finalFlutterAudioQuery audioQuery = FlutterAudioQuery();
Getting all artist available on device storage:
List<ArtistInfo> artists = await audioQuery.getArtists(); // returns all artists available
artists.forEach( (artist){
print(artist); /// prints all artist property values
} );
Getting albums data:
/// getting all albums available on device storageList<AlbumInfo> albumList = await audioQuery.getAlbums();
/// getting all albums available from a specific artistList<AlbumInfo> albums = await audioQuery.getAlbumsFromArtist(artist: artist.name);
albums.forEach( (artistAlbum) {
print(artistAlbum); //print all album property values
});
Getting artwork on Android >= Q:
Since Android API level 29 ALBUM_ART constant is deprecated and plus
scoped storage approach we can't load artwork from absolute image path.
So if your app is running over Android API >= 29 you will get all artwork fields with null. To fetch images on these API levels you can use getArwork method.
/// detecting, loading and displaying an artist artwork.ArtistInfo artist // assuming a non null instance// check if artistArtPath isn't available.
(artist.artistArtPath == null)
? FutureBuilder<Uint8List>(
future: audioQuery.getArtwork(
type: ResourceType.ARTIST, id: artist.id),
builder: (_, snapshot) {
if (snapshot.data == null)
returnContainer(
height: 250.0,
child: Center(
child: CircularProgressIndicator(),
),
);
returnCardItemWidget(
height: 250.0,
title: artist.name,
subtitle: "Number of Albums: ${artist.numberOfAlbums}",
infoText: "Number of Songs: ${artist.numberOfTracks}",
// The image bytes// You can use Image.memory widget constructor // or MemoryImage image provider class to load image from bytes// or a different approach.
rawImage: snapshot.data,
);
}) :
// or you can load image from File path if available.Image.file( File( artist.artistArtPath ) )
Getting genre data
/// getting all genres availableList<GenreInfo> genreList = audioQuery.getGenres();
genreList.foreach( (genre){
/// getting all artists available from specific genre.await audioQuery.getArtistsFromGenre(genre: genre.name);
/// getting all albums which appears on genre [genre].await audioQuery.getAlbumsFromGenre(genre: genre.name);
/// getting all songs which appears on genre [genre]await audioQuery.getSongsFromGenre(genre: genre.name);
} );
Getting songs data
/// getting all songs available on device storageList<SongInfo> songs = await audioQuery.getSongs();
albumList.foreach( (album){
/// getting songs from specific album
audioQuery.getSongsFromAlbum(album: album.name);
} );
Getting playlist data
/// getting all playlist availableList<PlaylistInfo> playlist = await audioQuery.getPlaylists();
/// Getting playlist songsList<SongInfo> songs = await audioQuery.getSongsFromPlaylist(playlist: playlist[0]);
/// adding songs into a specific playlistPlaylistInfo updatedPlaylist = await playlist[0].addSong(song: songs[2] );
//removing song from a specific playlist
updatedPlaylist = await updatedPlaylist.removeSong(song: songs[2]);
Sorting queries
You can also define a sort query constraint to get the data already sorted using sort enums.ArtistSortType, AlbumSortType, SongSortType, GenreSortType, PlaylistSortType.
/// Getting albums sorted by most recent year first
audioQuery.getAlbums(sortType: AlbumSortType.MOST_RECENT_YEAR )
/// getting artists sorted by number of songs
audioQuery.getArtits(sortType: ArtistSortType.MORE_TRACKS_NUMBER_FIRST);
/// and more...
Searching
You can search using search methods.
///searching for albums that title starts with 'a'List<AlbumInfo> albums = await audioQuery.searchAlbums(query "a");
/// searching for songs that title starts with 'la'List<SongInfo> songs = await audioQuery.searchSongs(query: "la");
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.