master.flame.danmaku.danmaku.model.android.SpannedCacheStuffer Java Examples

The following examples show how to use master.flame.danmaku.danmaku.model.android.SpannedCacheStuffer. 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 check out the related API usage on the sidebar.
Example #1
Source File: DanmukuVideoView.java    From DKVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 发送文字弹幕
 *
 * @param text   弹幕文字
 * @param isSelf 是不是自己发的
 */
public void addDanmaku(String text, boolean isSelf) {
    if (mDanmakuView == null) return;
    mContext.setCacheStuffer(new SpannedCacheStuffer(), null);
    BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
    if (danmaku == null || mDanmakuView == null) {
        return;
    }

    danmaku.text = text;
    danmaku.priority = 0;  // 可能会被各种过滤器过滤并隐藏显示
    danmaku.isLive = false;
    danmaku.setTime(mDanmakuView.getCurrentTime() + 1200);
    danmaku.textSize = PlayerUtils.sp2px(getContext(), 12);
    danmaku.textColor = Color.WHITE;
    danmaku.textShadowColor = Color.GRAY;
    // danmaku.underlineColor = Color.GREEN;
    danmaku.borderColor = isSelf ? Color.GREEN : Color.TRANSPARENT;
    mDanmakuView.addDanmaku(danmaku);
}
 
Example #2
Source File: MyDanmakuView.java    From DKVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 发送文字弹幕
 *
 * @param text   弹幕文字
 * @param isSelf 是不是自己发的
 */
public void addDanmaku(String text, boolean isSelf) {
    mContext.setCacheStuffer(new SpannedCacheStuffer(), null);
    BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
    if (danmaku == null) {
        return;
    }

    danmaku.text = text;
    danmaku.priority = 0;  // 可能会被各种过滤器过滤并隐藏显示
    danmaku.isLive = false;
    danmaku.setTime(getCurrentTime() + 1200);
    danmaku.textSize = PlayerUtils.sp2px(getContext(), 12);
    danmaku.textColor = Color.WHITE;
    danmaku.textShadowColor = Color.GRAY;
    // danmaku.underlineColor = Color.GREEN;
    danmaku.borderColor = isSelf ? Color.GREEN : Color.TRANSPARENT;
    addDanmaku(danmaku);
}
 
Example #3
Source File: VideoPlayActivity.java    From BlueBoard with Apache License 2.0 6 votes vote down vote up
private void initDanmaku() {
        // 设置最大显示行数
        HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
        // 滚动弹幕最大显示3行
        maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 5);
        // 设置是否禁止重叠
        HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<Integer, Boolean>();
        overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
        overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);

        mDanmakuContext = DanmakuContext.create();
        mDanmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3)
                .setDuplicateMergingEnabled(false)
                .setScrollSpeedFactor(1.2f)
                .setScaleTextSize(1.2f)
                .setCacheStuffer(new SpannedCacheStuffer(), null) // 图文混排使用SpannedCacheStuffer
//        .setCacheStuffer(new BackgroundCacheStuffer())  // 绘制背景使用BackgroundCacheStuffer
                .setMaximumLines(maxLinesPair)
                .preventOverlapping(overlappingEnablePair);
    }