如何在列表视图中选择时启用视频序列自动播放?

发布于 2024-11-08 14:55:22 字数 233 浏览 0 评论 0原文

大家好,有人可以与我分享一下我如何编写我的 viewvideo.java 类,以便它允许自动播放视频功能,该功能自动排序在列表视图中播放所选视频的任务(从当前位置到最新录制的视频)按顺序直到最新的视频播放完毕)这类似于 YouTube 自动播放功能,如果你明白我的意思吗?

有人可以帮助我解决我现在面临的这个问题吗?我对 android/java 编程相当陌生,并且已经被这个问题困扰好几天了......抱歉我上面的英语不好......

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 playing the selected video in a listview (from current position to the latest video recorded in sequence until the latest video in line has finished playing) which is something similar to the youtube auto-play function if you know what i mean?

Can someone help me pertaining to this problem i'm facing now i'm rather quite new to android/java programming and have been stuck on this problem for days... Sorry for my bad English above..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2024-11-15 14:55:22

我认为您需要做的就是调用videoView.setVideoPath(next_file_path),然后调用videoView.start()。如果没有更多视频,则调用 videoView.stopPlayback()

以下是可能有效的方法:

@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();
    }
}

这会将路径名数组传递给您的对话框活动(您尚未发布)。如果用户选择播放所有视频,您应该能够检索 arrayPath 并将其传递给 VideoView 活动。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文