Reputation: 3485
I want to be able to play an mp3 file in my android application given a url (e.g. http://www.somedomain.com/audio.mp3).
This I think should be used to get a byte array using an InputStream maybe but I'm not totally sure, which then can be used with a MediaPlayer object.
Upvotes: 0
Views: 1530
Reputation: 1379
I found in practical life that the MediaPlayer can play just about any MP3 URL if you take care to reformat any Space characters (0x20) into "%20". I tried that URLEncoder and some other filters to little gain but simply converting those spaces before presenting the URL to MediaPlayer will take you far.
In a String you can easily substitute stuff:
mediaPlayer.setDataSource(urlString.replace(" ", "%20"));
Upvotes: 0