视频的屏幕截图

时间:2015-10-15 14:17:00

标签: java android cordova

我正在制作一个应用程序,我想截取屏幕截图。在前台我正在运行一些循环的视频,我也有一个背景图片集。问题是,当我拍摄截图时,我得到的是背景图片,而不是运行视频的图片。

            try {
                // image naming and path  to include sd card  appending name you choose for file
                String mPath = Environment.getExternalStorageDirectory().toString() + "/app/" + fname + ".jpg";

                // create bitmap screen capture
                View v1 = getWindow().getDecorView().getRootView();
                v1.setDrawingCacheEnabled(true);

                Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
                v1.setDrawingCacheEnabled(false);

                Canvas canvas = new Canvas(bitmap);
                canvas.drawColor(0, Mode.CLEAR);

                File imageFile = new File(mPath);

                FileOutputStream outputStream = new FileOutputStream(imageFile);
                int quality = 90;
                bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
                outputStream.flush();
                outputStream.close();

                Log.d("MainActivity","TakeScreenshot SUCCESS");

                //openScreenshot(imageFile);
            } catch (Throwable e) {
                // Several error may come out with file handling or OOM
                Log.d("MainActivity","TakeScreenshot ERROR ");
                e.printStackTrace();
            }

有人知道如何拍摄屏幕上运行的视频的快照吗?

0 个答案:

没有答案