修改详情页

This commit is contained in:
sifacai@outlook.com 2022-09-01 22:58:39 +08:00
parent e926adf005
commit ad98cbf192
4 changed files with 75 additions and 45 deletions

View File

@ -122,10 +122,10 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
if (mstype.equals("Video")) {
video += ms.getDisplayTitle();
} 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 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() + "";
}
}

View File

@ -38,23 +38,6 @@ public class HomeActivity extends BaseActivity {
tvContiner = findViewById(R.id.tvItems);
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() {
@ -69,10 +52,14 @@ public class HomeActivity extends BaseActivity {
@Override
protected void onResume() {
super.onResume();
initView();
initData();
}
/**
* 登录框
*/
private void showLoginDialog() {
Log.d(TAG, "showLoginDialog: 跳出登录框");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog alert = builder.setTitle("登录")
.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() {
showLoadingDialog("正在加载首页…………");
@ -144,11 +152,11 @@ public class HomeActivity extends BaseActivity {
public void onSuccess(Items latests) {
addRowTvRecyclerView("新的 " + item.getName(), latests.getItems(), false);
}
}, null);
}, errcb);
}
dismissLoadingDialog();
}
}, null);
}, errcb);
JfClient.GetResume(new JfClient.JJCallBack() {
@Override
public void onSuccess(Items resumes) {
@ -159,10 +167,9 @@ public class HomeActivity extends BaseActivity {
}
addRowTvRecyclerView("最近播放", resumes.getItems(), false);
}
}, null);
}, errcb);
}
/**
* 添加类别行
*/
@ -216,4 +223,12 @@ public class HomeActivity extends BaseActivity {
System.exit(0);
}
}
public JfClient.JJCallBack errcb = new JfClient.JJCallBack(){
@Override
public void onError(String str) {
dismissLoadingDialog();
ShowToask(str);
}
};
}

View File

@ -406,6 +406,10 @@ public class JfClient {
* @param cb
*/
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 reqjson = "{\"Username\":\"" + username + "\",\"Pw\":\"" + password + "\"}";
SendPost(url, reqjson, new JJCallBack() {
@ -461,29 +465,27 @@ public class JfClient {
* @param cb
*/
public static void VerityServerUrl(String url, JJCallBack cb, JJCallBack err) {
if (url.length() > 0) {
if (url.startsWith("http://") || url.startsWith("https://")) {
SendGet(url + "/system/info/public", new JJCallBack() {
@Override
public void onSuccess(String str) {
try {
JsonObject serverInfo = new Gson().fromJson(str, JsonObject.class);
String ServerId = "";
ServerId = serverInfo.get("Id").getAsString();
if (ServerId == null || ServerId.length() == 0) {
err.onError("服务器连接失败!");
} else {
config.setJellyfinUrl(url);
cb.onSuccess(true);
}
} catch (Exception e) {
err.onError(e.getMessage());
if (url.startsWith("http://") || url.startsWith("https://")) {
SendGet(url + "/system/info/public", new JJCallBack() {
@Override
public void onSuccess(String str) {
try {
JsonObject serverInfo = new Gson().fromJson(str, JsonObject.class);
String ServerId = "";
ServerId = serverInfo.get("Id").getAsString();
if (ServerId == null || ServerId.length() == 0) {
err.onError("服务器连接失败!");
} else {
config.setJellyfinUrl(url);
cb.onSuccess(true);
}
} catch (Exception e) {
err.onError(e.getMessage());
}
}, err);
}
}
}, err);
} else {
err.onError("服务器地址不能为空");
err.onError("服务器地址不正确");
}
}

View File

@ -18,6 +18,8 @@ import android.widget.SeekBar;
import android.widget.TextView;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaFactory;
import org.videolan.libvlc.MediaPlayer;
import org.videolan.libvlc.util.VLCVideoLayout;
@ -405,13 +407,24 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
if (JfClient.playIndex < JfClient.playList.size()) {
currItem = JfClient.playList.get(JfClient.playIndex);
videoTitle.setText(currItem.Name);
mediaPlayer.play(Uri.parse(currItem.Url));
Media media = getMedia();
mediaPlayer.setMedia(media);
media.release();
mediaPlayer.play();
}
} else {
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;
}
/**
* 播放下一集
*/