How to use a YouTube player view as a fragment
<p>I was trying to use two <code>YouTubePlayerViews</code> in one activity, but it doesn't <em>seem</em> to be possible without a fragment. I tried the code below.</p>

<ol>
<li><p>Created a New layout Resource file and declared its name as youtubefragment1.xml and added Youtubeplayer view in it.</p></li>
<li><p>Created a new class file with the following code in it.</p></li>
</ol>

<p>public class youtubeFragment1 extends YouTubePlayerSupportFragment  {</p>

<pre><code>private String currentVideoID = "video_id";
private YouTubePlayer activePlayer;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view =inflater.inflate(R.layout.youtubefragmen1,container,false);

    return view;

}


public static youtubeFragment1 newInstance(String url) {

    youtubeFragment1 youtubeFragment1 = new youtubeFragment1();

    Bundle bundle = new Bundle();
    bundle.putString("url", url);

    youtubeFragment1.setArguments(bundle);

    return youtubeFragment1;
}

private void init() {
    final String DeveloperKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    initialize(DeveloperKey, new OnInitializedListener() {
        @Override
        public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) { }

        @Override
        public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
            activePlayer = player;
            activePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
            if (!wasRestored) {
                activePlayer.loadVideo(getArguments().getString("url"), 0);

            }
        }
    });
}

public void onYouTubeVideoPaused() {
    activePlayer.pause();
}
</code></pre>

<ol start="3">
<li><p>The YouTubePlayerFragment and its attributes are as shown below.</p></li>
<li><p>I declared a fragment in the main activity and set its attributes.</p></li>
</ol>

<p>Is the code that I've written thus far correct? How do I link the YouTube fragment with the fragment declared in the main activity?</p>