master.flame.danmaku.danmaku.model.android.DanmakuContext Java Examples
The following examples show how to use
master.flame.danmaku.danmaku.model.android.DanmakuContext.
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: DanmakuFilters.java From letv with Apache License 2.0 | 6 votes |
private boolean needFilter(BaseDanmaku danmaku, int orderInScreen, int totalSizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext context) { Log.v("XX", "QuantityDanmakuFilter needFilter mMaximumSize : " + this.mMaximumSize + " totalSizeInScreen : " + totalSizeInScreen + " orderInScreen : " + orderInScreen + " danmaku.isTimeOut() " + danmaku.isTimeOut() + " mMaximumSize : " + this.mMaximumSize + " isShown :" + danmaku.isShown()); if (this.mMaximumSize == 0) { return true; } if (totalSizeInScreen < this.mMaximumSize || (this.mLastSkipped != null && danmaku.time - this.mLastSkipped.time > context.mDanmakuFactory.MAX_DANMAKU_DURATION / 4)) { Log.v("xx", " QuantityDanmakuFilter not guolv2222 >>>>>>>>"); this.mLastSkipped = danmaku; return false; } else if (orderInScreen <= this.mMaximumSize || danmaku.isTimeOut()) { this.mLastSkipped = danmaku; Log.v("xx", " QuantityDanmakuFilter not guolv11111 >>>>>>>>"); return false; } else { Log.v("xx", " QuantityDanmakuFilter guolv >>>>>>>>"); return true; } }
Example #2
Source File: DanmakuConfig.java From QSVideoPlayer with Apache License 2.0 | 6 votes |
public static DanmakuContext getDefaultContext() { if (danmakuContext != null) return danmakuContext; // 设置最大显示行数 HashMap<Integer, Integer> maxLinesPair = new HashMap<>(); maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 5); // 滚动弹幕最大显示5行 // 设置是否禁止重叠 HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<>(); overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true); overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true); danmakuContext = DanmakuContext.create(); danmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3) .setDuplicateMergingEnabled(false) .setScrollSpeedFactor(1.2f).setScaleTextSize(1.2f) // .setCacheStuffer(new SpannedCacheStuffer(), mCacheStufferAdapter) // 图文混排使用SpannedCacheStuffer // .setCacheStuffer(new BackgroundCacheStuffer()) // 绘制背景使用BackgroundCacheStuffer .setMaximumLines(maxLinesPair) .preventOverlapping(overlappingEnablePair) .setDanmakuMargin(40); return danmakuContext; }
Example #3
Source File: VideoPlayActivity.java From BlueBoard with Apache License 2.0 | 6 votes |
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); }
Example #4
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 5 votes |
public boolean onDanmakuConfigChanged(DanmakuContext config, DanmakuConfigTag tag, Object... values) { if (!super.handleOnDanmakuConfigChanged(config, tag, values)) { if (DanmakuConfigTag.SCROLL_SPEED_FACTOR.equals(tag)) { this.mDisp.resetSlopPixel(this.mContext.scaleTextSize); requestClear(); } else if (tag.isVisibilityRelatedTag()) { if (values != null && values.length > 0 && values[0] != null && ((!(values[0] instanceof Boolean) || ((Boolean) values[0]).booleanValue()) && this.mCacheManager != null)) { this.mCacheManager.requestBuild(0); } requestClear(); } else if (DanmakuConfigTag.TRANSPARENCY.equals(tag) || DanmakuConfigTag.SCALE_TEXTSIZE.equals(tag) || DanmakuConfigTag.DANMAKU_STYLE.equals(tag)) { if (DanmakuConfigTag.SCALE_TEXTSIZE.equals(tag)) { this.mDisp.resetSlopPixel(this.mContext.scaleTextSize); } if (this.mCacheManager != null) { this.mCacheManager.requestClearAll(); this.mCacheManager.requestBuild(-this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION); } } else if (this.mCacheManager != null) { this.mCacheManager.requestClearUnused(); this.mCacheManager.requestBuild(0); } } if (!(this.mTaskListener == null || this.mCacheManager == null)) { this.mCacheManager.post(new Runnable() { public void run() { CacheManagingDrawTask.this.mTaskListener.onDanmakuConfigChanged(); } }); } return true; }
Example #5
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean willHit, DanmakuContext config) { boolean filtered = false; if (this.mEnabledPairs != null) { Boolean enabledValue = (Boolean) this.mEnabledPairs.get(Integer.valueOf(danmaku.getType())); filtered = enabledValue != null && enabledValue.booleanValue() && willHit; if (filtered) { danmaku.mFilterParam |= 512; } } return filtered; }
Example #6
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public synchronized boolean filter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered; filtered = needFilter(danmaku, orderInScreen, totalsizeInScreen, timer, fromCachingTask, config); if (filtered) { danmaku.mFilterParam |= 2; } return filtered; }
Example #7
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = (danmaku == null || this.mWhiteList.contains(Integer.valueOf(danmaku.textColor))) ? false : true; if (filtered) { danmaku.mFilterParam |= 8; } return filtered; }
Example #8
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = danmaku != null && this.mBlackList.contains(danmaku.userHash); if (filtered) { danmaku.mFilterParam |= 32; } return filtered; }
Example #9
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = danmaku != null && this.mBlackList.contains(Integer.valueOf(danmaku.userId)); if (filtered) { danmaku.mFilterParam |= 16; } return filtered; }
Example #10
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public void filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext context) { for (IDanmakuFilter<?> f : this.mFilterArray) { if (f != null) { boolean filtered = f.filter(danmaku, index, totalsizeInScreen, timer, fromCachingTask, context); danmaku.filterResetFlag = context.mGlobalFlagValues.FILTER_RESET_FLAG; if (filtered) { return; } } } }
Example #11
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filterSecondary(BaseDanmaku danmaku, int lines, int totalsizeInScreen, DanmakuTimer timer, boolean willHit, DanmakuContext context) { for (IDanmakuFilter<?> f : this.mFilterArraySecondary) { if (f != null) { boolean filtered = f.filter(danmaku, lines, totalsizeInScreen, timer, willHit, context); danmaku.filterResetFlag = context.mGlobalFlagValues.FILTER_RESET_FLAG; if (filtered) { return true; } } } return false; }
Example #12
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 5 votes |
public CacheManagingDrawTask(DanmakuTimer timer, DanmakuContext config, TaskListener taskListener, int maxCacheSize) { super(timer, config, taskListener); NativeBitmapFactory.loadLibs(); this.mMaxCacheSize = maxCacheSize; if (NativeBitmapFactory.isInNativeAlloc()) { this.mMaxCacheSize = maxCacheSize * 2; } this.mCacheManager = new CacheManager(maxCacheSize, 3); this.mRenderer.setCacheManager(this.mCacheManager); }
Example #13
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = danmaku != null && this.mFilterTypes.contains(Integer.valueOf(danmaku.getType())); if (filtered) { danmaku.mFilterParam |= 1; danmaku.isDanmakuTypeFiltered = true; } return filtered; }
Example #14
Source File: DanmakuFactory.java From letv with Apache License 2.0 | 5 votes |
public BaseDanmaku createDanmaku(int type, DanmakuContext context) { if (context == null) { return null; } this.sLastConfig = context; this.sLastDisp = context.getDisplayer(); return createDanmaku(type, this.sLastDisp.getWidth(), this.sLastDisp.getHeight(), this.CURRENT_DISP_SIZE_FACTOR, context.scrollSpeedFactor); }
Example #15
Source File: DanmakuSurfaceView.java From letv with Apache License 2.0 | 5 votes |
public void prepare(BaseDanmakuParser parser, DanmakuContext config) { prepare(); this.handler.setConfig(config); this.handler.setParser(parser); this.handler.setCallback(this.mCallback); this.handler.prepare(); }
Example #16
Source File: DanmakuView.java From letv with Apache License 2.0 | 5 votes |
public void prepare(BaseDanmakuParser parser, DanmakuContext config) { prepare(); this.handler.setConfig(config); this.handler.setParser(parser); this.handler.setCallback(this.mCallback); this.handler.prepare(); }
Example #17
Source File: DanmakuTextureView.java From letv with Apache License 2.0 | 5 votes |
public void prepare(BaseDanmakuParser parser, DanmakuContext config) { prepare(); this.handler.setConfig(config); this.handler.setParser(parser); this.handler.setCallback(this.mCallback); this.handler.prepare(); }
Example #18
Source File: DanmakuSurfaceView.java From BlueBoard with Apache License 2.0 | 5 votes |
@Override public void prepare(BaseDanmakuParser parser, DanmakuContext config) { prepare(); handler.setConfig(config); handler.setParser(parser); handler.setCallback(mCallback); handler.prepare(); }
Example #19
Source File: DanmakuSurfaceView.java From BlueBoard with Apache License 2.0 | 5 votes |
@Override public DanmakuContext getConfig() { if (handler == null) { return null; } return handler.getConfig(); }
Example #20
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = this.mBlock.booleanValue() && danmaku.isGuest; if (filtered) { danmaku.mFilterParam |= 64; } return filtered; }
Example #21
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = needFilter(danmaku, orderInScreen, totalsizeInScreen, timer, fromCachingTask); if (filtered) { danmaku.mFilterParam |= 4; } return filtered; }
Example #22
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) { boolean filtered = needFilter(danmaku, index, totalsizeInScreen, timer, fromCachingTask); if (filtered) { danmaku.mFilterParam |= 128; } return filtered; }
Example #23
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 5 votes |
public boolean filter(BaseDanmaku danmaku, int lines, int totalsizeInScreen, DanmakuTimer timer, boolean willHit, DanmakuContext config) { boolean filtered = false; if (this.mMaximumLinesPairs != null) { Integer maxLines = (Integer) this.mMaximumLinesPairs.get(Integer.valueOf(danmaku.getType())); filtered = maxLines != null && lines >= maxLines.intValue(); if (filtered) { danmaku.mFilterParam |= 256; } } return filtered; }
Example #24
Source File: QSDanmakuParser.java From QSVideoPlayer with Apache License 2.0 | 5 votes |
public synchronized Danmakus preParse(DanmakuContext mContext) { this.mContext = mContext; result = new Danmakus(ST_BY_TIME, false, mContext.getBaseComparator()); long l = System.currentTimeMillis(); int len = 0; try { JSONObject jsonObject = new JSONObject(json); JSONArray jsonArray = jsonObject.getJSONArray("list"); len = jsonArray.length(); for (int i = 0; i < len; i++) { JSONObject object = jsonArray.getJSONObject(i); String p = object.getString("p"); String t = object.getString("t"); String[] values = p.split(","); long time = (long) (parseFloat(values[0]) * 1000); // 出现时间 int type = parseInteger(values[1]); // 弹幕类型 float textSize = parseFloat(values[2]); // 字体大小 int color = (int) ((0xff000000 | parseLong(values[3])) & 0xffffffff); // 颜色 item = buildDanmaku(t, type, time, textSize, color); Object lock = result.obtainSynchronizer(); synchronized (lock) { result.addItem(item); } } json = null; } catch (JSONException e) { e.printStackTrace(); } Log.e("QSDanmakuParser", len + "条弹幕,解析弹幕时间:" + (System.currentTimeMillis() - l)); return result; }
Example #25
Source File: DrawTask.java From letv with Apache License 2.0 | 5 votes |
protected boolean handleOnDanmakuConfigChanged(DanmakuContext config, DanmakuConfigTag tag, Object[] values) { boolean z = false; if (tag == null || DanmakuConfigTag.MAXIMUM_NUMS_IN_SCREEN.equals(tag)) { return true; } if (DanmakuConfigTag.DUPLICATE_MERGING_ENABLED.equals(tag)) { Boolean enable = values[0]; if (enable == null) { return false; } if (enable.booleanValue()) { this.mContext.mDanmakuFilters.registerFilter(DanmakuFilters.TAG_DUPLICATE_FILTER); } else { this.mContext.mDanmakuFilters.unregisterFilter(DanmakuFilters.TAG_DUPLICATE_FILTER); } return true; } else if (DanmakuConfigTag.SCALE_TEXTSIZE.equals(tag) || DanmakuConfigTag.SCROLL_SPEED_FACTOR.equals(tag)) { requestClearRetainer(); return false; } else if (!DanmakuConfigTag.MAXIMUN_LINES.equals(tag) && !DanmakuConfigTag.OVERLAPPING_ENABLE.equals(tag)) { return false; } else { if (this.mRenderer != null) { IRenderer iRenderer = this.mRenderer; if (this.mContext.isPreventOverlappingEnabled() || this.mContext.isMaxLinesLimited()) { z = true; } iRenderer.setVerifierEnabled(z); } return true; } }
Example #26
Source File: DrawTask.java From letv with Apache License 2.0 | 5 votes |
public boolean onDanmakuConfigChanged(DanmakuContext config, DanmakuConfigTag tag, Object... values) { boolean handled = handleOnDanmakuConfigChanged(config, tag, values); if (this.mTaskListener != null) { this.mTaskListener.onDanmakuConfigChanged(); } return handled; }
Example #27
Source File: DrawTask.java From letv with Apache License 2.0 | 5 votes |
public DrawTask(DanmakuTimer timer, DanmakuContext context, TaskListener taskListener) { boolean z = false; if (context == null) { throw new IllegalArgumentException("context is null"); } this.mContext = context; this.mDisp = context.getDisplayer(); this.mTaskListener = taskListener; this.mRenderer = new DanmakuRenderer(context); this.mRenderer.setOnDanmakuShownListener(new OnDanmakuShownListener() { public void onDanmakuShown(BaseDanmaku danmaku) { if (DrawTask.this.mTaskListener != null) { DrawTask.this.mTaskListener.onDanmakuShown(danmaku); } } }); IRenderer iRenderer = this.mRenderer; if (this.mContext.isPreventOverlappingEnabled() || this.mContext.isMaxLinesLimited()) { z = true; } iRenderer.setVerifierEnabled(z); initTimer(timer); Boolean enable = Boolean.valueOf(this.mContext.isDuplicateMergingEnabled()); if (enable == null) { return; } if (enable.booleanValue()) { this.mContext.mDanmakuFilters.registerFilter(DanmakuFilters.TAG_DUPLICATE_FILTER); } else { this.mContext.mDanmakuFilters.unregisterFilter(DanmakuFilters.TAG_DUPLICATE_FILTER); } }
Example #28
Source File: DanmakuEngineManager.java From letv with Apache License 2.0 | 5 votes |
public DanmakuContext getDanmakuContext(boolean isHalfScreen) { if (isHalfScreen) { if (this.mHalfScreenEngine != null) { return ((DanmakuDanmakuEngine) this.mHalfScreenEngine).getDanmakuContext(); } } else if (this.mFullScreenEngine != null) { return ((DanmakuDanmakuEngine) this.mFullScreenEngine).getDanmakuContext(); } return null; }
Example #29
Source File: DanmakuControl.java From QSVideoPlayer with Apache License 2.0 | 4 votes |
public static DanmakuControl bind(QSVideoView qsVideoView, final QSDanmakuParser parser, DanmakuContext danmakuContext) { return new DanmakuControl(qsVideoView, parser, danmakuContext); }
Example #30
Source File: CustomMediaLiveController.java From MyHearts with Apache License 2.0 | 4 votes |
public void setTanMuView(IDanmakuView tanMuView,DanmakuContext mDanmakuContext,BaseDanmakuParser mParser ) { this.mDanmakuView = tanMuView; this.mDanmakuContext=mDanmakuContext; this.mParser=mParser; }