Code example for Fragment

Methods: getActivity, checkState

   * Creates the controller (play, pause, rewind etc controls) for the player. 
  private void createMediaController() { 
    checkState(mediaPlayer != null,
        "media player must be initialized before the media controller"); 
    mediaController = new MediaController(getActivity());
    MediaPlayerControl mediaPlayerControl = new MediaController.MediaPlayerControl() {
      public boolean canPause() { 
        return true; 
      public boolean canSeekBackward() { 
Connect your IDE to all the code out there  Get Codota for Java