BiliDanmukuParser.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:HeroVideo-master 作者:
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    String tagName = localName.length() != 0 ? localName : qName;
    tagName = tagName.toLowerCase(Locale.getDefault()).trim();
    if (tagName.equals("d")) {
        // <d p="23.826000213623,1,25,16777215,1422201084,0,057075e9,757076900">我从未见过如此厚颜无耻之猴</d>
        // 0:时间(弹幕出现时间)
        // 1:类型(1从右至左滚动弹幕|6从左至右滚动弹幕|5顶端固定弹幕|4底端固定弹幕|7高级弹幕|8脚本弹幕)
        // 2:字号
        // 3:颜色
        // 4:时间戳 ?
        // 5:弹幕池id
        // 6:用户hash
        // 7:弹幕id
        String pValue = attributes.getValue("p");
        // parse p value to danmaku
        String[] values = pValue.split(",");
        if (values.length > 0) {
            long time = (long) (Float.parseFloat(values[0]) * 1000); // 出现时间
            int type = Integer.parseInt(values[1]); // 弹幕类型
            float textSize = Float.parseFloat(values[2]); // 字体大小
            int color = (int) ((0x00000000ff000000 | Long.parseLong(values[3])) & 0x00000000ffffffff); // 颜色
            // int poolType = Integer.parseInt(values[5]); // 弹幕池类型(忽略
            item = mContext.mDanmakuFactory.createDanmaku(type, mContext);
            if (item != null) {
                item.setTime(time);
                item.textSize = textSize * (mDispDensity - 0.6f);
                item.textColor = color;
                item.textShadowColor = color <= Color.BLACK ? Color.WHITE : Color.BLACK;
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号