0

*这里是按钮点击听下载音频 *实际上我想下载一个应用程序目录中的所有音频,我想在媒体播放器中播放音频,所以我的功能下载音频在Android文件夹中,我无法获取所有音频列表,,需要帮助,请查看 其音频路径,下载的音频存储在哪里

             @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();

        }
4

0 回答 0