3

I have followed a tutorial on how to use the youtube gdata. Populating a listview with videos from youtube and a onclick from stackoverflow

But still video play on youtube not inside my application. Please help me to find this.

Community
  • 1
  • 1
Hardik Joshi
  • 9,477
  • 12
  • 61
  • 113
  • check link given at answer given by me at http://stackoverflow.com/questions/10208439/html5-video-doesnt-play-with-android/10209684#10209684 – Khan Jun 20 '12 at 11:14

1 Answers1

14

Once you get the You tube url..., Substring the Video_ID from the Url.See the example below i have given.

You can use http://gdata.youtube.com/feeds/mobile/videos/VIDEO_ID api to get the rtsp link from the actual you tube url.Data is in XML format

once you get the rtsp link you can play video in VideoView here is the example

For example: If this link is the video http://www.youtube.com/watch?v=sMM0R19IisI

Then sMM0R19IisI is the Video_ID.So you can pass this video id to above api to get the rtsp link

To get Data in JSON format use this http://gdata.youtube.com/feeds/mobile/videos/"+videoid+"?alt=json

Refer these two links:

Link1

Link2

Once you get the rtsp link you can play it in VideoView

Community
  • 1
  • 1
Abhi
  • 8,935
  • 7
  • 37
  • 60
  • How i do this in blundell example? what i change on it? – Hardik Joshi Jun 20 '12 at 11:18
  • if you have you tube video link get the Video_ID – Abhi Jun 20 '12 at 11:19
  • See the answer in that question.., Or if you can get the url you can do in the way i told – Abhi Jun 20 '12 at 11:27
  • I got https://www.youtube.com/watch?v=I88fKt1DL5o&feature=youtube_gdata_player URL. – Hardik Joshi Jun 20 '12 at 11:44
  • and i pass https://gdata.youtube.com/feeds/api/videos?author=mrencros&v=2&alt=jsonc – Hardik Joshi Jun 20 '12 at 11:47
  • I got https://www.youtube.com/watch?v=I88fKt1DL5o&feature=youtube_gdata_player In URL now how i get Video ID from this. I am so confuse about it. – Hardik Joshi Jun 20 '12 at 11:53
  • v=I88fKt1DL5o see in this, I88fKt1DL5o is the Video ID – Abhi Jun 20 '12 at 12:27
  • Thanks @Abhi but how i get Video ID? – Hardik Joshi Jun 20 '12 at 12:46
  • Try with string operations.., substring after getting the index – Abhi Jun 20 '12 at 12:50
  • Can you please give me a source code for this same. I got https://gdata.youtube.com/feeds/api/videos?author=mrEncros&v=2&alt=jsonc I got all videos from my channel in listview. But when i click on particular video then Webview is open. I play that video in videoview not in browser. Its very very need for me. please. – Hardik Joshi Jun 20 '12 at 12:51
  • See [this](http://www.google.co.in/#hl=en&sa=X&ei=z8fhT8WMKM_qrQeetOirAw&ved=0CAYQvwUoAQ&q=get+index+of+particular+string+in+android&spell=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=6b112fb1837e7265&biw=1024&bih=677) and [this](http://www.google.co.in/#hl=en&sclient=psy-ab&q=get%20substring%20from%20string%20in%20java&oq=Substring%20from%20the%20string%20in%20java&aq=2q&aqi=g-q4&aql=&gs_l=hp.11.2.0i22l4.0.0.2.522.0.0.0.0.0.0.0.0..0.0...0.0.qm9c9s5A5EE&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=6b112fb1837e7265&biw=1024&bih=677&pf=p&pdl=300) – Abhi Jun 20 '12 at 12:54
  • I already told you , on click of the list item you have get that particular Url and from thar url get Video_ID.., pass Video_ID my link given in my answer – Abhi Jun 20 '12 at 12:57
  • startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(video.getUrl()))); I write this on onvideoclick function. in video.getUrl() what i write to parse video id? – Hardik Joshi Jun 20 '12 at 13:04
  • See my edited answer.., i told everything think it in cool way you will get – Abhi Jun 20 '12 at 13:17
  • Thanks a lot Abhi i solve it by `startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.youtube.com/watch?v="+video.getUrl().split("v=")[1].split("&")[0])));` – Hardik Joshi Jun 20 '12 at 13:36