Java Code Examples for master.flame.danmaku.controller.DrawHandler

The following examples show how to use master.flame.danmaku.controller.DrawHandler. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: letv   Source File: DanmakuView.java    License: Apache License 2.0 6 votes vote down vote up
private void stopDraw() {
    DrawHandler handler = this.handler;
    this.handler = null;
    unlockCanvasAndPost();
    if (handler != null) {
        handler.quit();
    }
    if (this.mHandlerThread != null) {
        HandlerThread handlerThread = this.mHandlerThread;
        this.mHandlerThread = null;
        try {
            handlerThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        handlerThread.quit();
    }
}
 
Example 2
Source Project: BlueBoard   Source File: VideoPlayActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void danmuku(InputStream inputStream) {
        if (mDanmakuView != null) {
            mParser = DanmakuHelper.createParser(inputStream);
            mDanmakuView.setCallback(new DrawHandler.Callback() {
                @Override
                public void updateTimer(DanmakuTimer timer) {
                }

                @Override
                public void danmakuShown(BaseDanmaku danmaku) {

                }

                @Override
                public void drawingFinished() {

                }

                @Override
                public void prepared() {
                    mIsDanmakuReday = true;
                }
            });
            mDanmakuView.setOnDanmakuClickListener(new IDanmakuView.OnDanmakuClickListener() {
                @Override
                public void onDanmakuClick(BaseDanmaku latest) {
//                    Log.d("DFM", "onDanmakuClick text:" + latest.text);
                }

                @Override
                public void onDanmakuClick(IDanmakus danmakus) {
//                    Log.d("DFM", "onDanmakuClick danmakus size:" + danmakus.size());
                }
            });
            mDanmakuView.prepare(mParser, mDanmakuContext);
            mDanmakuView.enableDanmakuDrawingCache(true);
//            mDanmakuView.showFPS(true);
        }
    }
 
Example 3
Source Project: BlueBoard   Source File: DanmakuSurfaceView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void start(long postion) {
    if (handler == null) {
        prepare();
    } else {
        handler.removeCallbacksAndMessages(null);
    }
    handler.obtainMessage(DrawHandler.START, postion).sendToTarget();
}
 
Example 4
/**
 * danmuku init
 */
public void initDanMuKu(){
    //弹幕
    // 设置最大显示行数
    HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
    maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 10); // 滚动弹幕最大显示10行
    // 设置是否禁止重叠
    HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<Integer, Boolean>();
    overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
    overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);

    danmakuContext = DanmakuContext.create();
    danmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 5).setDuplicateMergingEnabled(false)
            .setMaximumLines(maxLinesPair)
            .preventOverlapping(overlappingEnablePair).setDanmakuMargin(20);
    danmakuView = findViewById(R.id.danmaku_view);
    danmakuView.enableDanmakuDrawingCache(true);
    danmakuView.setCallback(new DrawHandler.Callback() {
        @Override
        public void prepared() {
            showDanmaku = true;
            danmakuView.start();
        }

        @Override
        public void updateTimer(DanmakuTimer timer) {

        }

        @Override
        public void danmakuShown(BaseDanmaku danmaku) {

        }

        @Override
        public void drawingFinished() {

        }
    });
    danmakuView.prepare(parser, danmakuContext);
}
 
Example 5
Source Project: letv   Source File: DanmakuSurfaceView.java    License: Apache License 2.0 4 votes vote down vote up
public void setCallback(DrawHandler.Callback callback) {
    this.mCallback = callback;
    if (this.handler != null) {
        this.handler.setCallback(callback);
    }
}
 
Example 6
Source Project: letv   Source File: DanmakuSurfaceView.java    License: Apache License 2.0 4 votes vote down vote up
private void prepare() {
    if (this.handler == null) {
        this.handler = new DrawHandler(getLooper(this.mDrawingThreadType), this, this.mDanmakuVisible);
    }
}
 
Example 7
Source Project: letv   Source File: DanmakuView.java    License: Apache License 2.0 4 votes vote down vote up
private void prepare() {
    if (this.handler == null) {
        this.handler = new DrawHandler(getLooper(this.mDrawingThreadType), this, this.mDanmakuVisible);
    }
}
 
Example 8
Source Project: letv   Source File: DanmakuTextureView.java    License: Apache License 2.0 4 votes vote down vote up
private void prepare() {
    if (this.handler == null) {
        this.handler = new DrawHandler(getLooper(this.mDrawingThreadType), this, this.mDanmakuVisible);
    }
}