mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-06-03 00:58:06 -04:00
集成libvlc-3.5.1
This commit is contained in:
parent
bf265a86ab
commit
65b723d064
@ -1,5 +1,4 @@
|
||||
Jellyfin androidtv client
|
||||
|
||||
android 4.2以上
|
||||
|
||||
jellyfin8.1以上
|
||||
jellyfin安卓TV客户端,支持安卓4.2以上。
|
||||
在安卓4.4及以下环境中运行时,集成的VLC播放器可能无法播放HTTPS,可在右上角菜单勾选"调用外部播放器"选项,使用外部播放器播放。
|
||||
支持jellyfin8.1以上
|
||||
|
@ -5,7 +5,6 @@ import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.lzy.okgo.OkGo;
|
||||
@ -18,10 +17,19 @@ import org.sifacai.vlcjellyfin.Bean.Items;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class JfClient {
|
||||
@ -41,6 +49,70 @@ public class JfClient {
|
||||
stop
|
||||
}
|
||||
|
||||
/**
|
||||
* description 忽略https证书验证
|
||||
*
|
||||
* @author yanzy
|
||||
* @version 1.0
|
||||
* @date 2021/9/8 14:42
|
||||
*/
|
||||
private static TrustManager[] getTrustManager() {
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
return trustAllCerts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* description 忽略https证书验证
|
||||
*`在这里插入代码片`
|
||||
* @author yanzy
|
||||
* @version 1.0
|
||||
* @date 2021/9/8 14:42
|
||||
*/
|
||||
public static SSLSocketFactory getSSLSocketFactory() {
|
||||
try {
|
||||
SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, getTrustManager(), new SecureRandom());
|
||||
return sslContext.getSocketFactory();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* description 忽略https证书验证
|
||||
*
|
||||
* @author yanzy
|
||||
* @version 1.0
|
||||
* @date 2021/9/8 14:42
|
||||
*/
|
||||
public static HostnameVerifier getHostnameVerifier() {
|
||||
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String s, SSLSession sslSession) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return hostnameVerifier;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化配置
|
||||
*
|
||||
@ -50,6 +122,8 @@ public class JfClient {
|
||||
config = new Config(application);
|
||||
SetHeaders();
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.sslSocketFactory(getSSLSocketFactory());
|
||||
builder.hostnameVerifier(getHostnameVerifier());
|
||||
builder.connectTimeout(5, TimeUnit.SECONDS);
|
||||
builder.readTimeout(3, TimeUnit.SECONDS);
|
||||
builder.writeTimeout(5, TimeUnit.SECONDS);
|
||||
|
@ -15,6 +15,7 @@ import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.videolan.libvlc.Dialog;
|
||||
import org.videolan.libvlc.LibVLC;
|
||||
import org.videolan.libvlc.Media;
|
||||
import org.videolan.libvlc.MediaPlayer;
|
||||
@ -87,11 +88,49 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
||||
vlcoptions.add("-v");
|
||||
vlcVideoLayout = findViewById(R.id.VideoView);
|
||||
libVLC = new LibVLC(this,vlcoptions);
|
||||
Dialog.setCallbacks(libVLC,callbacks);
|
||||
|
||||
mediaPlayer = new MediaPlayer(libVLC);
|
||||
mediaPlayer.attachViews(vlcVideoLayout, null, true, false);
|
||||
mediaPlayer.setEventListener(this);
|
||||
}
|
||||
|
||||
Dialog.Callbacks callbacks = new Dialog.Callbacks() {
|
||||
@Override
|
||||
public void onDisplay(Dialog.ErrorMessage dialog) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplay(Dialog.LoginDialog dialog) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplay(Dialog.QuestionDialog dialog) {
|
||||
if(dialog.getQuestionType() == 1){
|
||||
dialog.postAction(1);
|
||||
}else {
|
||||
Log.d(TAG, "onDisplay_QuestionDialog: " + dialog.getQuestionType() + " : " + dialog.getTitle() + " : " + dialog.getText());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplay(Dialog.ProgressDialog dialog) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(Dialog dialog) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressUpdate(Dialog.ProgressDialog dialog) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onEvent(MediaPlayer.Event event) {
|
||||
switch (event.type) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user