title: E/MediaPlayer: Error (1,-2147483648) when using emulator
body: <p>I'm making a online radio streaming app for a friend. When I run it on a physical device the stream plays no problem. But if I run it on Android Studio's built-in emulator it gives the following error:</p>
  <pre><code>E/MediaPlayer: Error (1,-2147483648) 
  </code></pre>
  <p>From the research I've done it means just a general error? I've tried adding:</p>
  <pre><code>if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N) {
          player.setAudioAttributes(new AudioAttributes.Builder()
                  .setUsage(AudioAttributes.USAGE_MEDIA)
                  .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                  .build());
      } else {
          player.setAudioStreamType(AudioManager.STREAM_MUSIC);
      }
  </code></pre>
  <p>I've also added the right permissions in the manifest for access to internet. I'm sure this has been answered already but I can't find any answers that fix the problem. Here is the full code I'm using to play the stream:</p>
  <pre><code> private void initializeUIElements(View root) {
  
      playSeekBar = root.findViewById(R.id.progressBar1);
      playSeekBar.setMax(100);
      playSeekBar.setVisibility(View.INVISIBLE);
  
      buttonPlay =  root.findViewById(R.id.buttonPlay);
      buttonPlay.setOnClickListener(this);
  
      buttonStopPlay = root.findViewById(R.id.buttonStopPlay);
      buttonStopPlay.setEnabled(false);
      buttonStopPlay.setOnClickListener(this);
  
  }
  public void onClick(View v) {
      if (v == buttonPlay) {
          startPlaying();
      } else if (v == buttonStopPlay) {
          stopPlaying();
      }
  }
  
  private void startPlaying() {
      buttonStopPlay.setEnabled(true);
      buttonPlay.setEnabled(false);
  
      playSeekBar.setVisibility(View.VISIBLE);
  
  
  
      player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
  
          public void onPrepared(MediaPlayer mp) {
              player.start();
          }
      });
      player.prepareAsync();
  }
  
  private void stopPlaying() {
      if (player.isPlaying()) {
          player.stop();
          player.release();
          initializeMediaPlayer();
      }
  
      buttonPlay.setEnabled(true);
      buttonStopPlay.setEnabled(false);
      playSeekBar.setVisibility(View.INVISIBLE);
  }
  
  private void initializeMediaPlayer() {
      player = new MediaPlayer();
      if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N) {
          player.setAudioAttributes(new AudioAttributes.Builder()
                  .setUsage(AudioAttributes.USAGE_MEDIA)
                  .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                  .build());
      } else {
          player.setAudioStreamType(AudioManager.STREAM_MUSIC);
      }
      try {
          player.setDataSource(&quot;http://s5.citrus3.com:8162/stream&quot;);
      } catch (IllegalArgumentException e) {
          e.printStackTrace();
      } catch (IllegalStateException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      player.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
  
          public void onBufferingUpdate(MediaPlayer mp, int percent) {
              playSeekBar.setSecondaryProgress(percent);
              Log.i(&quot;Buffering&quot;, &quot;&quot; + percent);
          }
      });
  }
  
  @Override
  public void onPause() {
      super.onPause();
      if (player.isPlaying()) {
          player.stop();
      }
  }   
  </code></pre>