use of master.flame.danmaku.danmaku.model.android.Danmakus 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.android.Danmakus in project ABPlayer by winkstu.
the class BiliVideoViewActivity method createParser.
private BaseDanmakuParser createParser(String uri) {
InputStream stream = null;
if (uri == null) {
return new BaseDanmakuParser() {
@Override
protected Danmakus parse() {
return new Danmakus();
}
};
}
try {
Response rsp = (Response) Jsoup.connect(uri).execute();
stream = new ByteArrayInputStream(CompressionTools.decompressXML(rsp.bodyAsBytes()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (DataFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
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;
}
use of master.flame.danmaku.danmaku.model.android.Danmakus in project ABPlayer by winkstu.
the class BiliVideoViewActivity method createParser.
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;
}
use of master.flame.danmaku.danmaku.model.android.Danmakus in project GSYVideoPlayer by CarGuo.
the class DanmakuVideoPlayer method createParser.
/**
* 创建解析器对象,解析输入流
*
* @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;
}
use of master.flame.danmaku.danmaku.model.android.Danmakus in project bilibili-android-client by HotBitmapGG.
the class BiliDanmukuDownloadUtil method downloadXML.
public static Observable<BaseDanmakuParser> downloadXML(final String uri) {
return Observable.create(new Observable.OnSubscribe<BaseDanmakuParser>() {
@Override
public void call(final Subscriber<? super BaseDanmakuParser> subscriber) {
if (TextUtils.isEmpty(uri)) {
subscriber.onNext(new BaseDanmakuParser() {
@Override
protected IDanmakus parse() {
return new Danmakus();
}
});
}
ILoader loader = null;
try {
HttpConnection.Response rsp = (HttpConnection.Response) Jsoup.connect(uri).timeout(20000).execute();
InputStream stream = new ByteArrayInputStream(BiliDanmukuCompressionTools.decompressXML(rsp.bodyAsBytes()));
loader = DanmakuLoaderFactory.create(DanmakuLoaderFactory.TAG_BILI);
loader.load(stream);
} catch (IOException | DataFormatException | IllegalDataException e) {
e.printStackTrace();
}
BaseDanmakuParser parser = new BiliDanmukuParser();
assert loader != null;
IDataSource<?> dataSource = loader.getDataSource();
parser.load(dataSource);
subscriber.onNext(parser);
}
}).subscribeOn(Schedulers.io());
}
Aggregations