title: Android SDK: Media Player - Load video stream from HTTP url
body: <p>I have a MediaPlayerActivity with the following code:
  This code basically tries to get a video stream from a http url and load it but for some reason it keeps crashing.</p>
  
  <pre><code>public class MediaPlayerActivity extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          this.setContentView(R.layout.video_player);
          SurfaceView v = (SurfaceView) findViewById(R.id.surface_video); 
          SurfaceHolder holder = v.getHolder(); 
          holder.setFixedSize(400,300); 
  
          MediaPlayer mp = MediaPlayer.create(this, Uri.parse("http://stream-url.com/playlist.m3u8")); 
          mp.setDisplay(holder);
          //mp.setAudioStreamType(2); 
          try {
              //mp.prepare();
              mp.start();
          } catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
  
      }
  
  }
  </code></pre>
  
  <p>video_player.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; 
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  &gt; 
  &lt;SurfaceView android:id="@+id/surface_video" 
  android:layout_width="250px" 
  android:layout_height="250px"&gt; 
  &lt;/SurfaceView&gt; 
  &lt;LinearLayout 
  android:orientation="horizontal" 
  android:layout_height="wrap_content" 
  android:layout_width="fill_parent" 
  android:padding="10dip" 
  &gt; 
  &lt;/LinearLayout&gt; 
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>When I go to this activity using the following code it crashes:</p>
  
  <pre><code>Intent myIntent = new Intent(HomeActivity.this, MediaPlayerActivity.class);
                      HomeActivity.this.startActivity(myIntent);
  </code></pre>
  
  <p>What am I doing wrong?</p>