Code example for Fragment

Methods: getActivity, checkState

0
 
  /** 
   * 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());
 
    mediaController.setAnchorView(getAudioView());
 
    MediaPlayerControl mediaPlayerControl = new MediaController.MediaPlayerControl() {
      @Override 
      public boolean canPause() { 
        return true; 
      } 
 
      @Override 
      public boolean canSeekBackward() { 
        return true;