Update default subtitle logic to work with custom subtitle function
This commit is contained in:
parent
8601adfa14
commit
b5ad638449
|
@ -151,13 +151,16 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
|
|||
end if
|
||||
|
||||
addSubtitlesToVideo(video, meta)
|
||||
else
|
||||
video.SelectedSubtitle = subtitle_idx
|
||||
end if
|
||||
else
|
||||
video.SelectedSubtitle = subtitle_idx
|
||||
end if
|
||||
|
||||
video.videoId = video.id
|
||||
video.mediaSourceId = mediaSourceId
|
||||
video.audioIndex = audio_stream_idx
|
||||
video.SelectedSubtitle = subtitle_idx
|
||||
|
||||
video.PlaySessionId = m.playbackInfo.PlaySessionId
|
||||
|
||||
|
|
|
@ -323,11 +323,6 @@ sub onVideoContentLoaded()
|
|||
m.top.transcodeParams = videoContent[0].transcodeparams
|
||||
m.chapters = videoContent[0].chapters
|
||||
|
||||
' Allow default subtitles
|
||||
m.top.unobserveField("selectedSubtitle")
|
||||
m.top.selectedSubtitle = videoContent[0].selectedSubtitle
|
||||
m.top.observeField("selectedSubtitle", "onSubtitleChange")
|
||||
|
||||
m.osd.itemTitleText = m.top.content.title
|
||||
|
||||
populateChapterMenu()
|
||||
|
@ -340,6 +335,29 @@ sub onVideoContentLoaded()
|
|||
m.top.allowCaptions = true
|
||||
end if
|
||||
|
||||
' Allow default subtitles
|
||||
m.top.unobserveField("selectedSubtitle")
|
||||
|
||||
' Set subtitleTrack property is subs are natively supported by Roku
|
||||
selectedSubtitle = invalid
|
||||
for each subtitle in m.top.fullSubtitleData
|
||||
if subtitle.Index = videoContent[0].selectedSubtitle
|
||||
selectedSubtitle = subtitle
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
|
||||
if isValid(selectedSubtitle)
|
||||
availableSubtitleTrackIndex = availSubtitleTrackIdx(selectedSubtitle.Track.TrackName)
|
||||
if availableSubtitleTrackIndex <> -1
|
||||
m.top.subtitleTrack = m.top.availableSubtitleTracks[availableSubtitleTrackIndex].TrackName
|
||||
end if
|
||||
end if
|
||||
|
||||
m.top.selectedSubtitle = videoContent[0].selectedSubtitle
|
||||
|
||||
m.top.observeField("selectedSubtitle", "onSubtitleChange")
|
||||
|
||||
if isValid(m.top.audioIndex)
|
||||
m.top.audioTrack = (m.top.audioIndex + 1).toStr()
|
||||
else
|
||||
|
@ -587,6 +605,25 @@ function stateAllowsOSD() as boolean
|
|||
return inArray(validStates, m.top.state)
|
||||
end function
|
||||
|
||||
|
||||
' availSubtitleTrackIdx: Returns Roku's index for requested subtitle track
|
||||
'
|
||||
' @param {string} tracknameToFind - TrackName for subtitle we're looking to match
|
||||
' @return {integer} indicating Roku's index for requested subtitle track. Returns -1 if not found
|
||||
function availSubtitleTrackIdx(tracknameToFind as string) as integer
|
||||
idx = 0
|
||||
for each availTrack in m.top.availableSubtitleTracks
|
||||
' The TrackName must contain the URL we supplied originally, though
|
||||
' Roku mangles the name a bit, so we check if the URL is a substring, rather
|
||||
' than strict equality
|
||||
if Instr(1, availTrack.TrackName, tracknameToFind)
|
||||
return idx
|
||||
end if
|
||||
idx = idx + 1
|
||||
end for
|
||||
return -1
|
||||
end function
|
||||
|
||||
function onKeyEvent(key as string, press as boolean) as boolean
|
||||
|
||||
' Keypress handler while user is inside the chapter menu
|
||||
|
|
Loading…
Reference in New Issue
Block a user