How to enable autoplay of video in sequences upon selection in a listview?

后端 未结 1 1966
挽巷
挽巷 2021-01-27 19:08

Hello guys can someone share with me on how am i going to code my viewvideo.java class such that it allow auto-play video function which automatically sequence the task of playi

相关标签:
1条回答
  • 2021-01-27 19:55

    I think that all you need to do is call videoView.setVideoPath(next_file_path) and then call videoView.start(). If there are no more videos, then call videoView.stopPlayback().

    Here's something that might work:

    @Override
    public void onClick(DialogInterface dialog, int which) {
        if (arg1 == 0) {
            Intent intentInfo = new Intent(ListViewActivity.this, DialogBox.class);
            // Retrieve the path names of all videos from the top to the
            // selected item (inclusive).
            arrayPath = new String[selectedPosition+1];
            for (int i = 0; i <= selectedPosition; ++i) {
                arrayPath[i] = videoItems.get(i).absolutePath;
            }
            VideoInfo info = videoItems.get(selectedPosition);
            intentInfo.putExtra("fileName", info.name);             
            intentInfo.putExtra("fileSize", info.size);
            intentInfo.putExtra("absolutePath", info.absolutePath);
            intentInfo.putExtra("arrayPath", arrayPath);
    
            startActivity(intentInfo);  
        }
        else
        {
            deleteFile();
        }
    }
    

    This passes the array of path names to your DialogBox activity (which you haven't posted). You should then be able to retrieve arrayPath and pass it on to the VideoView activity if the user selects to play all videos.

    0 讨论(0)
提交回复
热议问题