title: How to play a video with the YouTube API using YouTubePlayerFragment?
body: <p>I'm trying to play video in my Fragment. However, I cannot get it to work. If I'm extending 'YoutubeFailureRecovery' I get:</p>
  
  <blockquote>
    <p>09-06 21:56:40.472: E/AndroidRuntime(4946): Caused by: java.lang.IllegalStateException: A YouTubePlayerView can only be created with an Activity  which extends YouTubeBaseActivity as its context.</p>
  </blockquote>
  
  <p>This is my .xml:</p>
  
  <pre><code>&lt;com.google.android.youtube.player.YouTubePlayerView
      android:id="@+id/player"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/&gt;
  </code></pre>
  
  <p>And this is the class:</p>
  
  <pre><code>public class YoutubeFragment extends YoutubeFailureRecovery {
  
      YouTubePlayer player;
      YouTubePlayerView playerView;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle arg2) {
          // TODO Auto-generated method stub
          return inflater.inflate(R.layout.detailview, container, false);
      }
  
      @Override
      public void onStart() {
          // TODO Auto-generated method stub
          super.onStart();
          playerView = (YouTubePlayerView)getActivity().findViewById(R.id.player);
          playerView.initialize(DataHolder.DEVELOPER_KEY, this);
  
      }
  
      @Override
      public void onInitializationSuccess(Provider provider, YouTubePlayer player,
                                          boolean wasRestored) {
          // TODO Auto-generated method stub
          player.cueVideo("nCgQDjiotG0");
      }
  
      @Override
      protected Provider getYouTubePlayerProvider() {
          // TODO Auto-generated method stub
          return playerView;
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <pre><code>public abstract class YoutubeFailureRecovery extends YouTubePlayerSupportFragment implements YouTubePlayer.OnInitializedListener{
  </code></pre>
  
  <p>I just don't know what to do. I tried to extend my Fragment class with 'YoutubePlayerSupportFragment', tried to add a video-like fragment in XML, but nothing is working (error inflating). Maybe someone has some experience with using YouTube API in Fragment?</p>