Working from Season list only.
This commit is contained in:
parent
f70489e1b7
commit
82fc950361
|
@ -34,6 +34,13 @@ sub loadItems()
|
|||
end if
|
||||
end if
|
||||
|
||||
if m.top.selectedAudioStreamIndex = 0
|
||||
currentItem = m.global.queueManager.callFunc("getCurrentItem")
|
||||
if isValid(currentItem) and isValid(currentItem.json) and isValid(currentItem.json.MediaStreams)
|
||||
m.top.selectedAudioStreamIndex = FindPreferredAudioStream(currentItem.json.MediaStreams)
|
||||
end if
|
||||
end if
|
||||
|
||||
id = m.top.itemId
|
||||
mediaSourceId = invalid
|
||||
audio_stream_idx = m.top.selectedAudioStreamIndex
|
||||
|
@ -383,6 +390,25 @@ function sortSubtitles(id as string, MediaStreams)
|
|||
return { "all": tracks["forced"], "text": tracks["text"] }
|
||||
end function
|
||||
|
||||
function FindPreferredAudioStream(streams as dynamic) as integer
|
||||
preferredLanguage = m.global.userConfig.AudioLanguagePreference
|
||||
playDefault = m.global.userConfig.PlayDefaultAudioTrack
|
||||
|
||||
if playDefault <> invalid and playDefault = true
|
||||
return 1
|
||||
end if
|
||||
|
||||
if preferredLanguage <> invalid
|
||||
for i = 0 to streams.Count() - 1
|
||||
if LCase(streams[i].Type) = "audio" and LCase(streams[i].Language) = LCase(preferredLanguage)
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
return 1
|
||||
end function
|
||||
|
||||
function getSubtitleLanguages()
|
||||
return {
|
||||
"aar": "Afar",
|
||||
|
|
|
@ -124,8 +124,6 @@ sub Main (args as dynamic) as void
|
|||
audio_stream_idx = 0
|
||||
if isValid(itemNode.selectedAudioStreamIndex) and itemNode.selectedAudioStreamIndex > 0
|
||||
audio_stream_idx = itemNode.selectedAudioStreamIndex
|
||||
else if isValid(itemNode.json) and isValid(itemNode.json.MediaStreams)
|
||||
audio_stream_idx = FindPreferredAudioStream(itemNode.json.MediaStreams)
|
||||
end if
|
||||
|
||||
itemNode.selectedAudioStreamIndex = audio_stream_idx
|
||||
|
@ -191,8 +189,6 @@ sub Main (args as dynamic) as void
|
|||
audio_stream_idx = 0
|
||||
if isValid(selectedItem.selectedAudioStreamIndex) and selectedItem.selectedAudioStreamIndex > 0
|
||||
audio_stream_idx = selectedItem.selectedAudioStreamIndex
|
||||
else if isValid(selectedItem.json) and isValid(selectedItem.json.id)
|
||||
audio_stream_idx = FindPreferredAudioStream(invalid, selectedItem.json.id)
|
||||
end if
|
||||
|
||||
selectedItem.selectedAudioStreamIndex = audio_stream_idx
|
||||
|
@ -408,7 +404,6 @@ sub Main (args as dynamic) as void
|
|||
group = CreateVideoPlayerGroup(node.id)
|
||||
sceneManager.callFunc("pushScene", group)
|
||||
else if node.type = "Episode"
|
||||
audioPreference = FindPreferredAudioStream(invalid, node.id)
|
||||
group = CreateVideoPlayerGroup(node.id)
|
||||
sceneManager.callFunc("pushScene", group)
|
||||
else if node.type = "Audio"
|
||||
|
|
|
@ -835,33 +835,3 @@ sub playbackOptionDialog(time as longinteger, meta as object)
|
|||
|
||||
m.global.sceneManager.callFunc("optionDialog", tr("Playback Options"), [], resumeData)
|
||||
end sub
|
||||
|
||||
function FindPreferredAudioStream(streams as dynamic, id = "" as string) as integer
|
||||
preferredLanguage = m.user.Configuration.AudioLanguagePreference
|
||||
playDefault = m.user.Configuration.PlayDefaultAudioTrack
|
||||
|
||||
' Do we already have the MediaStreams or not?
|
||||
if streams = invalid
|
||||
url = Substitute("Users/{0}/Items/{1}", m.user.id, id)
|
||||
resp = APIRequest(url)
|
||||
jsonResponse = getJson(resp)
|
||||
|
||||
if jsonResponse = invalid or jsonResponse.MediaStreams = invalid then return 1
|
||||
|
||||
streams = jsonResponse.MediaStreams
|
||||
end if
|
||||
|
||||
if playDefault <> invalid and playDefault = true
|
||||
return 1
|
||||
end if
|
||||
|
||||
if preferredLanguage <> invalid
|
||||
for i = 0 to streams.Count() - 1
|
||||
if LCase(streams[i].Type) = "audio" and LCase(streams[i].Language) = LCase(preferredLanguage)
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
return 1
|
||||
end function
|
||||
|
|
Loading…
Reference in New Issue
Block a user