问题描述
*这里是点击收听下载音频的按钮 *实际上我想在一个应用程序目录中下载所有音频,我想在媒体播放器中播放这些音频,所以我的功能在 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 (将#修改为@)