use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.
the class DanmakuFactory method updateSpecialDanmakusDate.
private void updateSpecialDanmakusDate(final float scaleX, final float scaleY) {
IDanmakus list = sSpecialDanmakus;
list.forEachSync(new IDanmakus.DefaultConsumer<BaseDanmaku>() {
@Override
public int accept(BaseDanmaku danmaku) {
SpecialDanmaku speicalDanmaku = (SpecialDanmaku) danmaku;
fillTranslationData(speicalDanmaku, speicalDanmaku.beginX, speicalDanmaku.beginY, speicalDanmaku.endX, speicalDanmaku.endY, speicalDanmaku.translationDuration, speicalDanmaku.translationStartDelay, scaleX, scaleY);
LinePath[] linePaths = speicalDanmaku.linePaths;
if (linePaths != null && linePaths.length > 0) {
int length = linePaths.length;
float[][] points = new float[length + 1][2];
for (int j = 0; j < length; j++) {
points[j] = linePaths[j].getBeginPoint();
points[j + 1] = linePaths[j].getEndPoint();
}
fillLinePathData(speicalDanmaku, points, scaleX, scaleY);
}
return ACTION_CONTINUE;
}
});
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.
the class DrawTask method endTracing.
private void endTracing(RenderingState renderingState) {
renderingState.nothingRendered = (renderingState.totalDanmakuCount == 0);
if (renderingState.nothingRendered) {
renderingState.beginTime = RenderingState.UNKNOWN_TIME;
}
BaseDanmaku lastDanmaku = renderingState.lastDanmaku;
renderingState.lastDanmaku = null;
renderingState.endTime = lastDanmaku != null ? lastDanmaku.getActualTime() : RenderingState.UNKNOWN_TIME;
renderingState.consumingTime = renderingState.timer.update(SystemClock.uptimeMillis());
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project GSYVideoPlayer by CarGuo.
the class DanmakuVideoPlayer method initDanmaku.
private void initDanmaku() {
// 设置最大显示行数
HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
// 滚动弹幕最大显示5行
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);
DanamakuAdapter danamakuAdapter = new DanamakuAdapter(mDanmakuView);
mDanmakuContext = DanmakuContext.create();
mDanmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false).setScrollSpeedFactor(1.2f).setScaleTextSize(1.2f).setCacheStuffer(new SpannedCacheStuffer(), // 图文混排使用SpannedCacheStuffer
danamakuAdapter).setMaximumLines(maxLinesPair).preventOverlapping(overlappingEnablePair);
if (mDanmakuView != null) {
//todo 替换成你的数据流
mParser = createParser(this.getResources().openRawResource(R.raw.comments));
mDanmakuView.setCallback(new master.flame.danmaku.controller.DrawHandler.Callback() {
@Override
public void updateTimer(DanmakuTimer timer) {
}
@Override
public void drawingFinished() {
}
@Override
public void danmakuShown(BaseDanmaku danmaku) {
}
@Override
public void prepared() {
if (getDanmakuView() != null) {
getDanmakuView().start();
if (getDanmakuStartSeekPosition() != -1) {
resolveDanmakuSeek(DanmakuVideoPlayer.this, getDanmakuStartSeekPosition());
setDanmakuStartSeekPosition(-1);
}
resolveDanmakuShow();
}
}
});
mDanmakuView.enableDanmakuDrawingCache(true);
}
}
use of master.flame.danmaku.danmaku.model.BaseDanmaku in project DanmakuFlameMaster by Bilibili.
the class UglyViewCacheStufferSampleActivity 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 MainActivity method findViews.
private void findViews() {
mMediaController = findViewById(R.id.media_controller);
mBtnRotate = (Button) findViewById(R.id.rotate);
mBtnHideDanmaku = (Button) findViewById(R.id.btn_hide);
mBtnShowDanmaku = (Button) findViewById(R.id.btn_show);
mBtnPauseDanmaku = (Button) findViewById(R.id.btn_pause);
mBtnResumeDanmaku = (Button) findViewById(R.id.btn_resume);
mBtnSendDanmaku = (Button) findViewById(R.id.btn_send);
mBtnSendDanmakuTextAndImage = (Button) findViewById(R.id.btn_send_image_text);
mBtnSendDanmakus = (Button) findViewById(R.id.btn_send_danmakus);
mBtnRotate.setOnClickListener(this);
mBtnHideDanmaku.setOnClickListener(this);
mMediaController.setOnClickListener(this);
mBtnShowDanmaku.setOnClickListener(this);
mBtnPauseDanmaku.setOnClickListener(this);
mBtnResumeDanmaku.setOnClickListener(this);
mBtnSendDanmaku.setOnClickListener(this);
mBtnSendDanmakuTextAndImage.setOnClickListener(this);
mBtnSendDanmakus.setOnClickListener(this);
// VideoView
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
// DanmakuView
// 设置最大显示行数
HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
// 滚动弹幕最大显示5行
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);
mDanmakuView = (IDanmakuView) findViewById(R.id.sv_danmaku);
mContext = DanmakuContext.create();
mContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false).setScrollSpeedFactor(1.2f).setScaleTextSize(1.2f).setCacheStuffer(new SpannedCacheStuffer(), // 图文混排使用SpannedCacheStuffer
mCacheStufferAdapter).setMaximumLines(maxLinesPair).preventOverlapping(overlappingEnablePair);
if (mDanmakuView != null) {
mParser = createParser(this.getResources().openRawResource(R.raw.comments));
mDanmakuView.setCallback(new master.flame.danmaku.controller.DrawHandler.Callback() {
@Override
public void updateTimer(DanmakuTimer timer) {
}
@Override
public void drawingFinished() {
}
@Override
public void danmakuShown(BaseDanmaku danmaku) {
// Log.d("DFM", "danmakuShown(): text=" + danmaku.text);
}
@Override
public void prepared() {
mDanmakuView.start();
}
});
mDanmakuView.setOnDanmakuClickListener(new IDanmakuView.OnDanmakuClickListener() {
@Override
public boolean onDanmakuClick(IDanmakus danmakus) {
Log.d("DFM", "onDanmakuClick: danmakus size:" + danmakus.size());
BaseDanmaku latest = danmakus.last();
if (null != latest) {
Log.d("DFM", "onDanmakuClick: text of latest danmaku:" + latest.text);
return true;
}
return false;
}
@Override
public boolean onViewClick(IDanmakuView view) {
mMediaController.setVisibility(View.VISIBLE);
return false;
}
});
mDanmakuView.prepare(mParser, mContext);
mDanmakuView.showFPS(true);
mDanmakuView.enableDanmakuDrawingCache(true);
}
if (mVideoView != null) {
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
}
});
mVideoView.setVideoPath(Environment.getExternalStorageDirectory() + "/1.flv");
}
}
Aggregations