title: Pausing youtube video after 1-2 seconds
body: <p>I am using an Youtube Player api for playing youtube videos in my application. Video start playing and pausing after 1-2 seconds</p>
  
  <p>I created Video Fragment and ViewGroup. Subsequently I create some youtobe videoview.</p>
  
  <p>VideoFragment</p>
  
  <pre><code>public static final class VideoFragment extends YouTubePlayerSupportFragment implements
          OnInitializedListener
  {
  
      private YouTubePlayer player;
      private String videoId;
  
      public static VideoFragment newInstance()
      {
          return new VideoFragment();
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
  
          initialize(Constants.DEVELOPER_KEY, this);
      }
  
      @Override
      public void onDestroy()
      {
          if (player != null)
          {
              player.release();
          }
          super.onDestroy();
      }
  
      public void setVideoId(String videoId)
      {
          if (videoId != null &amp;&amp; !videoId.equals(this.videoId))
          {
              this.videoId = videoId;
              if (player != null)
              {
                  player.cueVideo(videoId);
              }
          }
      }
  
      public void pause()
      {
          if (player != null)
          {
              player.pause();
          }
      }
  
      @Override
      public void onInitializationSuccess(Provider provider, YouTubePlayer player,
              boolean restored)
      {
          this.player = player;
          if (!restored &amp;&amp; videoId != null)
          {
              player.cueVideo(videoId);
          }
      }
  
      @Override
      public void onInitializationFailure(Provider provider, YouTubeInitializationResult result)
      {
          this.player = null;
      }
  
  }
  </code></pre>
  
  <p>Function for creating Youtobe videoview</p>
  
  <pre><code>private ViewGroup createYouTubePlayer(final VideoData data, final FrameLayout youTubePlayer)
  {
  
      youTubePlayer.setOnClickListener(new OnClickListener()
      {
  
          @Override
          public void onClick(View v)
          {
              FragmentManager fm = mActivity.getSupportFragmentManager();
  
              if (v.getId() == mCurrentYouTubePlayer)
              {
                  return;
              }
  
              VideoFragment fragment = (VideoFragment) fm.findFragmentById(mCurrentYouTubePlayer);
              if (fragment == null)
              {
                  fragment = VideoFragment.newInstance();
                  fragment.setVideoId(data.srcPath);
  
                  fm.beginTransaction().add(youTubePlayer.getId(), fragment).commit();
                  mCurrentYouTubePlayer = v.getId();
              }
              else
              {
                  fm.beginTransaction().remove(fragment).commit();
  
                  fragment = VideoFragment.newInstance();
                  fragment.setVideoId(data.srcPath);
                  fm.beginTransaction().add(youTubePlayer.getId(), fragment).commit();
                  mCurrentYouTubePlayer = v.getId();
              }
          }
      });
  
  
  
      return youTubePlayer;
  }
  </code></pre>