title: Android: Unable to create MediaPlayer
body: <p>I'm trying to run a simple test app to stream music from an online shoutcast radio but I'm always getting an error about MediaPlayer <code>setDataSource()</code> method.. This is the log:</p>
  
  <pre><code>08-26 11:33:42.268  17698-17698/com.example.bruno.radioteste D/MainActivity﹕ Attempt to play http://50.7.98.106:8398
  08-26 11:33:42.268  17698-17698/com.example.bruno.radioteste E/MediaPlayer﹕ Unable to create media player
  08-26 11:33:42.268  17698-17698/com.example.bruno.radioteste W/System.err﹕ java.io.IOException: setDataSource failed.: status=0x80000000
  08-26 11:33:42.278  17698-17698/com.example.bruno.radioteste W/System.err﹕ at android.media.MediaPlayer._setDataSource(Native Method)
  </code></pre>
  
  <p>The code is very simple, and from what I've been searching it should work just fine.. The layout's xml:</p>
  
  <pre><code>&lt;Button
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="BassDrive-http://50.7.98.106:8398"
      android:onClick="play" /&gt;
  </code></pre>
  
  <p>And the activity class:</p>
  
  <pre><code> public class MainActivity extends AppCompatActivity implements MediaPlayer.OnPreparedListener {
  
  private static final String TAG = MainActivity.class.getSimpleName();
  
  private MediaPlayer player;
  private boolean isPlaying = false;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      player = new MediaPlayer();
      player.setOnPreparedListener(this);
      player.setAudioStreamType(AudioManager.STREAM_MUSIC);
  }
  
  public void play(View view) {
  
      if(isPlaying) {
          player.stop();
          isPlaying = false;
      } else {
  
          try {
  
              String stationIp = ((Button)view).getText().toString().split("-")[1];
              Log.d(TAG, "Attempt to play " + stationIp);
              player.setDataSource(stationIp);
              player.prepareAsync();
              isPlaying = true;
  
          } catch(Exception e) {
              e.printStackTrace();
          }
      }
  
  }
  
  @Override
  public void onPrepared(MediaPlayer mp) {
      Log.d(TAG, "Trying to start...");
      mp.start();
  }
  
  @Override
  protected void onStop() {
      super.onStop();
  
      // clear media player
      player.stop();
      player.release();
      player = null;
  }
  </code></pre>