I'm recently faced with some problems of streaming AAC+ radio streams with the Android MediaPlayer
. Regarding to the documentation, there should be support for streaming AAC+ in Android 4.1. (Test Device is a Nexus 2 with Android 4.2.2)
I found some related questions (check here, here or here), but they are mainly related to older Android versions or dated before the release of 4.1. I found the AACPlayerAndroid libary, but there you must purchase for a license..
If I try streaming an AACPlus Stream, the MediaPlayer throws MediaPlayerError (1,-2147483648)
, which is defined as "unsupported media format". However, if I start the same AAC+ Stream in Emulator, it is working fine!
What I tried so far:
trying same code in emulator works?!? (whyever.. maybe codec supported at local machine?)
testing two other devices with 4.1 or 4.2 fails as well
set AAC+ stream with manual header and with
setDataSource(String path)
, which doesn't work (changing http header also fails)set up a new SimpleMediaPlayer project -> fails too
trying to check network traffic, if android device is redirected to a wrong url. Actually I got the device connected with
Charles
using aProxy
, but was only able to monitor the Android Browser. Still I think that the redirect is correct!
Here is my implementation of the setDataSource of my Streaming.class
public AmplifyMediaPlayer(PlayerStationObject playerStationObject, Context context) {
super();
this.setAudioStreamType(AudioManager.STREAM_MUSIC);
this.mCurrentStationObject = playerStationObject;
try {
//AAC+ TestStream #1: NOT WORKING
//Uri uri = Uri.parse("http://up-gc2.webnow.com.br/alpha.aac");
//AAC+ TestStream #2: NOT WORKING
//Audio codec: 64 kbit/s 44.1 kHz AAC+, 128 kbit/s 44.1 kHz MP3
//Uri uri = Uri.parse("http://relay.publicdomainproject.org:80/jazz_swing.aac ");
//Setting HTTP header for fixing some issues with normal setDataSource Header from Android
//User-Agent "iTunes" was set to force re-direct to shoutcast streaming url
Map<String, String> headers = new HashMap<String, String>();
headers.put("User-Agent", "iTunes");
setDataSource(context, uri, headers);
//AAC Codec works fine...
//setDataSource("http://fri.net.pl:8000/fri");
prepareAsync();
//...
So actually I'm having following questions:
Why am I not able to play an ACC+ Stream on Android 4.1 and higher, even if they should be supported?
Does anyone have an ACC+ Stream, which he successfully stream with the MediaPlayer Class from Android? (just to check, if there's be something with my player-integration)
If ACC+ is not supported, do you know a good libary or an example project to look, how they solved the issue?
Thanks or any suggestions or advices!
Other AAC+ Streams I tested: http://jam-aacp.rautemusik.fm
EDIT So far, I ended up with: it's not possible. The AACP-Decoder Library is a good solution, but it is not stable yet. Hope Android will support this soon. If you disagree, PLEASE COMMENT!