title: Android: AAC+ radio streaming doesn't work with MediaPlayer (Android 4.2.2 / Shoucast links)
body: <p>I'm recently faced with some problems of <strong>streaming AAC+</strong> radio streams with the Android <code>MediaPlayer</code>. <a href="http://developer.android.com/guide/appendix/media-formats.html#core" rel="nofollow noreferrer">Regarding to the documentation</a>, there should be support for streaming AAC+ in Android 4.1. (Test Device is a Nexus 2 with Android 4.2.2)</p>
  
  <p>I found some related questions (check <a href="https://stackoverflow.com/questions/8166072/android-http-live-streaming-url-using-mediaplayer">here</a>, <a href="https://stackoverflow.com/questions/8671479/android-mediaplayer-works-fine-in-custom-audio-streaming-application-up-to-andro/8833346#8833346">here</a> or <a href="https://stackoverflow.com/questions/9850328/android-how-can-i-play-shoutcast-aac-aac-mp3-in-mediaplayer-for-android-2-3-a">here</a>), but they are mainly related to older Android versions or dated before the release of 4.1. I found the <a href="http://code.google.com/p/aacplayer-android/" rel="nofollow noreferrer">AACPlayerAndroid</a> libary, but there  you must purchase for a license..</p>
  
  <p>If I try streaming an AACPlus Stream, the MediaPlayer throws <code>MediaPlayerError (1,-2147483648)</code>, which is defined as "unsupported media format". However, if I start the same AAC+ Stream in Emulator, it is working fine!</p>
  
  <p>What I tried so far:</p>
  
  <ul>
  <li><p>trying same code in emulator works?!? (whyever.. maybe codec supported at local machine?)</p></li>
  <li><p>testing two other devices with 4.1 or 4.2 fails as well</p></li>
  <li><p>set AAC+ stream with manual header and with <code>setDataSource(String path)</code>, which doesn't work (changing http header also fails)</p></li>
  <li><p>set up a new SimpleMediaPlayer project -> fails too</p></li>
  <li><p>trying to check network traffic, if android device is redirected to a wrong url. Actually  I got the device connected with <code>Charles</code> using a <code>Proxy</code>, but was only able to monitor the Android Browser. Still I think that the redirect is correct!</p></li>
  </ul>
  
  <p>Here is my implementation of the setDataSource of my Streaming.class</p>
  
  <pre><code>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&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
          headers.put("User-Agent", "iTunes");
  
          setDataSource(context, uri, headers);
  
          //AAC Codec works fine...
          //setDataSource("http://fri.net.pl:8000/fri");
  
          prepareAsync();
  
          //...
  </code></pre>
  
  <p>So actually I'm having following questions:</p>
  
  <p>Why am I not able to play an ACC+ Stream on Android 4.1 and higher, even if they should be supported?</p>
  
  <p>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)</p>
  
  <p>If ACC+ is not supported, do you know a good libary or an example project to look, how they solved the issue?</p>
  
  <p>Thanks or any suggestions or advices!</p>
  
  <p>Other AAC+ Streams I tested: <a href="http://jam-aacp.rautemusik.fm" rel="nofollow noreferrer">http://jam-aacp.rautemusik.fm</a> </p>
  
  <p><strong>EDIT</strong>
  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, <strong>PLEASE COMMENT</strong>!</p>