i building application in want use youtube api running videos problem youtube api copied card items dont want come, want specific post video can played , not on posts. using recyclerview , cardview in application firebase database.please me reduce redundancy problem, have researched many questions did not found useful. there way video can played on post of cardview , not on all. example facebook application or instagram application videos come on specific posts , not on all.
i using android studio
youtube firebaseadapter class file:
firebaserecycleradapter <post, postviewholder> firebaserecycleradapter = new firebaserecycleradapter<post, postviewholder>( post.class, r.layout.post_row_recycle_home, postviewholder.class, mdatabasereference ) { @override protected void populateviewholder(postviewholder viewholder, post model, int position) { viewholder.setyoutube(model.getyoutube()); } }; mrecyclerview.setadapter(firebaserecycleradapter); } public static class postviewholder extends recyclerviewpager.viewholder{ view mview; public postviewholder(view itemview) { super(itemview); mview = itemview; } public void setyoutube(final string youtube){ final youtubeplayerview youplay = (youtubeplayerview) mview.findviewbyid(r.id.youtuber); youplay.initialize("some key", new youtubeplayer.oninitializedlistener() { @override public void oninitializationsuccess(youtubeplayer.provider provider, youtubeplayer youtubeplayer, boolean b) { youtubeplayer.cuevideo(youtube); } @override public void oninitializationfailure(youtubeplayer.provider provider, youtubeinitializationresult youtubeinitializationresult) { } }); }
youtube cardview xml
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/cardview" android:layout_width="match_parent" android:layout_height="wrap_content" card_view:cardcornerradius="10dp"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <com.google.android.youtube.player.youtubeplayerview android:id="@+id/youtuber" android:layout_width="match_parent" android:layout_height="200dp" />
Comments
Post a Comment