Search in sources :

Example 16 with BaseDanmaku

use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.

the class DrawTask method getVisibleDanmakusOnTime.

@Override
public IDanmakus getVisibleDanmakusOnTime(long time) {
    long beginMills = time - mContext.mDanmakuFactory.MAX_DANMAKU_DURATION - 100;
    long endMills = time + mContext.mDanmakuFactory.MAX_DANMAKU_DURATION;
    IDanmakus subDanmakus = danmakuList.subnew(beginMills, endMills);
    final IDanmakus visibleDanmakus = new Danmakus();
    if (null != subDanmakus && !subDanmakus.isEmpty()) {
        subDanmakus.forEachSync(new IDanmakus.DefaultConsumer<BaseDanmaku>() {

            @Override
            public int accept(BaseDanmaku danmaku) {
                if (danmaku.isShown() && !danmaku.isOutside()) {
                    visibleDanmakus.addItem(danmaku);
                }
                return ACTION_CONTINUE;
            }
        });
    }
    return visibleDanmakus;
}
Also used : BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus) Danmakus(master.flame.danmaku.danmaku.model.android.Danmakus) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus)

Example 17 with BaseDanmaku

use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.

the class DrawTask method seek.

@Override
public void seek(long mills) {
    reset();
    mContext.mGlobalFlagValues.updateVisibleFlag();
    mContext.mGlobalFlagValues.updateFirstShownFlag();
    mContext.mGlobalFlagValues.updateSyncOffsetTimeFlag();
    mContext.mGlobalFlagValues.updatePrepareFlag();
    mRunningDanmakus = new Danmakus(Danmakus.ST_BY_LIST);
    mStartRenderTime = mills < 1000 ? 0 : mills;
    mRenderingState.reset();
    mRenderingState.endTime = mStartRenderTime;
    mLastBeginMills = mLastEndMills = 0;
    if (danmakuList != null) {
        BaseDanmaku last = danmakuList.last();
        if (last != null && !last.isTimeOut()) {
            mLastDanmaku = last;
        }
    }
}
Also used : BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus) Danmakus(master.flame.danmaku.danmaku.model.android.Danmakus)

Example 18 with BaseDanmaku

use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.

the class DrawTask method requestSync.

@Override
public void requestSync(long fromTimeMills, long toTimeMills, final long offsetMills) {
    // obtain the running-danmakus which was drawn on screen
    IDanmakus runningDanmakus = mRenderingState.obtainRunningDanmakus();
    mRunningDanmakus = runningDanmakus;
    // set offset time for each running-danmakus
    runningDanmakus.forEachSync(new IDanmakus.DefaultConsumer<BaseDanmaku>() {

        @Override
        public int accept(BaseDanmaku danmaku) {
            if (danmaku.isOutside()) {
                return ACTION_REMOVE;
            }
            danmaku.setTimeOffset(offsetMills + danmaku.timeOffset);
            danmaku.isOffset = true;
            return ACTION_CONTINUE;
        }
    });
    mStartRenderTime = toTimeMills;
}
Also used : BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus)

Example 19 with BaseDanmaku

use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.

the class DanmakuFactory method createDanmaku.

/**
     * 创建弹幕数据请尽量使用此方法,参考BiliDanmakuParser或AcfunDanmakuParser
     * @param type 弹幕类型
     * @param viewportWidth danmakuview宽度,会影响滚动弹幕的存活时间(duration)
     * @param viewportHeight danmakuview高度
     * @param viewportSizeFactor 会影响滚动弹幕的速度/存活时间(duration)
     * @return
     */
public BaseDanmaku createDanmaku(int type, float viewportWidth, float viewportHeight, float viewportSizeFactor, float scrollSpeedFactor) {
    int oldDispWidth = CURRENT_DISP_WIDTH;
    int oldDispHeight = CURRENT_DISP_HEIGHT;
    boolean sizeChanged = updateViewportState(viewportWidth, viewportHeight, viewportSizeFactor);
    if (MAX_Duration_Scroll_Danmaku == null) {
        MAX_Duration_Scroll_Danmaku = new Duration(REAL_DANMAKU_DURATION);
        MAX_Duration_Scroll_Danmaku.setFactor(scrollSpeedFactor);
    } else if (sizeChanged) {
        MAX_Duration_Scroll_Danmaku.setValue(REAL_DANMAKU_DURATION);
    }
    if (MAX_Duration_Fix_Danmaku == null) {
        MAX_Duration_Fix_Danmaku = new Duration(COMMON_DANMAKU_DURATION);
    }
    if (sizeChanged && viewportWidth > 0) {
        updateMaxDanmakuDuration();
        float scaleX = 1f;
        float scaleY = 1f;
        if (oldDispWidth > 0 && oldDispHeight > 0) {
            scaleX = viewportWidth / (float) oldDispWidth;
            scaleY = viewportHeight / (float) oldDispHeight;
        }
        if (viewportHeight > 0) {
            updateSpecialDanmakusDate(scaleX, scaleY);
        }
    }
    BaseDanmaku instance = null;
    switch(type) {
        case // 从右往左滚动
        1:
            instance = new R2LDanmaku(MAX_Duration_Scroll_Danmaku);
            break;
        case // 底端固定
        4:
            instance = new FBDanmaku(MAX_Duration_Fix_Danmaku);
            break;
        case // 顶端固定
        5:
            instance = new FTDanmaku(MAX_Duration_Fix_Danmaku);
            break;
        case // 从左往右滚动
        6:
            instance = new L2RDanmaku(MAX_Duration_Scroll_Danmaku);
            break;
        case // 特殊弹幕
        7:
            instance = new SpecialDanmaku();
            sSpecialDanmakus.addItem(instance);
            break;
    }
    return instance;
}
Also used : FBDanmaku(master.flame.danmaku.danmaku.model.FBDanmaku) BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) FTDanmaku(master.flame.danmaku.danmaku.model.FTDanmaku) L2RDanmaku(master.flame.danmaku.danmaku.model.L2RDanmaku) Duration(master.flame.danmaku.danmaku.model.Duration) SpecialDanmaku(master.flame.danmaku.danmaku.model.SpecialDanmaku) R2LDanmaku(master.flame.danmaku.danmaku.model.R2LDanmaku)

Example 20 with BaseDanmaku

use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.

the class Danmakus method sub.

@Override
public IDanmakus sub(long startTime, long endTime) {
    if (items == null || items.size() == 0) {
        return null;
    }
    if (subItems == null) {
        if (mSortType == ST_BY_LIST) {
            subItems = new Danmakus(Danmakus.ST_BY_LIST);
            subItems.mLockObject = this.mLockObject;
            synchronized (this.mLockObject) {
                subItems.setItems(items);
            }
        } else {
            subItems = new Danmakus(mDuplicateMergingEnabled);
            subItems.mLockObject = this.mLockObject;
        }
    }
    if (mSortType == ST_BY_LIST) {
        return subItems;
    }
    if (startItem == null) {
        startItem = createItem("start");
    }
    if (endItem == null) {
        endItem = createItem("end");
    }
    if (subItems != null) {
        long dtime = startTime - startItem.getActualTime();
        if (dtime >= 0 && endTime <= endItem.getActualTime()) {
            return subItems;
        }
    }
    startItem.setTime(startTime);
    endItem.setTime(endTime);
    synchronized (this.mLockObject) {
        subItems.setItems(((SortedSet<BaseDanmaku>) items).subSet(startItem, endItem));
    }
    return subItems;
}
Also used : BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus)

Aggregations

BaseDanmaku (master.flame.danmaku.danmaku.model.BaseDanmaku)23 IDanmakus (master.flame.danmaku.danmaku.model.IDanmakus)9 Danmakus (master.flame.danmaku.danmaku.model.android.Danmakus)4 HashMap (java.util.HashMap)3 DanmakuTimer (master.flame.danmaku.danmaku.model.DanmakuTimer)3 SpecialDanmaku (master.flame.danmaku.danmaku.model.SpecialDanmaku)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 Drawable (android.graphics.drawable.Drawable)2 MediaPlayer (android.media.MediaPlayer)2 VideoView (android.widget.VideoView)2 IDanmakuView (master.flame.danmaku.controller.IDanmakuView)2 Duration (master.flame.danmaku.danmaku.model.Duration)2 FBDanmaku (master.flame.danmaku.danmaku.model.FBDanmaku)2 FTDanmaku (master.flame.danmaku.danmaku.model.FTDanmaku)2 IDanmakuIterator (master.flame.danmaku.danmaku.model.IDanmakuIterator)2 L2RDanmaku (master.flame.danmaku.danmaku.model.L2RDanmaku)2 R2LDanmaku (master.flame.danmaku.danmaku.model.R2LDanmaku)2 SpannedCacheStuffer (master.flame.danmaku.danmaku.model.android.SpannedCacheStuffer)2 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1