I'm currently trying to make a media player for audio. I am currently using candy. I am having a problem setting up a dataSource for a media player. First, here is how I set the dataSource:
public void playSong() { player.reset(); Song selSong = songs.get(songPos); long currSong = selSong.getId();
And Uri comes to this:
Contents: // media / external / audio / media / 22
I did some research, and in my opinion, after Android 4.1, you can no longer use the URI for the dataSource. When I run this application with the above code, I will get this error:
E/MediaPlayer﹕ Unable to create media player E/MUSIC SERVICE﹕ Error setting data source java.io.IOException: setDataSource failed.: status=0x80000000 at android.media.MediaPlayer.nativeSetDataSource(Native Method)
So now I need to convert the URI to the file path and provide this as a dataSource. And, after further research, kitkat seems to have changed the way the URI is provided, so it’s hard to get the file path from the URI. However, I'm not sure if this change has been preserved in Android Lollipop 5.0.2.
Essentially, I have a song URI, but I need to provide something other than a URI in a dataSource. Is there a way I can convert a URI to Lollipop, and if not, how can I provide a dataSource to only know the song id? Thank.
android uri android-5.0-lollipop android-mediaplayer
user2082169 Jan 10 '15 at 17:48 2015-01-10 17:48
source share