mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-05-26 06:20:20 -04:00
get playurl via api for transcoded play
This commit is contained in:
parent
965ee32fd1
commit
d715fe48b6
@ -200,8 +200,46 @@ public class JfClient {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String GetPlayUrl(String itemid) {
|
public static String GetPlayUrl(String itemid) {
|
||||||
String playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
|
String playbackurl = config.getJellyfinUrl() + "/Items/" + itemid + "/PlaybackInfo?UserId=" + UserId + "&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
|
||||||
return playurl;
|
// 可以修改各种具体参数如比特率,允许的编码方式,字幕烧录方式等
|
||||||
|
// 此处为 仅使用 h264 强制烧录字幕
|
||||||
|
String deviceProfile = "{\"DeviceProfile\":{\"MaxStreamingBitrate\":120000000,\"MaxStaticBitrate\":100000000,\"MusicStreamingTranscodingBitrate\":384000,\"DirectPlayProfiles\":[{\"Container\":\"mp4,m4v\",\"Type\":\"Video\",\"VideoCodec\":\"h264\",\"AudioCodec\":\"aac,mp3,opus,flac,vorbis\"},{\"Container\":\"mov\",\"Type\":\"Video\",\"VideoCodec\":\"h264\",\"AudioCodec\":\"aac,mp3,opus,flac,vorbis\"},{\"Container\":\"opus\",\"Type\":\"Audio\"},{\"Container\":\"webm\",\"AudioCodec\":\"opus\",\"Type\":\"Audio\"},{\"Container\":\"mp3\",\"Type\":\"Audio\"},{\"Container\":\"aac\",\"Type\":\"Audio\"},{\"Container\":\"m4a\",\"AudioCodec\":\"aac\",\"Type\":\"Audio\"},{\"Container\":\"m4b\",\"AudioCodec\":\"aac\",\"Type\":\"Audio\"},{\"Container\":\"flac\",\"Type\":\"Audio\"},{\"Container\":\"webma\",\"Type\":\"Audio\"},{\"Container\":\"webm\",\"AudioCodec\":\"webma\",\"Type\":\"Audio\"},{\"Container\":\"wav\",\"Type\":\"Audio\"},{\"Container\":\"ogg\",\"Type\":\"Audio\"}],\"TranscodingProfiles\":[{\"Container\":\"ts\",\"Type\":\"Audio\",\"AudioCodec\":\"aac\",\"Context\":\"Streaming\",\"Protocol\":\"hls\",\"MaxAudioChannels\":\"2\",\"MinSegments\":\"1\",\"BreakOnNonKeyFrames\":true},{\"Container\":\"aac\",\"Type\":\"Audio\",\"AudioCodec\":\"aac\",\"Context\":\"Streaming\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"mp3\",\"Type\":\"Audio\",\"AudioCodec\":\"mp3\",\"Context\":\"Streaming\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"opus\",\"Type\":\"Audio\",\"AudioCodec\":\"opus\",\"Context\":\"Streaming\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"wav\",\"Type\":\"Audio\",\"AudioCodec\":\"wav\",\"Context\":\"Streaming\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"opus\",\"Type\":\"Audio\",\"AudioCodec\":\"opus\",\"Context\":\"Static\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"mp3\",\"Type\":\"Audio\",\"AudioCodec\":\"mp3\",\"Context\":\"Static\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"aac\",\"Type\":\"Audio\",\"AudioCodec\":\"aac\",\"Context\":\"Static\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"wav\",\"Type\":\"Audio\",\"AudioCodec\":\"wav\",\"Context\":\"Static\",\"Protocol\":\"http\",\"MaxAudioChannels\":\"2\"},{\"Container\":\"ts\",\"Type\":\"Video\",\"AudioCodec\":\"aac,mp3\",\"VideoCodec\":\"h264\",\"Context\":\"Streaming\",\"Protocol\":\"hls\",\"MaxAudioChannels\":\"2\",\"MinSegments\":\"1\",\"BreakOnNonKeyFrames\":true}],\"ContainerProfiles\":[],\"CodecProfiles\":[{\"Type\":\"Video\",\"Codec\":\"h264\",\"Conditions\":[{\"Condition\":\"NotEquals\",\"Property\":\"IsAnamorphic\",\"Value\":\"true\",\"IsRequired\":false},{\"Condition\":\"EqualsAny\",\"Property\":\"VideoProfile\",\"Value\":\"high|main|baseline|constrained baseline|high 10\",\"IsRequired\":false},{\"Condition\":\"EqualsAny\",\"Property\":\"VideoRangeType\",\"Value\":\"SDR\",\"IsRequired\":false},{\"Condition\":\"LessThanEqual\",\"Property\":\"VideoLevel\",\"Value\":\"52\",\"IsRequired\":false},{\"Condition\":\"NotEquals\",\"Property\":\"IsInterlaced\",\"Value\":\"true\",\"IsRequired\":false}]}],\"SubtitleProfiles\":[{\"Format\":\"vtt\",\"Method\":\"Embed\"},{\"Format\":\"ass\",\"Method\":\"Embed\"},{\"Format\":\"ssa\",\"Method\":\"Embed\"}],\"ResponseProfiles\":[{\"Type\":\"Video\",\"Container\":\"m4v\",\"MimeType\":\"video/mp4\"}]}}";
|
||||||
|
|
||||||
|
SendPost(url, deviceProfile, new JJCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String str) {
|
||||||
|
try {
|
||||||
|
// 使用Gson解析JSON数据
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonObject jsonObject = gson.fromJson(str, JsonObject.class);
|
||||||
|
JsonArray mediaSources = jsonObject.getAsJsonArray("MediaSources");
|
||||||
|
|
||||||
|
// 检查MediaSources是否为空
|
||||||
|
if (mediaSources != null && mediaSources.size() > 0) {
|
||||||
|
JsonObject mediaSource = mediaSources.get(0).getAsJsonObject();
|
||||||
|
String transcodingUrl = mediaSource.get("TranscodingUrl").getAsString();
|
||||||
|
|
||||||
|
// 检查TranscodingUrl是否为空
|
||||||
|
if (transcodingUrl != null && !transcodingUrl.isEmpty()) {
|
||||||
|
String playurl = config.getJellyfinUrl() + transcodingUrl;
|
||||||
|
// 返回TranscodingUrl
|
||||||
|
return playurl;
|
||||||
|
} else {
|
||||||
|
// 返回默认的URL
|
||||||
|
String playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
|
||||||
|
return playurl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
|
||||||
|
return playurl;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
err.onError("寻找播放地址失败:" + e.getMessage() + "\n" + str)
|
||||||
|
String playurl = config.getJellyfinUrl() + "/videos/" + itemid + "/stream.mp4?static=true&DeviceId=" + DeviceId + "&api_key=" + AccessToken;
|
||||||
|
return playurl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SearchByTerm(String term, int limit, JJCallBack scb, JJCallBack errcb) {
|
public static void SearchByTerm(String term, int limit, JJCallBack scb, JJCallBack errcb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user