VideoView和步进播放(逐帧)

发布于 2024-09-25 22:03:54 字数 205 浏览 1 评论 0原文

我想用视频视图逐帧播放。 我有这个:

mVideoView.seekTo(mVideoView.getCurrentPosition()+1);

但在此之后我看不到该帧,直到我单击播放...我不想那样,我只想看到下一帧。

另外 - 我可以对前一帧做同样的事情吗?

提前致谢。

I would like to play frame by frame with the videoview.
I have this:

mVideoView.seekTo(mVideoView.getCurrentPosition()+1);

But after this I do not see the frame until I click play... I do not want that, I just want to see the next frame.

Also - can I do the same for previous frame?

Thanks in advance.

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

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

发布评论

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

评论(2

浴红衣 2024-10-02 22:03:55

暂停时它不会进行搜索。但是,如果您使用 SurfaceView 和 MediaPlayer,则始终可以在查找后立即暂停,因为 VideoView 没有 onSeekComplete 回调。

public void seek() {
mediaplayer.start();
mediaplayer.seekTo(mediaplayer.getCurrentPosition()+1);
}

public void onSeekComplete(MediaPlayer mp) {        
mediaplayer.pause();
}

这将寻找并显示一些东西。不幸的是,您会发现这不允许您逐帧播放。

It will not seek while paused. But you can always pause right after seeking, if you use a SurfaceView and a MediaPlayer because VideoView doesn't have the onSeekComplete callback.

public void seek() {
mediaplayer.start();
mediaplayer.seekTo(mediaplayer.getCurrentPosition()+1);
}

public void onSeekComplete(MediaPlayer mp) {        
mediaplayer.pause();
}

This will seek and display something. Unfortunately you will find that this does not allow you to play frame by frame.

三寸金莲 2024-10-02 22:03:55

您可以使用 MediaMetadataRetriever 选择您想要的框架,然后将其获取为使用 MediaMetadataRetriever.getFrameAtTime(long timeUs) 的位图。它比使用 MediaPlayer 效果要好得多。

我希望它有用。

You can use MediaMetadataRetriever to select the frame you want and next get it as a BitMap using MediaMetadataRetriever.getFrameAtTime(long timeUs). It will work much better than using a MediaPlayer.

I hope it is useful.

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