|
|
|
|
@ -4,6 +4,7 @@ import com.fongmi.android.tv.App; |
|
|
|
|
import com.fongmi.android.tv.api.LiveConfig; |
|
|
|
|
import com.fongmi.android.tv.bean.Core; |
|
|
|
|
import com.fongmi.android.tv.player.Source; |
|
|
|
|
import com.fongmi.android.tv.utils.Notify; |
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
|
import com.tvbus.engine.Listener; |
|
|
|
|
import com.tvbus.engine.TVCore; |
|
|
|
|
@ -12,6 +13,7 @@ public class TVBus implements Source.Extractor, Listener { |
|
|
|
|
|
|
|
|
|
private TVCore tvcore; |
|
|
|
|
private String hls; |
|
|
|
|
private Core core; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean match(String scheme, String host) { |
|
|
|
|
@ -19,7 +21,7 @@ public class TVBus implements Source.Extractor, Listener { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void init(Core core) { |
|
|
|
|
tvcore = new TVCore(core.getSign(), core.getSo()); |
|
|
|
|
tvcore = new TVCore(core.getSo(), core.getSign()); |
|
|
|
|
tvcore.auth(core.getAuth()).broker(core.getBroker()); |
|
|
|
|
tvcore.name(core.getName()).pass(core.getPass()); |
|
|
|
|
tvcore.serv(0).play(8902).mode(1).listener(this); |
|
|
|
|
@ -28,7 +30,8 @@ public class TVBus implements Source.Extractor, Listener { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String fetch(String url) throws Exception { |
|
|
|
|
if (tvcore == null) init(LiveConfig.get().getHome().getCore()); |
|
|
|
|
if (core != null && !core.equals(LiveConfig.get().getHome().getCore())) change(); |
|
|
|
|
if (tvcore == null) init(core = LiveConfig.get().getHome().getCore()); |
|
|
|
|
tvcore.start(url); |
|
|
|
|
onWait(); |
|
|
|
|
return hls; |
|
|
|
|
@ -46,6 +49,11 @@ public class TVBus implements Source.Extractor, Listener { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void change() { |
|
|
|
|
App.post(() -> Notify.show("內核已切換,正在重新啟動。")); |
|
|
|
|
App.post(() -> System.exit(0), 1000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void stop() { |
|
|
|
|
if (tvcore != null) tvcore.stop(); |
|
|
|
|
@ -54,7 +62,8 @@ public class TVBus implements Source.Extractor, Listener { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void exit() { |
|
|
|
|
if (tvcore != null) System.exit(0); |
|
|
|
|
if (tvcore != null) tvcore.quit(); |
|
|
|
|
tvcore = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|