如何解决如何从应用程序目录在 android 文件夹内获取 Arraylist 中的所有音频
*这里是点击收听下载音频的按钮 *实际上我想在一个应用程序目录中下载所有音频,我想在媒体播放器中播放这些音频,所以我的功能在 Android 文件夹中下载音频,但我无法获取列表中的所有音频,请需要帮助 its audio path,where downloaded audio stored
@Override
public void onClick(View v) {
String url="https://firebasestorage.googleapis.com/v0/b/holly-quran-app-data.appspot.com/o/HOLY%20QURAN%20DATA%2FHOLY%20QURAN%20URDU%20TRANSLATION%2F001s-fatiha.mp3?alt=media&token=b395e953-39de-4870-b143-fc6b7647911d";
beginDownload(url);
}
}); ```
===================================================================================
>here is Doanload function
====================================================================================
``` private void beginDownload(String url) {
File file=new File(getExternalFilesDir(null),"audiosss-1.mp3");
//checking if android version is equal and greater than noughat
//Now if download complete file not visible Now lets show it
DownloadManager.Request request=null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
request=new DownloadManager.Request(Uri.parse(url))
.setTitle("Dummy")
.setDescription("Downloading")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
.setDestinationUri(Uri.fromFile(file))
.setRequiresCharging(false)
.setAllowedOverMetered(true)
.setAllowedOverRoaming(true);
}
else{
request=new DownloadManager.Request(Uri.parse(url))
.setTitle("Dummy")
.setDescription("Downloading")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
.setDestinationUri(Uri.fromFile(file))
.setAllowedOverRoaming(true);
}
DownloadManager downloadManager=(DownloadManager)getSystemService(DOWNLOAD_SERVICE);
final long downloadId=downloadManager.enqueue(request);
} ```
=====================================================================================
// here is access download audio files function..i want to put all audios from this folder in a list.
======================================================================================
``` private void accessFile() {
File file=new File(getExternalFilesDir(null),"audiosss-1.mp3");
if (file.exists()){
Toast.makeText(this,"exist",Toast.LENGTH_SHORT).show();
MediaPlayer mp = new MediaPlayer();
Uri uri=Uri.fromFile(file);
try {
mp.setDataSource(this,uri);
mp.prepare();
mp.start();
} catch (Exception e) {
e.printstacktrace();
}
}else {
Toast.makeText(this,"NOT exist",Toast.LENGTH_SHORT).show();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。