I want to fetch mp3 files from phone storage with specific folder,
Actually am using on_audio_query pkg for this but on_audio_query is fetched all mp3 files in my phone storage.
please anyone guide!
code:
@override
final _onAudioQuery = OnAudioQuery();
final AudioPlayer audioPlayer = AudioPlayer();
void initState() {
requestPermission();
myPath();
super.initState();
}
void requestPermission() {
Permission.storage.request();
}
String? appDocPath;
Future<void> myPath() async {
Directory? appDocDir = await getExternalStorageDirectory();
setState(() {
appDocPath = appDocDir!.path.toString();
print("dir lenght: ${appDocPath}".length.toString());
});
}
@override
Widget build(BuildContext context) {
print("dir: ${appDocPath}".toString());
return Scaffold(
appBar: AppBar(),
body: FutureBuilder<List<SongModel>>(
future: _onAudioQuery.querySongs(
path: appDocPath,
sortType: null,
orderType: OrderType.ASC_OR_SMALLER,
uriType: UriType.EXTERNAL,
ignoreCase: true,
),
............