Java Code Examples for master.flame.danmaku.danmaku.model.BaseDanmaku#setTime()

The following examples show how to use master.flame.danmaku.danmaku.model.BaseDanmaku#setTime() . 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: GameBaseActivity.java    From kcanotify_h5-master with GNU General Public License v3.0 6 votes vote down vote up
private void addDanmaku(String content, boolean withBorder) {
    if(danmakuView == null){
        return;
    }
    BaseDanmaku danmaku = danmakuContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
    if(content.length() > 7) {
        danmaku = danmakuContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_FIX_TOP);
    }
    danmaku.text = content;
    danmaku.padding = 5;
    danmaku.textSize = sp2px(14);
    danmaku.textColor = Color.WHITE;
    danmaku.textShadowColor = Color.BLACK;
    danmaku.setTime(danmakuView.getCurrentTime());
    if (withBorder) {
        danmaku.borderColor = Color.GREEN;
    }
    danmakuView.addDanmaku(danmaku);
}
 
Example 2
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 3
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 4
Source File: MainActivity.java    From QSVideoPlayer with Apache License 2.0 6 votes vote down vote up
private void addDanmaku(boolean islive) {
    BaseDanmaku danmaku = DanmakuConfig.getDefaultContext().mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
    if (danmaku == null || danmakuControl == null) {
        return;
    }
    // for(int i=0;i<100;i++){
    // }
    danmaku.text = "QSVideoPlayer-" + System.nanoTime();
    danmaku.padding = 5;
    danmaku.priority = 10;  // 可能会被各种过滤器过滤并隐藏显示
    danmaku.isLive = islive;
    danmaku.setTime(demoVideoView.getPosition() + 1200);
    danmaku.textSize = 40;
    danmaku.textColor = Color.RED;
    danmaku.textShadowColor = Color.WHITE;
    // danmaku.underlineColor = Color.GREEN;
    danmaku.borderColor = Color.GREEN;
    danmakuControl.add(danmaku);

}
 
Example 5
Source File: DanmakuVideoPlayer.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 模拟添加弹幕数据
 */
private void addDanmaku(boolean islive) {
    BaseDanmaku danmaku = mDanmakuContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
    if (danmaku == null || mDanmakuView == null) {
        return;
    }
    danmaku.text = "这是一条弹幕 " + getCurrentPositionWhenPlaying();
    danmaku.padding = 5;
    danmaku.priority = 8;  // 可能会被各种过滤器过滤并隐藏显示,所以提高等级
    danmaku.isLive = islive;
    danmaku.setTime(mDanmakuView.getCurrentTime() + 500);
    danmaku.textSize = 25f * (mParser.getDisplayer().getDensity() - 0.6f);
    danmaku.textColor = Color.RED;
    danmaku.textShadowColor = Color.WHITE;
    danmaku.borderColor = Color.GREEN;
    mDanmakuView.addDanmaku(danmaku);

}
 
Example 6
Source File: DanmukuVideoView.java    From DKVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
     * 发送自定义弹幕
     */
    public void addDanmakuWithDrawable() {
        mContext.setCacheStuffer(new BackgroundCacheStuffer(), null);
        BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
        if (danmaku == null || mDanmakuView == null) {
            return;
        }
        // for(int i=0;i<100;i++){
        // }
        Drawable drawable = ContextCompat.getDrawable(getContext(), R.mipmap.ic_launcher_round);
        int size = PlayerUtils.dp2px(getContext(), 20);
        drawable.setBounds(0, 0, size, size);

//        danmaku.text = "这是一条弹幕";
        danmaku.text = createSpannable(drawable);
//        danmaku.padding = 5;
        danmaku.priority = 0;  // 可能会被各种过滤器过滤并隐藏显示
        danmaku.isLive = false;
        danmaku.setTime(mDanmakuView.getCurrentTime() + 1200);
        danmaku.textSize = PlayerUtils.sp2px(getContext(), 12);
        danmaku.textColor = Color.RED;
        danmaku.textShadowColor = Color.WHITE;
        // danmaku.underlineColor = Color.GREEN;
//        danmaku.borderColor = Color.GREEN;
        mDanmakuView.addDanmaku(danmaku);

    }
 
Example 7
Source File: MyDanmakuView.java    From DKVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
     * 发送自定义弹幕
     */
    public void addDanmakuWithDrawable() {
        mContext.setCacheStuffer(new BackgroundCacheStuffer(), null);
        BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
        if (danmaku == null) {
            return;
        }
        // for(int i=0;i<100;i++){
        // }
        Drawable drawable = ContextCompat.getDrawable(getContext(), R.mipmap.ic_launcher_round);
        int size = PlayerUtils.dp2px(getContext(), 20);
        drawable.setBounds(0, 0, size, size);

//        danmaku.text = "这是一条弹幕";
        danmaku.text = createSpannable(drawable);
//        danmaku.padding = 5;
        danmaku.priority = 0;  // 可能会被各种过滤器过滤并隐藏显示
        danmaku.isLive = false;
        danmaku.setTime(getCurrentTime() + 1200);
        danmaku.textSize = PlayerUtils.sp2px(getContext(), 12);
        danmaku.textColor = Color.RED;
        danmaku.textShadowColor = Color.WHITE;
        // danmaku.underlineColor = Color.GREEN;
//        danmaku.borderColor = Color.GREEN;
        addDanmaku(danmaku);

    }
 
Example 8
Source File: LivePlayActivity.java    From C9MJ with Apache License 2.0 5 votes vote down vote up
/**
 * ListPlayChatFragment调用,添加弹幕到DanmakuView
 *
 * @param danmuBean
 * @param withBorder
 */
public void addDanmuOnDanmakuView(DanmuBean danmuBean, boolean withBorder) {
    if (!isShowDanmu) {
        return;
    }
    BaseDanmaku danmaku = danmakuContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
    danmaku.text = danmuBean.getData().getContent();
    danmaku.textSize = SizeUtils.sp2px(12 * 1.0f);
    danmaku.textColor = Color.WHITE;
    danmaku.setTime(danmuView.getCurrentTime());
    if (withBorder) {
        danmaku.borderColor = ContextCompat.getColor(context, R.color.color_primary);
    }
    danmuView.addDanmaku(danmaku);
}