mirror of https://github.com/FongMi/TV.git
parent
38c717d6b3
commit
c69eefb152
@ -0,0 +1,55 @@ |
||||
package com.fongmi.android.tv.player.source; |
||||
|
||||
import com.fongmi.android.tv.net.OkHttp; |
||||
import com.fongmi.android.tv.utils.FileUtil; |
||||
|
||||
public class ZLive { |
||||
|
||||
private final String BASE = "http://127.0.0.1:6677/stream/"; |
||||
private boolean init; |
||||
|
||||
private static class Loader { |
||||
static volatile ZLive INSTANCE = new ZLive(); |
||||
} |
||||
|
||||
public static ZLive get() { |
||||
return Loader.INSTANCE; |
||||
} |
||||
|
||||
public void init() { |
||||
com.east.android.zlive.ZLive.INSTANCE.OnLiveStart(6677); |
||||
init = true; |
||||
} |
||||
|
||||
private String getLive(String uuid) { |
||||
return BASE + "live?uuid=" + uuid; |
||||
} |
||||
|
||||
private String getOpen(String uuid) { |
||||
return BASE + "open?uuid=" + uuid; |
||||
} |
||||
|
||||
public String fetch(String url) { |
||||
try { |
||||
if (!init) init(); |
||||
String[] split = url.split("/"); |
||||
String server = split[2]; |
||||
String uuid = split[3]; |
||||
String param = "&group=5850&mac=00:00:00:00:00:00&dir="; |
||||
String result = getLive(uuid) + "&server=" + server + param + FileUtil.getCachePath(); |
||||
OkHttp.newCall(getOpen(uuid)).execute(); |
||||
return result; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return url; |
||||
} |
||||
} |
||||
|
||||
public void stop() { |
||||
try { |
||||
if (init) com.east.android.zlive.ZLive.INSTANCE.OnLiveStop(); |
||||
} catch (Throwable e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1 @@ |
||||
/build |
||||
@ -0,0 +1,16 @@ |
||||
plugins { |
||||
id 'com.android.library' |
||||
} |
||||
|
||||
android { |
||||
compileSdk 33 |
||||
|
||||
defaultConfig { |
||||
minSdk 21 |
||||
targetSdk 29 |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
api 'net.java.dev.jna:jna:5.12.1' |
||||
} |
||||
@ -0,0 +1,2 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<manifest package="com.east.android.zlive" /> |
||||
@ -0,0 +1,13 @@ |
||||
package com.east.android.zlive; |
||||
|
||||
import com.sun.jna.Library; |
||||
import com.sun.jna.Native; |
||||
|
||||
public interface ZLive extends Library { |
||||
|
||||
ZLive INSTANCE = Native.load("core", ZLive.class); |
||||
|
||||
void OnLiveStart(long port); |
||||
|
||||
void OnLiveStop(); |
||||
} |
||||
Loading…
Reference in new issue