Merge pull request #4 from 1hitsong/continuePlayback

Make continue playback work
This commit is contained in:
Jimi 2023-05-13 11:15:39 -06:00 committed by GitHub
commit c8dd7eab08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import "pkg:/source/api/userauth.brs"
import "pkg:/source/utils/deviceCapabilities.brs"
sub init()
m.user = AboutMe()
m.top.functionName = "loadItems"
end sub
@ -36,7 +37,7 @@ sub loadItems()
if m.top.selectedAudioStreamIndex = 0
currentItem = m.global.queueManager.callFunc("getCurrentItem")
if isValid(currentItem) and isValid(currentItem.json) and isValid(currentItem.json.MediaStreams)
if isValid(currentItem) and isValid(currentItem.json)
m.top.selectedAudioStreamIndex = FindPreferredAudioStream(currentItem.json.MediaStreams)
end if
end if
@ -345,7 +346,6 @@ end sub
'Checks available subtitle tracks and puts subtitles in forced, default, and non-default/forced but preferred language at the top
function sortSubtitles(id as string, MediaStreams)
m.user = AboutMe()
tracks = { "forced": [], "default": [], "normal": [], "text": [] }
'Too many args for using substitute
prefered_lang = m.user.Configuration.SubtitleLanguagePreference
@ -398,6 +398,17 @@ function FindPreferredAudioStream(streams as dynamic) as integer
return 1
end if
' Do we already have the MediaStreams or not?
if streams = invalid
url = Substitute("Users/{0}/Items/{1}", m.user.id, m.top.itemId)
resp = APIRequest(url)
jsonResponse = getJson(resp)
if jsonResponse = invalid or jsonResponse.MediaStreams = invalid then return 1
streams = jsonResponse.MediaStreams
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)

View File

@ -90,15 +90,15 @@ sub onVideoContentLoaded()
m.top.container = m.LoadMetaDataTask.content[0].container
m.top.mediaSourceId = m.LoadMetaDataTask.content[0].mediaSourceId
m.top.fullSubtitleData = m.LoadMetaDataTask.content[0].fullSubtitleData
m.top.audioIndex = m.LoadMetaDataTask.content[0].audio_stream_idx
m.top.audioIndex = m.LoadMetaDataTask.content[0].audioIndex
m.top.transcodeParams = m.LoadMetaDataTask.content[0].transcodeparams
if m.LoadMetaDataTask.isIntro
m.top.enableTrickPlay = false
end if
if isValid(m.currentItem.selectedAudioStreamIndex)
m.top.audioTrack = (m.currentItem.selectedAudioStreamIndex + 1).toStr()
if isValid(m.top.audioIndex)
m.top.audioTrack = (m.top.audioIndex + 1).toStr()
else
m.top.audioTrack = "2"
end if