我想从外部存储目录播放视频,所有文件都是 mp4 格式我在视频视图中播放它但问题是当我使用 onComplitonlistner 时下一个视频丢失了它的视图只有音频进来但没有视频,直到我触摸显示器任何解决方案.
final File s[] = videofiles.listFiles();
mylist = new ArrayList<String>();
try {
for (int j = 0; j < s.length; j++) {
if (s[j].getName().split("[.]")[1].equalsIgnoreCase("mp4")) {
mylist.add(s[j].getAbsolutePath());
}
}
} catch (Exception e) {
e.printStackTrace();
}
mVideoView.setVideoPath(mylist.get(i));
mVideoView.start();
mVideoView.buildLayer();
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (i >= s.length - 1) {
i = -1;
}
linearLayout.refreshDrawableState();
linear.refreshDrawableState();
mVideoView.stopPlayback();
mVideoView.refreshDrawableState();
mVideoView.setDrawingCacheEnabled(true);
mVideoView.setDrawingCacheQuality(TRIM_MEMORY_BACKGROUND);
mVideoView.setVideoPath(mylist.get(++i));
mVideoView.start();
}
logcat 在这里,这表示媒体播放器没有播放视频,但 auido 来了