use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.
the class MainActivity method addDanmaku.
private void addDanmaku(boolean islive) {
BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
if (danmaku == null || mDanmakuView == null) {
return;
}
// for(int i=0;i<100;i++){
// }
danmaku.text = "这是一条弹幕" + System.nanoTime();
danmaku.padding = 5;
// 可能会被各种过滤器过滤并隐藏显示
danmaku.priority = 0;
danmaku.isLive = islive;
danmaku.setTime(mDanmakuView.getCurrentTime() + 1200);
danmaku.textSize = 25f * (mParser.getDisplayer().getDensity() - 0.6f);
danmaku.textColor = Color.RED;
danmaku.textShadowColor = Color.WHITE;
// danmaku.underlineColor = Color.GREEN;
danmaku.borderColor = Color.GREEN;
mDanmakuView.addDanmaku(danmaku);
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.
the class UglyViewCacheStufferSampleActivity method addDanmaKuShowTextAndImage.
private void addDanmaKuShowTextAndImage(boolean islive) {
BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
Drawable drawable = getResources().getDrawable(R.drawable.ic_launcher);
drawable.setBounds(0, 0, 100, 100);
//SpannableStringBuilder spannable = createSpannable(drawable);
danmaku.text = "这是文本,图片在textview左侧";
danmaku.setTag(new MyImageWare("http://i0.hdslb.com/bfs/face/084bd13eb5dc51a64674085bb28e958ecd5addd0.jpg@180w_180h.webp", danmaku, mIconWidth, mIconWidth, mDanmakuView));
danmaku.padding = 5;
// 一定会显示, 一般用于本机发送的弹幕
danmaku.priority = 1;
danmaku.isLive = islive;
danmaku.setTime(mDanmakuView.getCurrentTime() + 1200);
danmaku.textSize = 25f * (mParser.getDisplayer().getDensity() - 0.6f);
danmaku.textColor = Color.RED;
// 重要:如果有图文混排,最好不要设置描边(设textShadowColor=0),否则会进行两次复杂的绘制导致运行效率降低
danmaku.textShadowColor = 0;
danmaku.underlineColor = Color.GREEN;
mDanmakuView.addDanmaku(danmaku);
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project ABPlayer by winkstu.
the class Danmakus method sub.
@Override
public IDanmakus sub(long startTime, long endTime) {
if (mSortType == ST_BY_LIST || items == null || items.size() == 0) {
return null;
}
if (subItems == null) {
subItems = new Danmakus(mDuplicateMergingEnabled);
}
if (startItem == null) {
startItem = createItem("start");
}
if (endItem == null) {
endItem = createItem("end");
}
if (subItems != null) {
long dtime = startTime - startItem.time;
if (dtime >= 0 && endTime <= endItem.time) {
return subItems;
}
}
startItem.time = startTime;
endItem.time = endTime;
subItems.setItems(((SortedSet<BaseDanmaku>) items).subSet(startItem, endItem));
return subItems;
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project ABPlayer by winkstu.
the class AcFunDanmakuParser method _parse.
private Danmakus _parse(JSONArray jsonArray, Danmakus danmakus) {
if (danmakus == null) {
danmakus = new Danmakus();
}
if (jsonArray == null || jsonArray.length() == 0) {
return danmakus;
}
for (int i = 0; i < jsonArray.length(); i++) {
try {
JSONObject obj = jsonArray.getJSONObject(i);
String c = obj.getString("c");
String[] values = c.split(",");
if (values.length > 0) {
// 弹幕类型
int type = Integer.parseInt(values[2]);
if (type == 7)
// TODO : parse advance danmaku json
continue;
// 出现时间
long time = (long) (Float.parseFloat(values[0]) * 1000);
// 颜色
int color = Integer.parseInt(values[1]) | 0xFF000000;
// 字体大小
float textSize = Float.parseFloat(values[3]);
BaseDanmaku item = DanmakuFactory.createDanmaku(type, mDisp);
if (item != null) {
item.time = time;
item.textSize = textSize * (mDispDensity - 0.6f);
item.textColor = color;
item.textShadowColor = color <= Color.BLACK ? Color.WHITE : Color.BLACK;
DanmakuFactory.fillText(item, obj.optString("m", "...."));
item.index = i;
item.setTimer(mTimer);
danmakus.addItem(item);
}
}
} catch (JSONException e) {
} catch (NumberFormatException e) {
}
}
return danmakus;
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project ABPlayer by winkstu.
the class DrawTask method removeUnusedLiveDanmakusIn.
protected void removeUnusedLiveDanmakusIn(int msec) {
if (danmakuList == null || danmakuList.isEmpty())
return;
synchronized (danmakuList) {
long startTime = System.currentTimeMillis();
IDanmakuIterator it = danmakuList.iterator();
while (it.hasNext()) {
BaseDanmaku danmaku = it.next();
boolean isTimeout = danmaku.isTimeOut();
if (isTimeout && danmaku.isLive) {
it.remove();
}
if (!isTimeout || System.currentTimeMillis() - startTime > msec) {
break;
}
}
}
}
Aggregations