We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
private fun createParser( context: Context, stream: InputStream? ): BaseDanmakuParser? { val parser: BaseDanmakuParser = object : BaseDanmakuParser() { override fun parse(): Danmakus { return Danmakus() } } if (stream == null) return parser val loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_ACFUN) val funParser = AcFunDanmuParser(context) try { loader.load(stream) funParser.load(loader.dataSource) return funParser } catch (e: IllegalDataException) { e.printStackTrace() } return parser }
class AcFunDanmuParser(val context: Context) : BaseDanmakuParser() { override fun parse(): IDanmakus { return if (this.mDataSource != null && this.mDataSource is JSONSource) { val jsonSource = this.mDataSource as JSONSource doParse(jsonSource.data()) } else { Danmakus() } } private fun doParse(data: JSONArray?): Danmakus { var danmakus = Danmakus() return if (data != null && data.length() != 0) { for (i in 0 until data.length()) { try { val jsonObj = data.getJSONObject(i) if (jsonObj != null) { danmakus = realParse(i, jsonObj, danmakus) } } catch (e: JSONException) { e.printStackTrace() } } danmakus } else { danmakus } } private fun realParse(index: Int, obj: JSONObject, danmakus: Danmakus): Danmakus { if (obj.length() != 0) { try { //{"content":"真好看","picUrl":"http://...png"} val content = obj.optString("content") val picUrl = obj.optString("picUrl") val item = this.mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL,this.mContext) GlideUtil.convertUrl2Bitmap(context, picUrl, object : GlideUtil.Url2BitmapCallback { override fun url2BitmapSuccess(bitmap: Bitmap?) { val dataMap = HashMap<String, Any?>() dataMap["content"] = content dataMap["bitmap"] = BitmapUtil.getDanmuBitmap(bitmap) dataMap["color"] = "#80000000" item.tag = dataMap item.padding = 5 item.priority = 0 item.isLive = false item.time = System.currentTimeMillis() + index * 1000 item.textSize = 0f // 重要:如果有图文混排,最好不要设置描边(设textShadowColor=0),否则会进行两次复杂的绘制导致运行效率降低 item.textShadowColor = 0 danmakus.addItem(item) //Logger.e("parser=${content}--${picUrl}") } override fun url2BitmapFailed(e: GlideException?) { } }) } catch (e: Exception) { Logger.e("error=${e.message}") e.printStackTrace() } return danmakus } else { return danmakus } } }
打log发现,解析过程都是走的,但是就不显示弹幕?why?
The text was updated successfully, but these errors were encountered:
是否切换了线程上下文
Sorry, something went wrong.
又或者弹幕渲染器不支持你这种解析后的结果?
No branches or pull requests
打log发现,解析过程都是走的,但是就不显示弹幕?why?
The text was updated successfully, but these errors were encountered: