master.flame.danmaku.danmaku.model.android.Danmakus Java Examples

The following examples show how to use master.flame.danmaku.danmaku.model.android.Danmakus. 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: VideoViewLiveActivity.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
private BaseDanmakuParser createParser(InputStream stream) {
    if (stream == null) {
        return new BaseDanmakuParser() {
            @Override
            protected Danmakus parse() {
                return new Danmakus();
            }
        };
    }
    ILoader loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_BILI);
    try {
        loader.load(stream);
    } catch (IllegalDataException e) {
        e.printStackTrace();
    }
    BaseDanmakuParser parser = new BiliDanmukuParser();
    IDataSource<?> dataSource = loader.getDataSource();
    parser.load(dataSource);
    return parser;

}
 
Example #2
Source File: VideoViewActivity.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
private BaseDanmakuParser createParser(InputStream stream) {
    if (stream == null) {
        return new BaseDanmakuParser() {
            @Override
            protected Danmakus parse() {
                return new Danmakus();
            }
        };
    }
    ILoader loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_BILI);
    try {
        loader.load(stream);
    } catch (IllegalDataException e) {
        e.printStackTrace();
    }
    BaseDanmakuParser parser = new BiliDanmukuParser();
    IDataSource<?> dataSource = loader.getDataSource();
    parser.load(dataSource);
    return parser;

}
 
Example #3
Source File: AcFunDanmakuParser.java    From letv with Apache License 2.0 6 votes vote down vote up
private Danmakus doParse(JSONArray danmakuListData) {
    Danmakus danmakus = new Danmakus();
    if (danmakuListData == null || danmakuListData.length() == 0) {
        return danmakus;
    }
    for (int i = 0; i < danmakuListData.length(); i++) {
        try {
            JSONObject danmakuArray = danmakuListData.getJSONObject(i);
            if (danmakuArray != null) {
                danmakus = _parse(danmakuArray, danmakus);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return danmakus;
}
 
Example #4
Source File: DanmakuVideoPlayer.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 创建解析器对象,解析输入流

 @param stream
 @return
 */
private BaseDanmakuParser createParser(InputStream stream) {

    if (stream == null) {
        return new BaseDanmakuParser() {

            @Override
            protected Danmakus parse() {
                return new Danmakus();
            }
        };
    }

    ILoader loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_BILI);

    try {
        loader.load(stream);
    } catch (IllegalDataException e) {
        e.printStackTrace();
    }
    BaseDanmakuParser parser = new BiliDanmukuParser();
    IDataSource<?> dataSource = loader.getDataSource();
    parser.load(dataSource);
    return parser;

}
 
Example #5
Source File: BiliDanmukuParser.java    From letv with Apache License 2.0 6 votes vote down vote up
public Danmakus parse() {
    if (this.mDataSource != null) {
        AndroidFileSource source = this.mDataSource;
        try {
            XMLReader xmlReader = XMLReaderFactory.createXMLReader();
            XmlContentHandler contentHandler = new XmlContentHandler();
            xmlReader.setContentHandler(contentHandler);
            xmlReader.parse(new InputSource(source.data()));
            return contentHandler.getResult();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }
    return null;
}
 
Example #6
Source File: DanmakuTouchHelper.java    From letv with Apache License 2.0 6 votes vote down vote up
public IDanmakus touchHitDanmaku(float x, float y) {
    IDanmakus hitDanmakus = new Danmakus();
    this.mDanmakuBounds.setEmpty();
    IDanmakus danmakus = this.danmakuView.getCurrentVisibleDanmakus();
    if (danmakus != null && !danmakus.isEmpty()) {
        IDanmakuIterator iterator = danmakus.iterator();
        while (iterator.hasNext()) {
            BaseDanmaku danmaku = iterator.next();
            if (danmaku != null) {
                this.mDanmakuBounds.set(danmaku.getLeft(), danmaku.getTop() - 30.0f, danmaku.getRight(), danmaku.getBottom() + 30.0f);
                if (this.mDanmakuBounds.contains(x, y)) {
                    danmaku.clickX = x;
                    danmaku.clickY = y;
                    danmaku.setRectF(this.mDanmakuBounds);
                    hitDanmakus.addItem(danmaku);
                    break;
                }
            }
        }
    }
    return hitDanmakus;
}
 
Example #7
Source File: DanmakuHelper.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
public static BaseDanmakuParser createParser(InputStream stream) {

        if (stream == null) {
            return new BaseDanmakuParser() {

                @Override
                protected Danmakus parse() {
                    return new Danmakus();
                }
            };
        }

//        ILoader loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_BILI);
        ILoader loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_ACFUN);

        try {
            loader.load(stream);
        } catch (IllegalDataException e) {
            e.printStackTrace();
        }
//        BaseDanmakuParser parser = new BiliDanmukuParser();
        BaseDanmakuParser parser = new AcFunDanmakuParser();
        IDataSource<?> dataSource = loader.getDataSource();
        parser.load(dataSource);

        return parser;
    }
 
Example #8
Source File: QSDanmakuParser.java    From QSVideoPlayer with Apache License 2.0 5 votes vote down vote up
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 #9
Source File: DrawTask.java    From letv with Apache License 2.0 5 votes vote down vote up
public IDanmakus getVisibleDanmakusOnTime(long time) {
    IDanmakus subDanmakus = this.danmakuList.subnew((time - this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION) - 100, time + this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION);
    IDanmakus visibleDanmakus = new Danmakus();
    if (!(subDanmakus == null || subDanmakus.isEmpty())) {
        IDanmakuIterator iterator = subDanmakus.iterator();
        while (iterator.hasNext()) {
            BaseDanmaku danmaku = iterator.next();
            if (danmaku.isShown() && !danmaku.isOutside()) {
                visibleDanmakus.addItem(danmaku);
            }
        }
    }
    return visibleDanmakus;
}
 
Example #10
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
private RLDanmakusRetainer() {
    this.mVisibleDanmakus = new Danmakus(1);
    this.mCancelFixingFlag = false;
}
 
Example #11
Source File: LivePlayActivity.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    return new Danmakus();
}
 
Example #12
Source File: BiliDanmukuParser.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
public Danmakus getResult() {
    return result;
}
 
Example #13
Source File: BiliDanmukuParser.java    From HeroVideo-master with Apache License 2.0 4 votes vote down vote up
@Override
public void startDocument() throws SAXException {
    result = new Danmakus();
}
 
Example #14
Source File: BiliDanmukuParser.java    From HeroVideo-master with Apache License 2.0 4 votes vote down vote up
public Danmakus getResult() {
    return result;
}
 
Example #15
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
private FBDanmakusRetainer() {
    super();
    this.mVisibleDanmakus = new Danmakus(2);
}
 
Example #16
Source File: GameBaseActivity.java    From kcanotify_h5-master with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    return new Danmakus();
}
 
Example #17
Source File: BiliDanmukuParser.java    From letv with Apache License 2.0 4 votes vote down vote up
public void startDocument() throws SAXException {
    this.result = new Danmakus();
}
 
Example #18
Source File: BiliDanmukuParser.java    From letv with Apache License 2.0 4 votes vote down vote up
public Danmakus getResult() {
    return this.result;
}
 
Example #19
Source File: AcFunDanmakuParser.java    From letv with Apache License 2.0 4 votes vote down vote up
public Danmakus parse() {
    if (this.mDataSource == null || !(this.mDataSource instanceof JSONSource)) {
        return new Danmakus();
    }
    return doParse(this.mDataSource.data());
}
 
Example #20
Source File: MyDanmakuView.java    From DKVideoPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    return new Danmakus();
}
 
Example #21
Source File: BiliDanmukuParser.java    From HeroVideo-master with Apache License 2.0 4 votes vote down vote up
@Override
public void startDocument() throws SAXException {
    result = new Danmakus();
}
 
Example #22
Source File: BiliDanmukuParser.java    From HeroVideo-master with Apache License 2.0 4 votes vote down vote up
public Danmakus getResult() {
    return result;
}