我想做一个可以播放我记忆卡上所有音乐的音乐播放器。我使用这个代码来播放音乐,但我不能播放存储卡中的音乐,只能在raw文件夹中。
MediaPlayer mp = MediaPlayer.create(this, R.id.raw.audio.mp3)我应该怎么做,才能从SD卡播放音乐?
发布于 2017-06-27 13:58:26
你会想要这样做的
Uri song = Uri.parse(location-of-song); //location-of-song is where the music is on the sd card
mPlayer = new MediaPlayer();
mPlayer.setDataSource(getApplicationContext(), song);
mPlayer.start();发布于 2017-06-26 08:07:48
使用带有URI的create版本,并提供要播放的本地文件的URI。
https://stackoverflow.com/questions/44751405
复制相似问题