问题描述
有没有打通过使用媒体播放器从MediaStore获得音频的方式,还是我完全错误的方向前进?我看着和MediaStore.Audio到目前为止,但没有什么是真正帮助我。我只需要知道如果我在正确的轨道上。
Is there a way to play audio obtained from MediaStore through the use of the MediaPLayer, Or am I going in the completely wrong direction? I've looked and MediaStore.Audio so far but nothing is really helping me. I just need to know if I'm on the right track
推荐答案
首先,我假设你有一个查询的ContentProvider和使用游标的基本知识。如果你不,我建议你研究它
First, I assume you have basic knowledge of querying a ContentProvider and working with Cursors. If you dont, I suggest you research it here
一旦你如何使用ContentProvider的,查询URI MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
的列音频的基本知识。 Media.DATA
,以及任何你需要的其他领域。
Once you have a basic knowledge of how to use a ContentProvider, query the URI MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
for the column Audio.Media.DATA
, along with any other fields you need.
假设你把返回光标 yourCursor
String path = yourCursor.getString(getColumnIndex(Audio.Media.DATA));
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(path);
mp.prepare();
mp.start();
这是一个非常基本实现。如果你需要得到看中它获得舒适与Android文档。
That's a very basic implementation. Get comfy with the android docs if you need to get fancy with it.
这篇关于从MediaStore对媒体播放器的Android音频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!