视频播放器暂停后,后台运行,再次唤起画面黑屏了。
解决方案:
方案一、唤起播放器时候自动播放,来解决。(本文不采取这种方案)
方案二、播放器截屏。
1、已ijk播放器为例,需要设置为TextureRenderView,自带截屏功能,SurfaceRenderView没有这个功能。
* 视频截屏,播放器提供
* @return bitmap
public Bitmap getShortcut() {
return this.mRenderView instanceof TextureRenderView ? ((TextureRenderView) this.mRenderView).getBitmap() : null;
已知bug:视频画面较小的时候,封面强行撑满会突然变大。
2、view直接截图进行获取,this就是指的VideoView控件,同样需要设置为TextureRenderView
* VideoView直接截屏
* @return bitmap
public Bitmap getCapture() {
//启用View的DrawingCache功能
this.buildDrawingCache(true); this.setDrawingCacheBackgroundColor(Color.BLACK); this.setDrawingCacheEnabled(true) this.setVerticalScrollBarEnabled(false);
this.buildDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(this.getMeasuredWidth(), this.getMeasuredHeight(), Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
canvas.drawBitmap(bitmap, 0, this.getMeasuredHeight(), paint);
this.draw(canvas);
this.destroyDrawingCache(); // 保存过后释放资源。