android - GET YOUTUBE KEY_VIDEO_ID -
how youtube key_vedio_id please me find-out problem. code please , correct me if wrong where.
public class youtubeactivity extends youtubebaseactivity implements youtubeplayer.oninitializedlistener { private static final int recovery_dialog_request = 1; public static final string key_video_id = "key_video_id"; private string mvideoid; @override protected void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.activity_youtube); final bundle arguments = getintent().getextras(); if (arguments != null && arguments.containskey(key_video_id)) { mvideoid = arguments.getstring(key_video_id); } final youtubeplayerview playerview = (youtubeplayerview) findviewbyid(r.id.youtubeplayerview); playerview.initialize(getstring(r.string.developer_key_you_tube), this); } @override public void oninitializationsuccess(youtubeplayer.provider provider, youtubeplayer youtubeplayer, boolean restored) { //here can set flags on player //this flag tells player switch landscape when in fullscreen, return portrait //when leaving fullscreen youtubeplayer.setfullscreencontrolflags(youtubeplayer.fullscreen_flag_control_orientation); //this flag tells player automatically enter fullscreen when in landscape. since don't have //landscape layout activity, way allow user rotate video player. youtubeplayer.addfullscreencontrolflag(youtubeplayer.fullscreen_flag_always_fullscreen_in_landscape); //this flag controls system ui such status , navigation bar, hiding , showing them //alongside player ui youtubeplayer.addfullscreencontrolflag(youtubeplayer.fullscreen_flag_control_system_ui); if (mvideoid != null) { if (restored) { youtubeplayer.play(); } else { youtubeplayer.loadvideo(mvideoid); } } } @override public void oninitializationfailure(youtubeplayer.provider provider, youtubeinitializationresult youtubeinitializationresult) { if (youtubeinitializationresult.isuserrecoverableerror()) { youtubeinitializationresult.geterrordialog(this, recovery_dialog_request).show(); } else { //handle failure toast.maketext(this, r.string.error_init_failure, toast.length_long).show(); } } }
Comments
Post a Comment