java - How to solve issue regarding youtube api in android app -
there problem regarding working youtube api in code. here trying call youtubefragmentactivity inside tab2frag.java not working in case.
specific problem: tab 2 passing youtube url using data.putstring("youtube_details", youtube_url1);. comming onpostexecute inside show_data class this
youtube_url = jobj.opt("youtube_detail").tostring(); youtube_url1=youtube_url.replace("https://www.youtube.com/watch?v=",""); youtubefragmentactivity. you_tube = extras.getstring("youtube_details");
here code youtubefragmentactivity
public class youtubefragmentactivity extends fragment { private fragmentactivity mycontext; private youtubeplayer yplayer; private static string you_tube; @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.activity_you_tube_api, container, false); bundle extras = getarguments(); you_tube = extras.getstring("youtube_details"); system.out.println("@@@@@@@@@@@@@"+you_tube+"@@@@@@@2"); youtubeplayersupportfragment youtubeplayerfragment = youtubeplayersupportfragment.newinstance(); fragmenttransaction transaction = getchildfragmentmanager().begintransaction(); transaction.add(r.id.youtube_fragment, youtubeplayerfragment).commit(); youtubeplayerfragment.initialize("developer_key", new oninitializedlistener() { @override public void oninitializationsuccess(provider provider, youtubeplayer youtubeplayer, boolean b) { if (!b) { yplayer = youtubeplayer; yplayer.loadvideo(you_tube); yplayer.play(); } } @override public void oninitializationfailure(provider provider, youtubeinitializationresult youtubeinitializationresult) { } }); return rootview; } } in tab2frag passing url using bundle youtube player working. video not playing.i trying many times still not able solve issue.
if can solve it.it great me.
have debuggued it? bundle reset when passing places. check bundle permissions, life time , call.
Comments
Post a Comment