[英]Android VideoView thumbnail refresh after programmatically seeking on certain devices
In my application I sometimes have to programatically skip the video to a certain position according to user input. 在我的应用程序中,有时必须根据用户输入以编程方式将视频跳过到某个位置。
The problem I'm having is that when the video is paused and I seek to a specified value the thumbnail does not refresh (the videoview still displays the image where it was initially paused). 我遇到的问题是,当视频暂停并且我寻求一个指定的值时,缩略图不会刷新(视频视图仍显示最初暂停的位置的图像)。
This however happens only on devices such as the Galaxy S4, the HTC One or the Nexus 10 (maybe something related to the API or the resolution, not exactly sure), while it works as expected on Galaxy S2, Nexus 7 and other lower-end devices. 但是,这种情况仅发生在Galaxy S4,HTC One或Nexus 10等设备上(可能与API或分辨率有关,但不确定),而在Galaxy S2,Nexus 7和其他较低版本的设备上则可以正常工作终端设备。
I've tried a "hacky" approach such as starting and pausing the video with no success (the image in the videoview does not update). 我尝试了一种“骇人”的方法,例如无法成功启动和暂停视频(videoview中的图像不会更新)。
I'm hoping that someone with a bit more experience can tell me if there is any way to refresh the video's thumbnail programmatically. 我希望有更多经验的人可以告诉我是否可以通过编程方式刷新视频缩略图。
You can use the SeekOnCompletedListener
of the underlaying MediaPlayer
of the VideoView
and pause right after it seeked. 您可以使用
VideoView
底层MediaPlayer
的SeekOnCompletedListener
,并在搜索之后立即暂停。
void Seek(int position) {
VideoView1.start();
VideoView1.seekTo(position);
}
VideoView1.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() {
@Override
public void onSeekComplete(MediaPlayer mp) {
VideoView1.pause();
}
});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.