This is my code.
public class MainActivity extends Activity {
ListView list;
public ArrayList videoList;
public CustomListAdapter a
Try setting a VideoURI
instead of VideoPath
and check again,
VideoView video = (VideoView)convertView.findViewById(R.id.video_view);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(video);
video.setMediaController(mediaController);
video.setVideoURI(Uri.parse(videoList.get(position)));
video.start();
UPDATE: If you are planning to use video's from YouTube only then the best way would be using the official YouTube API. Check here,
Android YouTube app Play Video Intent
How to Play YouTube Video in Android App
I think we should not put video view directly in the list, Since each and every view in list are redrawn or invalidated lot of times and if any video is being played and watched by user and he accidentally scrolls it off the screen , Android OS will free up that memory and hence again video will be played from Start. Video.start() will be called again and again
Best Solution is to provide a thumbnail image of any frame of video . Replace Video view with image view and on click of it open a new screen where put a video view and play on to it.