mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-06-03 00:58:06 -04:00
修改详情页
This commit is contained in:
parent
e926adf005
commit
ad98cbf192
@ -122,10 +122,10 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
|||||||
if (mstype.equals("Video")) {
|
if (mstype.equals("Video")) {
|
||||||
video += ms.getDisplayTitle();
|
video += ms.getDisplayTitle();
|
||||||
} else if (mstype.equals("Audio")) {
|
} else if (mstype.equals("Audio")) {
|
||||||
if (!ms.getLanguage().equals("")) audio += ms.getLanguage() + "、";
|
if (ms.getLanguage()!=null && !ms.getLanguage().equals("")) audio += ms.getLanguage() + "、";
|
||||||
else audio += ms.getCodec() + ";";
|
else audio += ms.getCodec() + ";";
|
||||||
} else if (mstype.equals("Subtitle")) {
|
} else if (mstype.equals("Subtitle")) {
|
||||||
if (!ms.getLanguage().equals("")) subtitle += ms.getLanguage() + "、";
|
if (ms.getLanguage() != null && !ms.getLanguage().equals("")) subtitle += ms.getLanguage() + "、";
|
||||||
else subtitle += ms.getCodec() + ";";
|
else subtitle += ms.getCodec() + ";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,23 +38,6 @@ public class HomeActivity extends BaseActivity {
|
|||||||
tvContiner = findViewById(R.id.tvItems);
|
tvContiner = findViewById(R.id.tvItems);
|
||||||
|
|
||||||
JfClient.init(getApplication());
|
JfClient.init(getApplication());
|
||||||
|
|
||||||
if (JfClient.AccessToken.equals("") || JfClient.UserId.equals("")) {
|
|
||||||
showLoadingDialog("正在验证服务器地址!");
|
|
||||||
JfClient.VerityServerUrl(JfClient.config.getJellyfinUrl(), new JfClient.JJCallBack() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Boolean bool) {
|
|
||||||
setLoadingText("正在验证用户名和密码!");
|
|
||||||
JfClient.AuthenticateByName(JfClient.config.getUserName(), JfClient.config.getPassWord(), new JfClient.JJCallBack() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Boolean bool) {
|
|
||||||
dismissLoadingDialog();
|
|
||||||
initView();
|
|
||||||
}
|
|
||||||
}, connErr, false);
|
|
||||||
}
|
|
||||||
}, connErr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JfClient.JJCallBack connErr = new JfClient.JJCallBack() {
|
private JfClient.JJCallBack connErr = new JfClient.JJCallBack() {
|
||||||
@ -69,10 +52,14 @@ public class HomeActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
initView();
|
initData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录框
|
||||||
|
*/
|
||||||
private void showLoginDialog() {
|
private void showLoginDialog() {
|
||||||
|
Log.d(TAG, "showLoginDialog: 跳出登录框");
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
AlertDialog alert = builder.setTitle("登录")
|
AlertDialog alert = builder.setTitle("登录")
|
||||||
.setMessage("请输入登录信息")
|
.setMessage("请输入登录信息")
|
||||||
@ -129,6 +116,27 @@ public class HomeActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initData(){
|
||||||
|
if (JfClient.AccessToken.equals("") || JfClient.UserId.equals("")) {
|
||||||
|
showLoadingDialog("正在验证服务器地址!");
|
||||||
|
JfClient.VerityServerUrl(JfClient.config.getJellyfinUrl(), new JfClient.JJCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean bool) {
|
||||||
|
setLoadingText("正在验证用户名和密码!");
|
||||||
|
JfClient.AuthenticateByName(JfClient.config.getUserName(), JfClient.config.getPassWord(), new JfClient.JJCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean bool) {
|
||||||
|
dismissLoadingDialog();
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
}, connErr, false);
|
||||||
|
}
|
||||||
|
}, connErr);
|
||||||
|
}else{
|
||||||
|
Log.d(TAG, "initData: 跳出");
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
showLoadingDialog("正在加载首页…………");
|
showLoadingDialog("正在加载首页…………");
|
||||||
@ -144,11 +152,11 @@ public class HomeActivity extends BaseActivity {
|
|||||||
public void onSuccess(Items latests) {
|
public void onSuccess(Items latests) {
|
||||||
addRowTvRecyclerView("新的 " + item.getName(), latests.getItems(), false);
|
addRowTvRecyclerView("新的 " + item.getName(), latests.getItems(), false);
|
||||||
}
|
}
|
||||||
}, null);
|
}, errcb);
|
||||||
}
|
}
|
||||||
dismissLoadingDialog();
|
dismissLoadingDialog();
|
||||||
}
|
}
|
||||||
}, null);
|
}, errcb);
|
||||||
JfClient.GetResume(new JfClient.JJCallBack() {
|
JfClient.GetResume(new JfClient.JJCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Items resumes) {
|
public void onSuccess(Items resumes) {
|
||||||
@ -159,10 +167,9 @@ public class HomeActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
addRowTvRecyclerView("最近播放", resumes.getItems(), false);
|
addRowTvRecyclerView("最近播放", resumes.getItems(), false);
|
||||||
}
|
}
|
||||||
}, null);
|
}, errcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加类别行
|
* 添加类别行
|
||||||
*/
|
*/
|
||||||
@ -216,4 +223,12 @@ public class HomeActivity extends BaseActivity {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JfClient.JJCallBack errcb = new JfClient.JJCallBack(){
|
||||||
|
@Override
|
||||||
|
public void onError(String str) {
|
||||||
|
dismissLoadingDialog();
|
||||||
|
ShowToask(str);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -406,6 +406,10 @@ public class JfClient {
|
|||||||
* @param cb
|
* @param cb
|
||||||
*/
|
*/
|
||||||
public static void AuthenticateByName(String username, String password, JJCallBack cb, JJCallBack err, boolean saveUser) {
|
public static void AuthenticateByName(String username, String password, JJCallBack cb, JJCallBack err, boolean saveUser) {
|
||||||
|
if(username.equals("") || password.equals("")){
|
||||||
|
err.onError("用户名和密码验证失败!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String url = config.getJellyfinUrl() + "/Users/authenticatebyname";
|
String url = config.getJellyfinUrl() + "/Users/authenticatebyname";
|
||||||
String reqjson = "{\"Username\":\"" + username + "\",\"Pw\":\"" + password + "\"}";
|
String reqjson = "{\"Username\":\"" + username + "\",\"Pw\":\"" + password + "\"}";
|
||||||
SendPost(url, reqjson, new JJCallBack() {
|
SendPost(url, reqjson, new JJCallBack() {
|
||||||
@ -461,29 +465,27 @@ public class JfClient {
|
|||||||
* @param cb
|
* @param cb
|
||||||
*/
|
*/
|
||||||
public static void VerityServerUrl(String url, JJCallBack cb, JJCallBack err) {
|
public static void VerityServerUrl(String url, JJCallBack cb, JJCallBack err) {
|
||||||
if (url.length() > 0) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
SendGet(url + "/system/info/public", new JJCallBack() {
|
||||||
SendGet(url + "/system/info/public", new JJCallBack() {
|
@Override
|
||||||
@Override
|
public void onSuccess(String str) {
|
||||||
public void onSuccess(String str) {
|
try {
|
||||||
try {
|
JsonObject serverInfo = new Gson().fromJson(str, JsonObject.class);
|
||||||
JsonObject serverInfo = new Gson().fromJson(str, JsonObject.class);
|
String ServerId = "";
|
||||||
String ServerId = "";
|
ServerId = serverInfo.get("Id").getAsString();
|
||||||
ServerId = serverInfo.get("Id").getAsString();
|
if (ServerId == null || ServerId.length() == 0) {
|
||||||
if (ServerId == null || ServerId.length() == 0) {
|
err.onError("服务器连接失败!");
|
||||||
err.onError("服务器连接失败!");
|
} else {
|
||||||
} else {
|
config.setJellyfinUrl(url);
|
||||||
config.setJellyfinUrl(url);
|
cb.onSuccess(true);
|
||||||
cb.onSuccess(true);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
err.onError(e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
err.onError(e.getMessage());
|
||||||
}
|
}
|
||||||
}, err);
|
}
|
||||||
}
|
}, err);
|
||||||
} else {
|
} else {
|
||||||
err.onError("服务器地址不能为空!");
|
err.onError("服务器地址不正确!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ import android.widget.SeekBar;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.videolan.libvlc.LibVLC;
|
import org.videolan.libvlc.LibVLC;
|
||||||
|
import org.videolan.libvlc.Media;
|
||||||
|
import org.videolan.libvlc.MediaFactory;
|
||||||
import org.videolan.libvlc.MediaPlayer;
|
import org.videolan.libvlc.MediaPlayer;
|
||||||
import org.videolan.libvlc.util.VLCVideoLayout;
|
import org.videolan.libvlc.util.VLCVideoLayout;
|
||||||
|
|
||||||
@ -405,13 +407,24 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
|||||||
if (JfClient.playIndex < JfClient.playList.size()) {
|
if (JfClient.playIndex < JfClient.playList.size()) {
|
||||||
currItem = JfClient.playList.get(JfClient.playIndex);
|
currItem = JfClient.playList.get(JfClient.playIndex);
|
||||||
videoTitle.setText(currItem.Name);
|
videoTitle.setText(currItem.Name);
|
||||||
mediaPlayer.play(Uri.parse(currItem.Url));
|
Media media = getMedia();
|
||||||
|
mediaPlayer.setMedia(media);
|
||||||
|
media.release();
|
||||||
|
mediaPlayer.play();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Media getMedia(){
|
||||||
|
Uri uri = Uri.parse(currItem.Url);
|
||||||
|
Media media = new Media(libVLC,uri);
|
||||||
|
media.setHWDecoderEnabled(true,false);
|
||||||
|
//media.addOption(":codec=mediacodec_ndk,mediacodec_jni,none"); //硬件加速
|
||||||
|
return media;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 播放下一集
|
* 播放下一集
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user