Android: AAC+ radio streaming doesn't work with MediaPlayer (Android 4.2.2 / Shoucast links)

longi picture longi · Mar 5, 2013 · Viewed 9.9k times · Source

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 a Proxy, 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!

Answer

Dodge picture Dodge · Mar 13, 2013

i had the same problem for my app.

I played alot with MediaPlayer with no success. I even tested with a proxy inside the app that is used for streaming MP3 Streams on older android versions

and i also tested the aacplayer-android/aacdecoder-android, but it was not very stable in my tests...

We ended up with BASS for Android as we were unable to find.

But it also requires an AAC Patent License* if you want to make the app public (for private use i think it does not care...) also it requires an BASS License unless you are a non-commercial entity.

*) Android Apps count as Consumer Products not as Consumer PC Software... just to avoid the mistake we made for our app...

[UPDATE]
Why are the patent fees required?
One have to pay fees as soon as the Product(in this case the App) brings is own decoder (or encoder) as both, BASS and aacdecoder-android bring thier own decoder code, they required to have an AAC license. Only if it would be possible to use the decoder available on the host system(that is licensed/paid by the developer of the host syste - in this case Google) it is "free". But as it seemsthere is currently no way to acces/use the device codecs...