|
6 | 6 | import "pkg:/source/utils/deviceCapabilities.bs" |
7 | 7 | import "pkg:/source/utils/misc.bs" |
8 | 8 |
|
9 | | -function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioTrackIndex = -1 as integer, subtitleTrackIndex = SubtitleSelection.none as integer, startTimeTicks = 0 as longinteger, forceMp3 = false as boolean, videoMetadata = invalid as dynamic) |
10 | | - params = { |
| 9 | +function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioTrackIndex = -1 as integer, subtitleTrackIndex = SubtitleSelection.none as integer, startTimeTicks = 0& as longinteger, videoMetadata = invalid as dynamic) |
| 10 | + postData = { |
11 | 11 | "UserId": m.global.user.id, |
12 | 12 | "StartTimeTicks": startTimeTicks, |
13 | | - "IsPlayback": true, |
14 | | - "AutoOpenLiveStream": true, |
15 | | - "MaxStreamingBitrate": "140000000", |
16 | | - "MaxStaticBitrate": "140000000", |
17 | | - "SubtitleStreamIndex": subtitleTrackIndex |
| 13 | + "AutoOpenLiveStream": true |
| 14 | + ' "AlwaysBurnInSubtitleWhenTranscoding": true |
18 | 15 | } |
19 | | - deviceProfile = getDeviceProfile() |
| 16 | + postData.DeviceProfile = getDeviceProfile() |
| 17 | + |
| 18 | + if subtitleTrackIndex <> SubtitleSelection.none and subtitleTrackIndex <> SubtitleSelection.notset |
| 19 | + postData.SubtitleStreamIndex = subtitleTrackIndex |
| 20 | + end if |
20 | 21 |
|
21 | 22 | ' Note: Jellyfin v10.9+ now remuxs LiveTV and does not allow DirectPlay anymore. |
22 | 23 | ' Because of this, we need to tell the server "EnableDirectPlay = false" so that we receive the |
23 | 24 | ' transcoding URL (which is just a remux and not a transcode; unless it is) |
24 | 25 | ' The web handles this by disabling EnableDirectPlay on a Retry, but we don't currently Retry a Live |
25 | 26 | ' TV stream, thus we just turn it off on the first try here. |
26 | 27 | if mediaSourceId <> "" |
27 | | - params.MediaSourceId = mediaSourceId |
| 28 | + postData.MediaSourceId = mediaSourceId |
28 | 29 | else |
29 | 30 | ' No mediaSourceId? Must be LiveTV... |
30 | | - params.EnableDirectPlay = false |
| 31 | + postData.EnableDirectPlay = false |
31 | 32 | end if |
32 | 33 |
|
33 | | - if audioTrackIndex > -1 and isValid(videoMetadata) and isValid(videoMetadata.json) and isValid(videoMetadata.json.MediaStreams) |
34 | | - ' Find the audio stream with the matching Jellyfin index |
35 | | - selectedAudioStream = invalid |
36 | | - for each stream in videoMetadata.json.MediaStreams |
37 | | - if isValid(stream.index) and stream.index = audioTrackIndex |
38 | | - selectedAudioStream = stream |
39 | | - exit for |
40 | | - end if |
41 | | - end for |
42 | | - |
43 | | - if isValid(selectedAudioStream) |
44 | | - params.AudioStreamIndex = audioTrackIndex |
45 | | - |
46 | | - ' force the server to transcode AAC profiles we don't support to MP3 instead of the usual AAC |
47 | | - ' TODO: Remove this after server adds support for transcoding AAC from one profile to another |
48 | | - if isValid(selectedAudioStream.Codec) and LCase(selectedAudioStream.Codec) = "aac" |
49 | | - if isValid(selectedAudioStream.Profile) and LCase(selectedAudioStream.Profile) = "main" or LCase(selectedAudioStream.Profile) = "he-aac" |
50 | | - forceMp3 = true |
| 34 | + if audioTrackIndex > -1 |
| 35 | + if isValid(videoMetadata) and isValid(videoMetadata.json) and isValid(videoMetadata.json.MediaStreams) |
| 36 | + ' Find the audio stream with the matching Jellyfin index |
| 37 | + selectedAudioStream = invalid |
| 38 | + for each stream in videoMetadata.json.MediaStreams |
| 39 | + if isValid(stream.index) and stream.index = audioTrackIndex |
| 40 | + selectedAudioStream = stream |
| 41 | + exit for |
| 42 | + end if |
| 43 | + end for |
| 44 | + |
| 45 | + if isValid(selectedAudioStream) |
| 46 | + postData.AudioStreamIndex = audioTrackIndex |
| 47 | + ' force the server to transcode AAC profiles we don't support to MP3 instead of the usual AAC |
| 48 | + ' TODO: Remove this after server adds support for transcoding AAC from one profile to another |
| 49 | + if isValid(selectedAudioStream.Codec) and LCase(selectedAudioStream.Codec) = "aac" |
| 50 | + if isValid(selectedAudioStream.Profile) and LCase(selectedAudioStream.Profile) = "main" or LCase(selectedAudioStream.Profile) = "he-aac" |
| 51 | + forceMp3Audio(postData.DeviceProfile) |
| 52 | + end if |
51 | 53 | end if |
52 | 54 | end if |
53 | 55 | end if |
54 | 56 | end if |
55 | 57 |
|
56 | | - if forceMp3 then forceMp3Audio(deviceProfile) |
57 | | - |
58 | | - req = APIRequest(Substitute("Items/{0}/PlaybackInfo", id), params) |
| 58 | + req = APIRequest(Substitute("Items/{0}/PlaybackInfo", id)) |
59 | 59 | req.SetRequest("POST") |
60 | | - return postJson(req, FormatJson({ "DeviceProfile": deviceProfile })) |
| 60 | + return postJson(req, FormatJson(postData)) |
61 | 61 | end function |
62 | 62 |
|
63 | 63 | ' Search across all libraries |
|
0 commit comments