Search in sources :

Example 21 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteBitmapLayerActivity method testDrawPadExecute.

private void testDrawPadExecute() {
    if (isExecuting)
        return;
    padWidth = 480;
    padHeight = 480;
    isExecuting = true;
    mDrawPad = new DrawPadPictureExecute(getApplicationContext(), 480, 480, 26 * 1000, 25, 1000000, dstPath);
    /**
     * 设置DrawPad的处理进度监听, 您可以在每一帧的过程中对ILayer做各种变化,
     * 比如平移,缩放,旋转,颜色变化,增删一个Layer等,来实现各种动画画面.
     */
    mDrawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        // currentTimeUs是当前时间戳,单位是微妙,可以根据时间戳/(MediaInfo.vDuration*1000000)来得到当前进度百分比.
        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            tvProgressHint.setText(String.valueOf(currentTimeUs));
        }
    });
    /**
     * 处理完毕后的监听
     */
    mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            tvProgressHint.setText("DrawPadExecute Completed!!!");
            isExecuting = false;
            if (SDKFileUtils.fileExist(dstPath)) {
                findViewById(R.id.id_video_edit_btn2).setEnabled(true);
            }
        }
    });
    /**
     * 开始前先设置暂停标记.暂停画面的走动.比如想一次性增加多个Layer对象后,
     * 在让DrawPad执行,这样比在画面走动中获取更精确一些.
     */
    mDrawPad.pauseRecord();
    if (mDrawPad.startDrawPad()) {
        mDrawPad.addBitmapLayer(BitmapFactory.decodeFile(picBackGround), null);
        // 这里同时增加多个,只是不显示出来.
        // 1--5秒.
        addLayerToArray(R.drawable.pic1, 0, 5000);
        // 5--10秒.
        addLayerToArray(R.drawable.pic2, 5000, 10000);
        // 10---15秒
        addLayerToArray(R.drawable.pic3, 10000, 15000);
        // 15---20秒
        addLayerToArray(R.drawable.pic4, 15000, 20000);
        // 20---25秒
        addLayerToArray(R.drawable.pic5, 20000, 25000);
    } else {
        DemoUtil.showToast(getApplicationContext(), "drawpad容器执行失败,请查看打印信息");
    }
    mDrawPad.resumeRecord();
}
Also used : DrawPad(com.lansosdk.box.DrawPad) DrawPadPictureExecute(com.lansosdk.videoeditor.DrawPadPictureExecute) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener)

Example 22 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class PictureSetRealTimeActivity method initDrawPad.

/**
 * Step1: 初始化DrawPad
 */
private void initDrawPad() {
    // 设置为自动刷新模式, 帧率为25
    drawPadView.setUpdateMode(DrawPadUpdateMode.AUTO_FLUSH, 30);
    // 使能实时录制,并设置录制后视频的宽度和高度, 码率, 帧率,保存路径.
    drawPadView.setRealEncodeEnable(480, 480, 1000000, (int) 30, dstPath);
    drawPadView.setOnDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

        @Override
        public void onThreadProgress(DrawPad arg0, long arg1) {
            if (arg1 >= 1000 * 1000 && isSwitched == false) {
                bgLayer.switchBitmap(BitmapFactory.decodeFile("/sdcard/a2.jpg"));
                isSwitched = true;
            }
        }
    });
    drawPadView.setOnDrawPadCompletedListener(new DrawPadCompleted());
    drawPadView.setOnDrawPadProgressListener(new DrawPadProgressListener());
    // 设置DrawPad的宽高, 这里设置为480x480,如果您已经在xml中固定大小,则不需要再次设置,
    // 可以直接调用startDrawPad来开始录制.
    drawPadView.setDrawPadSize(480, 480, new onDrawPadSizeChangedListener() {

        @Override
        public void onSizeChanged(int viewWidth, int viewHeight) {
            // TODO Auto-generated method stub
            startDrawPad();
        }
    });
    // 这里仅仅是举例,当界面再次返回的时候,依旧显示图片更新的动画效果,即重新开始DrawPad, 很多时候是不需要这样的场景, 这里仅仅是举例
    drawPadView.setOnViewAvailable(new onViewAvailable() {

        @Override
        public void viewAvailable(DrawPadView v) {
            startDrawPad();
        }
    });
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadSizeChangedListener(com.lansosdk.box.onDrawPadSizeChangedListener) DrawPadView(com.lansosdk.videoeditor.DrawPadView) DrawPadView.onViewAvailable(com.lansosdk.videoeditor.DrawPadView.onViewAvailable) com.lansosdk.box.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener)

Example 23 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ViewLayerDemoActivity method initDrawPad.

/**
 * Step1: 设置DrawPad 容器的尺寸.
 * 并设置是否实时录制容器上的内容.
 */
private void initDrawPad() {
    MediaInfo info = new MediaInfo(mVideoPath, false);
    if (info.prepare()) {
        drawPadView.setUpdateMode(DrawPadUpdateMode.AUTO_FLUSH, 25);
        drawPadView.setRealEncodeEnable(480, 480, 1000000, (int) info.vFrameRate, editTmpPath);
        drawPadView.setOnDrawPadProgressListener(new onDrawPadProgressListener() {

            @Override
            public void onProgress(DrawPad v, long currentTimeUs) {
                if (// 在第7秒的时候, 不再显示.
                currentTimeUs > 10 * 1000 * 1000) {
                    hideWord();
                } else if (// 在第三秒的时候, 显示tvWord
                currentTimeUs > 3 * 1000 * 1000) {
                    showWord();
                }
            }
        });
        drawPadView.setDrawPadSize(480, 480, new onDrawPadSizeChangedListener() {

            @Override
            public void onSizeChanged(int viewWidth, int viewHeight) {
                startDrawPad();
            }
        });
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadSizeChangedListener(com.lansosdk.box.onDrawPadSizeChangedListener) MediaInfo(com.lansosdk.videoeditor.MediaInfo) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) Paint(android.graphics.Paint)

Example 24 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteCanvasLayerActivity method testDrawPadExecute.

private void testDrawPadExecute() {
    if (isExecuting)
        return;
    isExecuting = true;
    /**
     * 设置宽高,时长, 帧率,码率, 目标文件路径
     * 这里设置的的时长是5秒钟.
     */
    mDrawPad = new DrawPadBitmapRunnable(getApplicationContext(), 480, 480, 5 * 1000, 25, 1000 * 1024, dstPath);
    mDrawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        // currentTimeUs是当前时间戳,单位是微妙,可以根据时间戳/(MediaInfo.vDuration*1000000)来得到当前进度百分比.
        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            // TODO Auto-generated method stub
            tvProgressHint.setText(String.valueOf(currentTimeUs));
        }
    });
    /**
     * 处理完毕后的监听
     */
    mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            // TODO Auto-generated method stub
            tvProgressHint.setText("DrawPadExecute Completed!!!");
            isExecuting = false;
            if (SDKFileUtils.fileExist(dstPath)) {
                findViewById(R.id.id_video_edit_btn2).setEnabled(true);
            }
        }
    });
    mDrawPad.setDrawpadOutFrameListener(480, 480, 1, new onDrawPadOutFrameListener() {

        @Override
        public void onDrawPadOutFrame(DrawPad v, Object obj, int type, long ptsUs) {
        // TODO Auto-generated method stub
        }
    });
    startDrawPad();
}
Also used : DrawPadBitmapRunnable(com.lansosdk.box.DrawPadBitmapRunnable) com.lansosdk.box.onDrawPadOutFrameListener(com.lansosdk.box.onDrawPadOutFrameListener) DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener)

Example 25 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteTwoVideoLayerDemoActivity method testDrawPadExecute.

/**
 * 从这里开始演示.
 */
private void testDrawPadExecute() {
    if (isExecuting)
        return;
    String videoPath2 = "/sdcard/mask.mp4";
    isExecuting = true;
    mDrawPad = new DrawPadTwoVideoExecute(ExecuteTwoVideoLayerDemoActivity.this, videoPath, videoPath2, 544, 960, 2000000, editTmpPath);
    mDrawPad.setUseMainVideoPts(true);
    /**
     * 设置效果视频 是否循环.
     */
    mDrawPad.setEffectVideoLoop(true);
    /**
     * 设置DrawPad处理的进度监听, 回传的currentTimeUs单位是微秒.
     */
    mDrawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            // TODO Auto-generated method stub
            tvProgressHint.setText(String.valueOf(currentTimeUs));
            // 6秒后消失
            if (currentTimeUs > 6000000 && bitmapLayer != null)
                v.removeLayer(bitmapLayer);
            // 3秒的时候,放大一倍.
            if (currentTimeUs > 3000000 && bitmapLayer != null)
                bitmapLayer.setScale(2.0f);
        }
    });
    /**
     * 设置DrawPad完成后的监听.
     */
    mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            // TODO Auto-generated method stub
            tvProgressHint.setText("DrawPadExecute Completed!!!");
            isExecuting = false;
            if (SDKFileUtils.fileExist(editTmpPath)) {
                boolean ret = VideoEditor.encoderAddAudio(videoPath, editTmpPath, SDKDir.TMP_DIR, dstPath);
                if (ret == false) {
                    dstPath = editTmpPath;
                }
            }
            findViewById(R.id.id_video_edit_btn2).setEnabled(true);
        }
    });
    // vDrawPad.setUseMainVideoPts(true);
    mDrawPad.pauseRecordDrawPad();
    /**
     * 开始执行这个DrawPad
     */
    if (mDrawPad.startDrawPad()) {
        addLayers();
    } else {
        Log.e(TAG, "后台容器线程  运行失败,您请检查下是否是路径设置有无, 请用MediaInfo.checkFile执行查看下....");
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) DrawPadTwoVideoExecute(com.lansosdk.box.DrawPadTwoVideoExecute) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener)

Aggregations

DrawPad (com.lansosdk.box.DrawPad)28 com.lansosdk.box.onDrawPadProgressListener (com.lansosdk.box.onDrawPadProgressListener)16 com.lansosdk.box.onDrawPadSizeChangedListener (com.lansosdk.box.onDrawPadSizeChangedListener)10 Paint (android.graphics.Paint)9 com.lansosdk.box.onDrawPadCompletedListener (com.lansosdk.box.onDrawPadCompletedListener)9 com.lansosdk.box.onDrawPadThreadProgressListener (com.lansosdk.box.onDrawPadThreadProgressListener)9 com.lansosdk.box.onDrawPadErrorListener (com.lansosdk.box.onDrawPadErrorListener)7 DrawPadCameraView (com.lansosdk.videoeditor.DrawPadCameraView)5 DrawPadCameraView.onViewAvailable (com.lansosdk.videoeditor.DrawPadCameraView.onViewAvailable)5 MediaInfo (com.lansosdk.videoeditor.MediaInfo)5 DrawPadCameraView.doFousEventListener (com.lansosdk.videoeditor.DrawPadCameraView.doFousEventListener)4 com.lansosdk.box.onDrawPadOutFrameListener (com.lansosdk.box.onDrawPadOutFrameListener)3 DrawPadVideoExecute (com.lansosdk.videoeditor.DrawPadVideoExecute)3 Bitmap (android.graphics.Bitmap)2 DrawPadView (com.lansosdk.videoeditor.DrawPadView)2 DrawPadView.onViewAvailable (com.lansosdk.videoeditor.DrawPadView.onViewAvailable)2 DialogInterface (android.content.DialogInterface)1 Surface (android.view.Surface)1 OnClickListener (android.view.View.OnClickListener)1 DrawPadAllExecute (com.lansosdk.box.DrawPadAllExecute)1