去除右上角播放进度;配置加载优化(已内置ijk解码和ads);竖屏按钮播放短视频时才显示

pull/69/head
于俊 3 years ago
parent db366092ef
commit e631bcf02a
  1. 31
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  2. 24
      app/src/main/java/com/github/tvbox/osc/player/controller/VodController.java
  3. 1
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  4. 1
      app/src/main/java/com/github/tvbox/osc/ui/fragment/PlayFragment.java
  5. 8
      app/src/main/java/com/github/tvbox/osc/util/AdBlocker.java
  6. 26
      app/src/main/res/layout/player_vod_control_view.xml

@ -301,7 +301,7 @@ public class ApiConfig {
sb.setQuickSearch(DefaultConfig.safeJsonInt(obj, "quickSearch", 1));
sb.setFilterable(DefaultConfig.safeJsonInt(obj, "filterable", 1));
sb.setPlayerUrl(DefaultConfig.safeJsonString(obj, "playUrl", ""));
if(obj.has("ext") && (obj.get("ext").isJsonArray() || obj.get("ext").isJsonObject())){
if(obj.has("ext") && (obj.get("ext").isJsonObject() || obj.get("ext").isJsonArray())){
sb.setExt(obj.get("ext").toString());
}else {
sb.setExt(DefaultConfig.safeJsonString(obj, "ext", ""));
@ -354,11 +354,6 @@ public class ApiConfig {
liveChannelGroupList.clear(); //修复从后台切换重复加载频道列表
try {
String lives = infoJson.get("lives").getAsJsonArray().toString();
// if(lives.indexOf("group")==-1){
// String defaultLiveTxt="[{\"group\":\"redirect\",\"channels\":[{\"name\":\"redirect\",\"urls\":[\"proxy://do=live&type=txt&ext=defaultLiveTxt\"]}]}]";
// JsonArray fengMilives = infoJson.get("lives").getAsJsonArray();
// lives=defaultLiveTxt.replace("defaultLiveTxt",fengMilives.get(0).getAsJsonObject().get("url").getAsString());
// }
int index = lives.indexOf("proxy://");
if (index != -1) {
int endIndex = lives.lastIndexOf("\"");
@ -421,18 +416,30 @@ public class ApiConfig {
}
}
}
String defaultIJKADS="{\"ijk\":[{\"options\":[{\"name\":\"opensles\",\"category\":4,\"value\":\"0\"},{\"name\":\"overlay-format\",\"category\":4,\"value\":\"842225234\"},{\"name\":\"framedrop\",\"category\":4,\"value\":\"1\"},{\"name\":\"soundtouch\",\"category\":4,\"value\":\"1\"},{\"name\":\"start-on-prepared\",\"category\":4,\"value\":\"1\"},{\"name\":\"http-detect-rangeupport\",\"category\":1,\"value\":\"0\"},{\"name\":\"fflags\",\"category\":1,\"value\":\"fastseek\"},{\"name\":\"skip_loop_filter\",\"category\":2,\"value\":\"48\"},{\"name\":\"reconnect\",\"category\":4,\"value\":\"1\"},{\"name\":\"enable-accurateeek\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-auto-rotate\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-handle-resolution-change\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-hevc\",\"category\":4,\"value\":\"0\"},{\"name\":\"dns_cache_timeout\",\"category\":1,\"value\":\"600000000\"}],\"group\":\"软解码\"},{\"options\":[{\"name\":\"opensles\",\"category\":4,\"value\":\"0\"},{\"name\":\"overlay-format\",\"category\":4,\"value\":\"842225234\"},{\"name\":\"framedrop\",\"category\":4,\"value\":\"1\"},{\"name\":\"soundtouch\",\"category\":4,\"value\":\"1\"},{\"name\":\"start-on-prepared\",\"category\":4,\"value\":\"1\"},{\"name\":\"http-detect-rangeupport\",\"category\":1,\"value\":\"0\"},{\"name\":\"fflags\",\"category\":1,\"value\":\"fastseek\"},{\"name\":\"skip_loop_filter\",\"category\":2,\"value\":\"48\"},{\"name\":\"reconnect\",\"category\":4,\"value\":\"1\"},{\"name\":\"enable-accurateeek\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-auto-rotate\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-handle-resolution-change\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-hevc\",\"category\":4,\"value\":\"1\"},{\"name\":\"dns_cache_timeout\",\"category\":1,\"value\":\"600000000\"}],\"group\":\"硬解码\"}],\"ads\":[\"mimg.0c1q0l.cn\",\"www.googletagmanager.com\",\"www.google-analytics.com\",\"mc.usihnbcq.cn\",\"mg.g1mm3d.cn\",\"mscs.svaeuzh.cn\",\"cnzz.hhttm.top\",\"tp.vinuxhome.com\",\"cnzz.mmstat.com\",\"www.baihuillq.com\",\"s23.cnzz.com\",\"z3.cnzz.com\",\"c.cnzz.com\",\"stj.v1vo.top\",\"z12.cnzz.com\",\"img.mosflower.cn\",\"tips.gamevvip.com\",\"ehwe.yhdtns.com\",\"xdn.cqqc3.com\",\"www.jixunkyy.cn\",\"sp.chemacid.cn\",\"hm.baidu.com\",\"s9.cnzz.com\",\"z6.cnzz.com\",\"um.cavuc.com\",\"mav.mavuz.com\",\"wofwk.aoidf3.com\",\"z5.cnzz.com\",\"xc.hubeijieshikj.cn\",\"tj.tianwenhu.com\",\"xg.gars57.cn\",\"k.jinxiuzhilv.com\",\"cdn.bootcss.com\",\"ppl.xunzhuo123.com\",\"xomk.jiangjunmh.top\",\"img.xunzhuo123.com\",\"z1.cnzz.com\",\"s13.cnzz.com\",\"xg.huataisangao.cn\",\"z7.cnzz.com\",\"xg.huataisangao.cn\",\"z2.cnzz.com\",\"s96.cnzz.com\",\"q11.cnzz.com\",\"thy.dacedsfa.cn\",\"xg.whsbpw.cn\",\"s19.cnzz.com\",\"z8.cnzz.com\",\"s4.cnzz.com\",\"f5w.as12df.top\",\"ae01.alicdn.com\",\"www.92424.cn\",\"k.wudejia.com\",\"vivovip.mmszxc.top\",\"qiu.xixiqiu.com\",\"cdnjs.hnfenxun.com\",\"cms.qdwght.com\"]}";
JsonObject defaultJson=new Gson().fromJson(defaultIJKADS, JsonObject.class);
// 广告地址
if(infoJson.has("ads")){
for (JsonElement host : infoJson.getAsJsonArray("ads")) {
AdBlocker.addAdHost(host.getAsString());
if(AdBlocker.isEmpty()){
// AdBlocker.clear();
//追加的广告拦截
if(infoJson.has("ads")){
for (JsonElement host : infoJson.getAsJsonArray("ads")) {
AdBlocker.addAdHost(host.getAsString());
}
}else {
//默认广告拦截
for (JsonElement host : defaultJson.getAsJsonArray("ads")) {
AdBlocker.addAdHost(host.getAsString());
}
}
}
// IJK解码配置
ijkCodes = new ArrayList<>();
if(infoJson.has("ijk")){
if(ijkCodes==null){
ijkCodes = new ArrayList<>();
boolean foundOldSelect = false;
String ijkCodec = Hawk.get(HawkConfig.IJK_CODEC, "");
for (JsonElement opt : infoJson.get("ijk").getAsJsonArray()) {
for (JsonElement opt : defaultJson.get("ijk").getAsJsonArray()) {
JsonObject obj = (JsonObject) opt;
String name = obj.get("group").getAsString();
LinkedHashMap<String, String> baseOpt = new LinkedHashMap<>();

@ -101,10 +101,8 @@ public class VodController extends BaseController {
boolean mIsDragging;
LinearLayout mProgressRoot;
TextView mProgressText;
TextView seekTime;
ImageView mProgressIcon;
LinearLayout mBottomRoot;
LinearLayout bottomCenterContainer;
LinearLayout mTopRoot1;
LinearLayout mTopRoot2;
LinearLayout mParseRoot;
@ -150,9 +148,6 @@ public class VodController extends BaseController {
String width = Integer.toString(mControlWrapper.getVideoSize()[0]);
String height = Integer.toString(mControlWrapper.getVideoSize()[1]);
mVideoSize.setText("[ " + width + " X " + height +" ]");
int getCurrentPosition = (int) (mControlWrapper.getCurrentPosition() / 1000.0);
int getDuration = (int) (mControlWrapper.getDuration() / 1000.0);
seekTime.setText(String.format("%02d", getCurrentPosition / 60) + ":" + String.format("%02d", getCurrentPosition % 60) + " | " + String.format("%02d", getDuration / 60) + ":" + String.format("%02d", getDuration % 60));
mHandler.postDelayed(this, 1000);
}
@ -198,8 +193,6 @@ public class VodController extends BaseController {
mZimuBtn = findViewById(R.id.zimu_select);
mAudioTrackBtn = findViewById(R.id.audio_track_select);
mLandscapePortraitBtn = findViewById(R.id.landscape_portrait);
bottomCenterContainer = findViewById(R.id.tv_bottom_center_container);
seekTime = findViewById(R.id.tv_seek_time);
initSubtitleInfo();
@ -616,14 +609,17 @@ public class VodController extends BaseController {
hideBottom();
}
});
initLandscapePortraitBtnInfo();
}
public void initLandscapePortraitBtnInfo() {
double screenSqrt = ScreenUtils.getSqrt(mActivity);
if (screenSqrt < 20.0) {
mLandscapePortraitBtn.setVisibility(View.VISIBLE);
mLandscapePortraitBtn.setText("竖屏");
if(mControlWrapper!=null){
int width = mControlWrapper.getVideoSize()[0];
int height = mControlWrapper.getVideoSize()[1];
double screenSqrt = ScreenUtils.getSqrt(mActivity);
if (screenSqrt < 20.0 && width < height) {
mLandscapePortraitBtn.setVisibility(View.VISIBLE);
mLandscapePortraitBtn.setText("竖屏");
}
}
}
@ -809,11 +805,9 @@ public class VodController extends BaseController {
case VideoView.STATE_IDLE:
break;
case VideoView.STATE_PLAYING:
bottomCenterContainer.setVisibility(VISIBLE);
startProgress();
break;
case VideoView.STATE_PAUSED:
bottomCenterContainer.setVisibility(GONE);
mTopRoot1.setVisibility(GONE);
mTopRoot2.setVisibility(GONE);
mPlayTitle.setVisibility(VISIBLE);
@ -843,13 +837,11 @@ public class VodController extends BaseController {
}
void showBottom() {
bottomCenterContainer.setVisibility(GONE);
mHandler.removeMessages(1003);
mHandler.sendEmptyMessage(1002);
}
void hideBottom() {
bottomCenterContainer.setVisibility(VISIBLE);
mHandler.removeMessages(1002);
mHandler.sendEmptyMessage(1003);
}

@ -544,6 +544,7 @@ public class PlayActivity extends BaseActivity {
}
mVideoView.start();
mController.resetSpeed();
mController.initLandscapePortraitBtnInfo();
}
}
}

@ -542,6 +542,7 @@ public class PlayFragment extends BaseLazyFragment {
}
mVideoView.start();
mController.resetSpeed();
mController.initLandscapePortraitBtnInfo();
}
}
}

@ -9,6 +9,14 @@ import java.util.List;
public class AdBlocker {
private static final List<String> AD_HOSTS = new ArrayList<>();
public static void clear() {
AD_HOSTS.clear();
}
public static boolean isEmpty() {
return AD_HOSTS.isEmpty();
}
public static void addAdHost(String host) {
AD_HOSTS.add(host);
}

@ -85,32 +85,6 @@
android:textColor="@android:color/white"
android:textSize="@dimen/ts_20" />
</LinearLayout>
<LinearLayout
android:id="@+id/tv_bottom_center_container"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:tag="tv_top_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_gravity="right"
android:layout_marginRight="@dimen/vs_20"
android:layout_marginTop="@dimen/vs_10"
android:orientation="vertical">
<TextView
android:id="@+id/tv_seek_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="@dimen/vs_20"
android:paddingRight="@dimen/vs_20"
android:tag="vod_control_pause_time"
android:text="00:00 | 00:00"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_20" />
</LinearLayout>
<com.github.tvbox.osc.subtitle.widget.SimpleSubtitleView
android:id="@+id/subtitle_view"

Loading…
Cancel
Save