fix 指定直播playerType的bug;

main
21561 11 months ago
parent 826550e1f1
commit 36e4caafae
  1. 4
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  2. 15
      app/src/main/java/com/github/tvbox/osc/bean/LivePlayerManager.java

@ -876,11 +876,15 @@ public class ApiConfig {
if(livesOBJ.has("epg")){
String epg =livesOBJ.get("epg").getAsString();
Hawk.put(HawkConfig.EPG_URL,epg);
}else {
Hawk.put(HawkConfig.EPG_URL,"");
}
//直播播放器类型
if(livesOBJ.has("playerType")){
String livePlayType =livesOBJ.get("playerType").getAsString();
Hawk.put(HawkConfig.LIVE_PLAY_TYPE,livePlayType);
}else {
Hawk.put(HawkConfig.LIVE_PLAY_TYPE,Hawk.get(HawkConfig.PLAY_TYPE, 0));
}
//设置UA
if(livesOBJ.has("header")) {

@ -1,9 +1,7 @@
package com.github.tvbox.osc.bean;
import androidx.annotation.NonNull;
import androidx.exifinterface.media.ExifInterface;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.PlayerHelper;
import com.orhanobut.hawk.Hawk;
@ -11,17 +9,16 @@ import com.orhanobut.hawk.Hawk;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Objects;
import xyz.doikki.videoplayer.player.VideoView;
public class LivePlayerManager {
JSONObject defaultPlayerConfig = new JSONObject();
JSONObject currentPlayerConfig;
private String currentApi="";
public void init(VideoView videoView) {
try {
currentApi=Hawk.get(HawkConfig.LIVE_API_URL,"");
defaultPlayerConfig.put("pl", Hawk.get(HawkConfig.LIVE_PLAY_TYPE, Hawk.get(HawkConfig.PLAY_TYPE, 0)));
defaultPlayerConfig.put("ijk", Hawk.get(HawkConfig.IJK_CODEC, "硬解码"));
defaultPlayerConfig.put("pr", Hawk.get(HawkConfig.PLAY_RENDER, 0));
@ -42,6 +39,7 @@ public class LivePlayerManager {
}
public void getLiveChannelPlayer(VideoView videoView, String channelName) {
channelName=currentCfgKey(channelName);
JSONObject playerConfig = Hawk.get(channelName, null);
if (playerConfig == null) {
if (!currentPlayerConfig.toString().equals(defaultPlayerConfig.toString()))
@ -101,6 +99,7 @@ public class LivePlayerManager {
}
public void changeLivePlayerType(VideoView videoView, int playerType, String channelName) {
channelName=currentCfgKey(channelName);
JSONObject playerConfig = currentPlayerConfig;
try {
switch (playerType) {
@ -135,6 +134,7 @@ public class LivePlayerManager {
}
public void changeLivePlayerScale(@NonNull VideoView videoView, int playerScale, String channelName){
channelName=currentCfgKey(channelName);
videoView.setScreenScaleType(playerScale);
JSONObject playerConfig = currentPlayerConfig;
@ -150,4 +150,9 @@ public class LivePlayerManager {
currentPlayerConfig = playerConfig;
}
private String currentCfgKey(String channelName)
{
return currentApi+"_"+channelName;
}
}
Loading…
Cancel
Save