I want to display multiple video in listview using video but not able to do this

前端 未结 2 621
被撕碎了的回忆
被撕碎了的回忆 2021-01-16 18:27

This is my code.

public class MainActivity extends Activity {
    ListView list;
    public ArrayList videoList;
    public CustomListAdapter a         


        
2条回答
  •  粉色の甜心
    2021-01-16 18:57

    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

提交回复
热议问题