title: Exit YoutubePlayer full-screen on YouTube API V3 programatically
body: <p>The question basically explains itself.</p>
  
  <p>I have tried player.setFullscreen(false);</p>
  
  <p>That does nothing but call the OnFullscreen method in OnFullscreenListener</p>
  
  <p><a href="https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayer#setFullscreen(boolean)" rel="nofollow">https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayer#setFullscreen(boolean)</a></p>
  
  <p>I think they did not implement a way for you to close it without user interaction otherwise it would've been obvious. (Just making sure)</p>
  
  <p>If you wonder why I need it, its because I want to exit fullscreen player when user presses the back button. Another issue is that I disabled landscape so it will not automatically switch to normal view when you return to portrait.</p>
  
  <p>Maybe I could programatically make it so it seems like I switch to landscape but in reality I dont, just to fool the player?</p>
  
  <p>Any solutions or ideas appreciated. Thanks.</p>
  
  <hr>
  
  <p>Here is some parts of my activity that are relevant:</p>
  
  <pre><code>Override
  public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
      if (groupPosition == 2) {
          String videoId = episodeList.get(childPosition).getYoutubeId();
          if (this.currentVideoId == null) {
              currentVideoId = videoId;
              currentFragment = YoutubeVideoFragment.newInstance(videoId);
              getSupportFragmentManager().beginTransaction().replace(R.id.youtube_video_area, currentFragment).commit();
              showVideoFragment();
          }
          else if (!this.currentVideoId.equals(videoId)) {
              cleanupRetainInstanceFragment();
              currentFragment = YoutubeVideoFragment.newInstance(videoId);
              getSupportFragmentManager().beginTransaction().replace(R.id.youtube_video_area, currentFragment).commit();
          }
          else
              toggleVideoFragment();
          return true;
      }
      else
          return false;
  }
  
  
  public void cleanupRetainInstanceFragment() {
      getSupportFragmentManager().beginTransaction().remove(this.currentFragment).commit();
      youtubePlayer.release();
      youtubePlayer = null;
  }
  
  @Override
  public void onBackPressed() {
      if (videoFullscreen) {
          youtubePlayer.pause();
          youtubePlayer.setFullscreen(false);
      }
      else
          super.onBackPressed();
  }
  
  @Override
  public void onVideoFragmentAttachSuccess(YouTubePlayer youTubePlayer) {       
      //here I get the youtubePlayer instance with a listener interface set up in my fragment. It works correctly.
      this.youtubePlayer = youTubePlayer;
  
  }
  </code></pre>