Android VideoView 黑屏处理
Android About 1,079 words代码
final VideoView videoView = findViewById(R.id.video_view);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
Uri uri = Uri.parse(PATH);
videoView.setVideoURI(uri);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
videoView.setBackgroundColor(Color.TRANSPARENT);
}
return true;
}
});
}
});
MediaMetadataRetriever media = new MediaMetadataRetriever();
media.setDataSource(PATH, new HashMap<String, String>());
//Bitmap bitmap = media.getFrameAtTime();//关键帧
Bitmap bitmap = media.getFrameAtTime(0);//第一帧
//videoView.setBackgroundColor(Color.WHITE);
videoView.setBackground(new BitmapDrawable(Resources.getSystem(), bitmap));
videoView.start();
Views: 6,793 · Posted: 2019-04-11
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...