title: Android youtube API play two or more Youtube players in one main activity
body: <p>Using the Android Youtube api i want to play two videos in my app  main activity without using fragment we have the same problem with this <a href="https://stackoverflow.com/questions/16291059/multiple-youtube-players-in-one-activity">Multiple Youtube players in one activity</a> but has no acceptable answers yet please help us.</p>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  &gt;
  
  &lt;com.google.android.youtube.player.YouTubePlayerView
      android:id="@+id/video1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;com.google.android.youtube.player.YouTubePlayerView
      android:id="@+id/video2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>MainActivity.java
  
      package com.apps.you;
      import android.os.Bundle;
  import com.google.android.youtube.player.YouTubeBaseActivity;
  import com.google.android.youtube.player.YouTubeInitializationResult;
  import com.google.android.youtube.player.YouTubePlayer;
  import com.google.android.youtube.player.YouTubePlayer.Provider;
  import com.google.android.youtube.player.YouTubePlayerView;
  
  public class MainActivity extends YouTubeBaseActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
      ((YouTubePlayerView) findViewById(R.id.video1)).initialize("AIzaSyBmb9Yqu9vEBXjNOrBmZZ__6s12RH5RSv0", new YouTubePlayer.OnInitializedListener() {
          @Override
          public void onInitializationSuccess(Provider provider1, YouTubePlayer player1, boolean restored1) {
              if (!restored1) {
              player1.cueVideo("Daa38ruXHxE");
              }
          }
  
          @Override
          public void onInitializationFailure(Provider provider1, YouTubeInitializationResult result1) {
          }
      });
  
      ((YouTubePlayerView) findViewById(R.id.video2)).initialize("AIzaSyBmb9Yqu9vEBXjNOrBmZZ__6s12RH5RSv0", new YouTubePlayer.OnInitializedListener() {
  
          public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean restored) {
  
              if (!restored) {
          player.loadVideo("ctQAPiojDKE");
              }
          }
  
  
          public void onInitializationFailure(Provider provider, YouTubeInitializationResult result) {
          }
      });
  }
  }
  </code></pre>
  
  <p>the problem with this is only one video was playing at the end , video1 initialization was overrriden by the video2 initialization they call the same </p>
  
  <pre><code>  .initialize(new YouTubePlayer.OnInitializedListener(){});
  </code></pre>
  
  <p>by this:</p>
  
  <pre><code>((YouTubePlayerView) findViewById(R.id.video1)).initialize(new
      YouTubePlayer.OnInitializedListener(){});
  
  ((YouTubePlayerView) findViewById(R.id.video2)).initialize(new
      YouTubePlayer.OnInitializedListener(){});
  </code></pre>