can i play a track from SoundCloud in my android app? I\'m trying this code but it doesn\'t works:
String res = \"https://api.soundcloud.com/tracks/84973999
trying adding this before you set data source
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
there have also been issues noted when using MediaPlayer with URL redirects. You may need to resolve the redirects first, then set your datasource accordingly
To get the redirected url you can do soemthing like this using the soundcloud java-api-wrapper
HttpResponse resp = wrapper.get(Request.to(res));
if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
final Header location = resp.getFirstHeader("Location");
if (location != null && location.getValue() != null) {
String redirectedStream = location.getValue();
//...
}
}