From 7f070bef7e16c436487bf85372a21110eceb0fd6 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Sat, 13 May 2023 13:01:58 -0400 Subject: [PATCH] Make continue playback work --- components/ItemGrid/LoadVideoContentTask.brs | 15 +++++++++++++-- components/video/VideoPlayerView.brs | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/ItemGrid/LoadVideoContentTask.brs b/components/ItemGrid/LoadVideoContentTask.brs index 85f2a70f..fdf6deb8 100644 --- a/components/ItemGrid/LoadVideoContentTask.brs +++ b/components/ItemGrid/LoadVideoContentTask.brs @@ -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) diff --git a/components/video/VideoPlayerView.brs b/components/video/VideoPlayerView.brs index 64e02776..71c78299 100644 --- a/components/video/VideoPlayerView.brs +++ b/components/video/VideoPlayerView.brs @@ -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