Play youtube Videos In Android App -


Good day everyone is trying to play video from a YouTube channel. Let me break it down 1: On the first activity you get a list of users in a list 2: When you click on the user, it loads their video in another listview. Everything is working perfectly at this point, but I do not know how the video plays, when that special video is clicked. This is my code.

  package com.talagbe.videofeeds; Import java.util.ArrayList; Import org.json.JSONArray; Import org.json.JSONException; Import org.json.JSONObject; Import com.loopj.android.http.AsyncHttpClient; Import com.loopj.android.http.AsyncHttpResponseHandler; Import android App Import android.app.ProgressDialog; Import android.content.Context; Import android.content.Intent; Importroid.os.Bundle; Import android.util.log; Import android.widget.ListView; Import android.widget.Toast; Public category YoutubeVideos Activity {ListView listv; Youtube adapter yadapter; ArrayList & LT; YouTube & gt; Y_list; String url; String channel; Reference reference = null; Progress Diabloag Mpgr; @ Override Protected Zero (InstanceStat saved from bundle) {// Todo auto-generated method stub super. Connet (Saved Instantstate); SetContentView (R.layout.youtube); Y_list = New Arrestist & lt; Youtube & gt; (); Listv = (ListView) findViewById (R.id.list2); Intent = getIntent (); Bundle Bundle = Intent. Channel = bundle .getString ("channel"); in this(); } Public Zero Init () {Log D. ("Chain", channel); AsyncHttpClient Load Video = New AsyncHttpClient (); LoadVideos.get ("https://gdata.youtube.com/feeds/api/users/" + Channel + "/ Uploads? V = 2 and alt = jsonc", new asyncHttpResponseHandler () { Try string data). // JSONArray jsonArray = json.getJSONObject ( "data") getJSONArray ( "item"), {{JSONObject videoObj = new JSONObject (data). JSONArray videosarray = videoObj.getJSONObject ( "data") getJSONArray ( "item") for ;; (int i = 0; i & LT; videosarray.length (); i ++) {youtube yvideos = new YouTube (); JSONObject video = videosarray.getJSONObject (i); string videourl = Video.getJSONObject ("player") .getString ("mobile"); yvideos.setVideoTitle (video.getString ("title"); yvideos.setThumbs (video. GetJSONObject ( "thumbnail") GetString ( "sqDefault").); //yvideos.setVideourl(videourl); Y_list.add (yvideos); log d. ( "title", video.getString ( "title")); Log Kd ( "Video", videourl); Log.d ( "thumb", video.getJSONObject ( "thumbnail") GetString ( "sqDefault").);}} catch (Jesnaksapshn e) {// Todo Auto-generated catch Block e.printStackTrace (); } YouTube adapter adapters = new YouTube adapter (getApplicationContext (), R.Lite.video, y_list); Listv.setAdapter (adapter); } Start at Public Zero () {mprogress = ProgressDialog.show (YoutubeVideos.this, "Connecting ...", "Recover Video"); } Public void onFinish () {mprogress.dismiss (); } Public Zero (throttle error, string content) on Fayler {//Log.e (("error", content); Toast. GetBaseContext (), "Error connecting to the internet", Toast.LNNHHLANG). Show (); }}); }  

}

You use Google provided Can you play YouTube videos?

The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications. The API defines the way YouTube videos (and playlists) load and customize and control the video playback experience.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -