title: No Control buttons in mediaplayer show up
body: <p>I'm new to Android and I'm trying to make a really simple app. Its just one activity which contains a MediaPlayer for playing audio or video files.
  I managed to play a song, but it just won't show me the control elements of the media player!</p>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>public class Player extends Activity implements OnPreparedListener,
          MediaPlayerControl {
  
      private static final String TAG = "AudioPlayer";
      public static final String AUDIO_FILE_NAME = "audioFileName";
  
      private String audioFile;
      private MediaPlayer mediaPlayer;
      private Handler handler = new Handler();
      private MediaController mediaController;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_player);
  
  
  
          Uri myUri = Uri.parse("android.resource://com.example.mediaplayer/"
                  + R.raw.lied); // initialize Uri here
          MediaPlayer mediaPlayer = new MediaPlayer();
  
          mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
          mediaController = new MediaController(this);
          try {
              mediaPlayer.setDataSource(getApplicationContext(), myUri);
          } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          try {
              mediaPlayer.prepare();
          } catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          mediaPlayer.start();
  
      }
  
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.player, menu);
          return true;
      }
  
      public void onPrepared(MediaPlayer mediaPlayer) {
          Log.d(TAG, "onPrepared");
          mediaController.setMediaPlayer(this);
          mediaController.setAnchorView(findViewById(R.id.mediaController1));
  
          handler.post(new Runnable() {
              public void run() {
                  mediaController.setEnabled(true);
                  mediaController.show();
              }
          });
      }
  
      protected void onStop() {
          super.onStop();
          mediaPlayer.stop();
          mediaPlayer.release();
      }
  
      public boolean onTouchEvent(MotionEvent event) {
          // the MediaController will hide after 3 seconds - tap the screen to
          // make it appear again
          mediaController.show();
          return false;
      }
  
      public boolean canPause() {
  
          return true;
      }
  
      public boolean canSeekBackward() {
  
          return true;
      }
  
      public boolean canSeekForward() {
  
          return true;
      }
  
      public int getBufferPercentage() {
  
          return 0;
      }
  
      public int getCurrentPosition() {
          return mediaPlayer.getCurrentPosition();
      }
  
      public int getDuration() {
          return mediaPlayer.getDuration();
  
      }
  
      public boolean isPlaying() {
          return mediaPlayer.isPlaying();
  
      }
  
      public void pause() {
          mediaPlayer.pause();
  
      }
  
      public void seekTo(int i) {
          mediaPlayer.seekTo(i);
  
      }
  
      public void start() {
          mediaPlayer.start();
  
      }
  }
  </code></pre>
  
  <p>And here is my Layout XML:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".Player" &gt;
  
      &lt;MediaController
          android:id="@+id/mediaController1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginLeft="122dp"
          android:layout_marginTop="55dp"
          android:visibility="visible" &gt;
  
      &lt;/MediaController&gt;
  
      &lt;VideoView
          android:id="@+id/videoView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>