I am making an app which has two activities ie MainActivity with a listview and second activity is a Video View.I use xml to populate listview and am successful I also stored video Url in a xml.What i need is I would like to play that videos from xml on VideoView when user click on corresponding listview list.How can i accomplish this?
Asked
Active
Viewed 1,919 times
0
-
can you show that xml? – Syn3sthete Mar 08 '14 at 09:06
-
You need to get the listview item by knowing the position and match the position to the correspoding video, this can be done in Java file but aint sure without seeing your code. Please post what have you tried so far – San Mar 08 '14 at 09:09
-
@Hari i used this tutorial http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/ to populate list view from server.No i need is when i click on corresponding link video must be played on videoview – Govind Narayan Mar 08 '14 at 09:14
-
@PiyushGupta please go through comment – Govind Narayan Mar 08 '14 at 09:15
-
@San please go through above comment – Govind Narayan Mar 08 '14 at 09:15
-
@GovindNarayan so what have you tried for it? where are you stuck exactly? – Syn3sthete Mar 08 '14 at 09:16
2 Answers
0
You are parse your data in XML format so obviously you have store your all data in HashMap Arraylist with particular key for your Video url.
Now, what can do, If you need to open Video on Item Click of ListView then you can retrieve your video url in String like
String myUrl = urHashMaparraylist.get(position).get("videolocation");
Now pass this myUrl to next Activity and just set this String as a
Uri video = Uri.parse(myUrl);
videoView.setVideoURI(video);
EDIT:
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String myUrl = urHashMaparraylist.get(position).get("videolocation");
Intent n = new Intent(YourActivityName.this , NewActivityName.class);
n.putExtra("videolocation",myUrl);
startActivity(n);
}
});
Now in your next Activity retrieve it as a
Intent n = getIntent();
String url = n.getStringExtra("videolocation");
Now you can set this string to your VideoView as a
Uri video = Uri.parse(url);
videoView.setVideoURI(video);

Piyush
- 18,895
- 5
- 32
- 63
-
It worked.Thankyou.Btw just edit next to "Now in your next Activity retrieve it as a" String myUrl – Govind Narayan Mar 08 '14 at 12:42
0
when i did something like that I used, these 3 links:
http://developer.samsung.com/android/technical-docs/Android-Media-Streaming-Tutorial
How to Play Streaming Audio/Video from a url?
I hope that is what you are looking.

Community
- 1
- 1

user3223477
- 3
- 1