Reputation: 4709
i'm using the code in the documentation of the MediaPlayer;
String url = "http://........"; // your URL here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare(); // might take long! (for buffering, etc)
mediaPlayer.start();
The path of the soundcloud mp3 is something like this;
https://api.soundcloud.com/tracks/41262720/stream?consumer_key=XXXXXX
In the preperation line i have this error;
prepare failed. status=0x1
I test it with a different source and it works fine;
http://www.colorado.edu/AmStudies/lewis/Design/blue.mp3
What is the problem with the soundcloud sources? Do i need an extra configuration for media player?
Note: i'm using the emulator with the 2.2 SDK
Upvotes: 1
Views: 5125
Reputation: 3453
The media player (at least older versions) has problems with https urls. You'll need to manually resolve the url (issue a GET request and check the redirect), then give the result to MediaPlayer. There are a lot of other issues with the MediaPlayer though, it's not straightforward to get it to work.
Upvotes: 2