Search in sources :

Example 1 with DrawPadAllExecute

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

the class ExecuteAllDrawpadActivity method startDrawPad.

/**
 * 从这里开始演示.
 */
private void startDrawPad() {
    if (isExecuting)
        return;
    isExecuting = true;
    /**
     * @param ctx
     * @param padwidth 容器宽度/生成视频的宽度
     * @param padheight 容器高度/生成视频的高度
     * @param framerate  生成视频的帧率
     * @param bitrate   生成视频的码率
     * @param dstPath   生成视频保存的完整路径 .mp4结尾.
     */
    mDrawPad = new DrawPadAllExecute(mContext, 480, 480, 25, 1000 * 1000, dstPath);
    /**
     * 设置错误监听
     */
    mDrawPad.setDrawPadErrorListener(new onDrawPadErrorListener() {

        @Override
        public void onError(DrawPad d, int what) {
            mDrawPad.stopDrawPad();
            Log.e(TAG, "后台容器线程 运行失败,您请检查下是否码率分辨率设置过大,或者联系我们!...");
        }
    });
    /**
     * 设置DrawPad处理的进度监听, 回传的currentTimeUs单位是微秒.
     */
    mDrawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            tvProgressHint.setText(String.valueOf(currentTimeUs));
            if (currentTimeUs > 18 * 1000 * 1000) {
                // 18秒的时候停止.
                mDrawPad.stopDrawPad();
            } else if (currentTimeUs > 15 * 1000 * 1000) {
                // 显示第4个图层.
                showFourLayer();
            } else if (currentTimeUs > 8 * 1000 * 1000 && videoLayer2 == null) {
                // 8秒的时候增加一个视频图层
                showThreeLayer(currentTimeUs);
            } else if (currentTimeUs > 3 * 1000 * 1000 && bmpLayer == null) {
                // 3秒的时候, 增加图片图层
                showSecondLayer(currentTimeUs);
            }
        }
    });
    /**
     * 设置DrawPad完成后的监听.
     */
    mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            tvProgressHint.setText("DrawPadExecute Completed!!!");
            isExecuting = false;
            findViewById(R.id.id_video_edit_btn2).setEnabled(true);
        }
    });
    /**
     * 开始执行这个DrawPad
     */
    if (mDrawPad.startDrawPad()) {
        // 增加背景图片
        mDrawPad.addBitmapLayer(BitmapFactory.decodeResource(getResources(), R.drawable.pad_bg), null);
        // 增加第一个视频
        videoLayer1 = mDrawPad.addVideoLayer(videoPath, null);
    } else {
        Log.e(TAG, "后台容器线程  运行失败,您请检查下是否是路径设置有无, 请用MediaInfo.checkFile执行查看下....");
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadErrorListener(com.lansosdk.box.onDrawPadErrorListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener) Paint(android.graphics.Paint) DrawPadAllExecute(com.lansosdk.box.DrawPadAllExecute)

Aggregations

Paint (android.graphics.Paint)1 DrawPad (com.lansosdk.box.DrawPad)1 DrawPadAllExecute (com.lansosdk.box.DrawPadAllExecute)1 com.lansosdk.box.onDrawPadCompletedListener (com.lansosdk.box.onDrawPadCompletedListener)1 com.lansosdk.box.onDrawPadErrorListener (com.lansosdk.box.onDrawPadErrorListener)1 com.lansosdk.box.onDrawPadProgressListener (com.lansosdk.box.onDrawPadProgressListener)1