【问题标题】:How to get the full path Mp3 songs from internal storage?如何从内部存储中获取完整路径的 Mp3 歌曲?
【发布时间】:2017-05-12 04:49:56
【问题描述】:

我想实现一个简单的媒体播放器。如何从 android 的内部存储中检索 Mp3 歌曲的完整路径。

【问题讨论】:

  • 你有什么努力吗?

标签: android


【解决方案1】:
mpintro = MediaPlayer.create(this, Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/Music/intro.mp3"));
mpintro.setLooping(true);
        mpintro.start();

【讨论】:

    【解决方案2】:

    如果您有任何问题,请先搜索。努力你会发现的... 这是一个链接试试吧Get Mp3 from SD card

    【讨论】:

    • @Shashank Verma 我想从设备内部存储而不是从 SD 卡中获取文件路径。
    【解决方案3】:

    试试这个检查文件是否存在

      public static String rootPath = Environment.getExternalStorageDirectory() + "/YourDirectory/";       
    
     File file = new File(Environment.getExternalStorageDirectory()
                + "/YourDirectoryFolder/Audio/" + NmaeofFile + "/");
        if (!file.exists())
            return false;
        else{
            //Do your work here
             }
    

    然后只需启动媒体播放器

    player.setDataSource(rootPath);//rootpath is the path of your file
                player.prepare();
                player.start();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 2010-10-29
      • 2018-04-13
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多