android - adding a second youtube video -


how add second video in different webview in same fragment? i've tried add second video reason both web views played same video , stopped after 2 seconds of playing.

public class fragmentvideo extends fragment {  private fragmentactivity mycontext;  private youtubeplayer yplayer; private static final string youtubedeveloperkey = "developerkey"; private static final int recovery_dialog_request = 1;  @override public void onattach(activity activity) {      if (activity instanceof fragmentactivity) {         mycontext = (fragmentactivity) activity;     }      super.onattach(activity); }  @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {      view rootview = inflater.inflate(r.layout.fragmentvideo, container, false);      youtubeplayersupportfragment youtubeplayerfragment = youtubeplayersupportfragment.newinstance();     fragmenttransaction transaction = getchildfragmentmanager().begintransaction();     transaction.add(r.id.youtubevideo, youtubeplayerfragment).commit();      youtubeplayerfragment.initialize("developer key", new oninitializedlistener() {          @override         public void oninitializationsuccess(provider arg0, youtubeplayer youtubeplayer, boolean b) {             if (!b) {                 yplayer = youtubeplayer;                 yplayer.setfullscreen(false);                 yplayer.loadvideo("0molawhckws");                 yplayer.play();             }         }          @override         public void oninitializationfailure(provider arg0, youtubeinitializationresult arg1) {             // todo auto-generated method stub          }     });      return rootview; }   } 

and code layout file

<framelayout     android:id="@+id/youtube_fragment"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:visibility="visible"     android:layout_alignparenttop="true"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true">      <webview         android:id="@+id/youtubevideo"         android:layout_width="match_parent"         android:layout_height="191dp"         android:layout_marginleft="12dp"         android:layout_marginright="12dp"         android:layout_margintop="145dp" />      <webview         android:id="@+id/secondyoutubevideo"         android:layout_width="match_parent"         android:layout_height="191dp"         android:layout_marginleft="12dp"         android:layout_marginright="12dp"         android:layout_margintop="350dp" /> </framelayout> 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -