move playurl fallback

This commit is contained in:
Ovler 2023-10-16 11:00:56 +08:00
parent fdbfd10d84
commit e50210fd12
No known key found for this signature in database
GPG Key ID: 87C2223333333333

View File

@ -209,7 +209,7 @@ public class JfClient {
SendPost(playbackurl, deviceProfile, new JJCallBack() { SendPost(playbackurl, deviceProfile, new JJCallBack() {
@Override @Override
public void onSuccess(String str) { public void onSuccess(String str) {
try { try {
// 使用Gson解析JSON数据 // 使用Gson解析JSON数据
Gson gson = new Gson(); Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(str, JsonObject.class); JsonObject jsonObject = gson.fromJson(str, JsonObject.class);
@ -219,22 +219,22 @@ public class JfClient {
if (mediaSources != null && mediaSources.size() > 0) { if (mediaSources != null && mediaSources.size() > 0) {
JsonObject mediaSource = mediaSources.get(0).getAsJsonObject(); JsonObject mediaSource = mediaSources.get(0).getAsJsonObject();
String transcodingUrl = mediaSource.get("TranscodingUrl").getAsString(); String transcodingUrl = mediaSource.get("TranscodingUrl").getAsString();
// 检查TranscodingUrl是否为空 // 检查TranscodingUrl是否为空
if (transcodingUrl != null && !transcodingUrl.isEmpty()) { if (transcodingUrl != null && !transcodingUrl.isEmpty()) {
playurl = config.getJellyfinUrl() + transcodingUrl; playurl = config.getJellyfinUrl() + transcodingUrl;
} else {
playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
} }
} else {
playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
} }
} catch (Exception e) { } catch (Exception e) {
playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken; e.printStackTrace();
} }
} }
}, null); }, null);
// if playurl is still "", return config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
if (playurl == null || playurl.isEmpty()) {
playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
}
return playurl; // Return the playurl variable return playurl; // Return the playurl variable
} }