Update API docs
This commit is contained in:
parent
127d08f1c0
commit
424951ccdc
|
@ -252,7 +252,7 @@ function defaultSubtitleTrackFromVid(videoID) as integer
|
|||
subtitles = sortSubtitles(meta.id, meta.json.MediaSources[0].MediaStreams)
|
||||
selectedAudioLanguage = meta.json.MediaSources[0].MediaStreams[m.top.selectedAudioStreamIndex].Language ?? ""
|
||||
|
||||
defaultTextSubs = defaultSubtitleTrack(subtitles["all"], selectedAudioLanguage, true) ' Find correct subtitle track (forced text)
|
||||
defaultTextSubs = defaultSubtitleTrack(subtitles["text"], selectedAudioLanguage, true) ' Find correct subtitle track (forced text)
|
||||
if defaultTextSubs <> SubtitleSelection.none
|
||||
return defaultTextSubs
|
||||
end if
|
||||
|
@ -496,26 +496,33 @@ function sortSubtitles(id as string, MediaStreams)
|
|||
"IsExternal": stream.IsExternal,
|
||||
"IsEncoded": stream.DeliveryMethod = "Encode"
|
||||
}
|
||||
|
||||
if stream.isForced
|
||||
trackType = "forced"
|
||||
else if stream.IsDefault
|
||||
trackType = "default"
|
||||
else if stream.IsTextSubtitleStream
|
||||
trackType = "text"
|
||||
else
|
||||
trackType = "normal"
|
||||
end if
|
||||
|
||||
if prefered_lang <> "" and prefered_lang = stream.Track.Language
|
||||
tracks[trackType].unshift(stream)
|
||||
|
||||
if stream.IsTextSubtitleStream
|
||||
tracks["text"].unshift(stream)
|
||||
end if
|
||||
else
|
||||
tracks[trackType].push(stream)
|
||||
|
||||
if stream.IsTextSubtitleStream
|
||||
tracks["text"].push(stream)
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
tracks["default"].append(tracks["normal"])
|
||||
tracks["forced"].append(tracks["default"])
|
||||
tracks["forced"].append(tracks["text"])
|
||||
|
||||
return { "all": tracks["forced"], "text": tracks["text"] }
|
||||
end function
|
||||
|
|
|
@ -23,9 +23,17 @@ sub init()
|
|||
m.showProgressBarField = m.top.findNode("showProgressBarField")
|
||||
|
||||
' Randomize the background colors
|
||||
backdropColor = "#00a4db" ' set default in case global var is invalid
|
||||
localGlobal = m.global
|
||||
|
||||
if isValid(localGlobal) and isValid(localGlobal.constants) and isValid(localGlobal.constants.poster_bg_pallet)
|
||||
posterBackgrounds = localGlobal.constants.poster_bg_pallet
|
||||
backdropColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
|
||||
end if
|
||||
|
||||
' update the backdrop node
|
||||
m.backdrop = m.top.findNode("backdrop")
|
||||
posterBackgrounds = m.global.constants.poster_bg_pallet
|
||||
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
|
||||
m.backdrop.color = backdropColor
|
||||
end sub
|
||||
|
||||
|
||||
|
|
|
@ -101,6 +101,14 @@ sub processSubtitleSelection()
|
|||
' The playbackData is now outdated and must be refreshed
|
||||
m.playbackData = invalid
|
||||
|
||||
' Find previously selected subtitle and identify if it was encoded
|
||||
for each item in m.view.fullSubtitleData
|
||||
if item.index = m.view.selectedSubtitle
|
||||
m.view.previousSubtitleWasEncoded = item.IsEncoded
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
|
||||
if LCase(m.selectedSubtitle.track.description) = "none"
|
||||
m.view.globalCaptionMode = "Off"
|
||||
m.view.subtitleTrack = ""
|
||||
|
|
|
@ -390,46 +390,10 @@ end sub
|
|||
' Update values on screen when page content changes
|
||||
sub pageContentChanged()
|
||||
|
||||
' Reset buffer bar without animation
|
||||
m.bufferPosition.width = 0
|
||||
m.LoadAudioStreamTask.control = "STOP"
|
||||
|
||||
useMetaTask = false
|
||||
currentItem = m.global.queueManager.callFunc("getCurrentItem")
|
||||
|
||||
if not isValid(currentItem.RunTimeTicks)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if not isValid(currentItem.AlbumArtist)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if not isValid(currentItem.name)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if not isValid(currentItem.Artists)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if useMetaTask
|
||||
m.LoadMetaDataTask.itemId = currentItem.id
|
||||
m.LoadMetaDataTask.observeField("content", "onMetaDataLoaded")
|
||||
m.LoadMetaDataTask.control = "RUN"
|
||||
else
|
||||
if isValid(currentItem.ParentBackdropItemId)
|
||||
setBackdropImage(ImageURL(currentItem.ParentBackdropItemId, "Backdrop", { "maxHeight": "720", "maxWidth": "1280" }))
|
||||
end if
|
||||
|
||||
setPosterImage(ImageURL(currentItem.id, "Primary", { "maxHeight": 500, "maxWidth": 500 }))
|
||||
setScreenTitle(currentItem)
|
||||
setOnScreenTextValues(currentItem)
|
||||
m.songDuration = currentItem.RunTimeTicks / 10000000.0
|
||||
|
||||
' Update displayed total audio length
|
||||
m.totalLengthTimestamp.text = ticksToHuman(currentItem.RunTimeTicks)
|
||||
end if
|
||||
|
||||
m.LoadAudioStreamTask.itemId = currentItem.id
|
||||
m.LoadAudioStreamTask.observeField("content", "onAudioStreamLoaded")
|
||||
m.LoadAudioStreamTask.control = "RUN"
|
||||
|
@ -453,6 +417,46 @@ sub onAudioStreamLoaded()
|
|||
data = m.LoadAudioStreamTask.content[0]
|
||||
m.LoadAudioStreamTask.unobserveField("content")
|
||||
if data <> invalid and data.count() > 0
|
||||
' Reset buffer bar without animation
|
||||
m.bufferPosition.width = 0
|
||||
|
||||
useMetaTask = false
|
||||
currentItem = m.global.queueManager.callFunc("getCurrentItem")
|
||||
|
||||
if not isValid(currentItem.RunTimeTicks)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if not isValid(currentItem.AlbumArtist)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if not isValid(currentItem.name)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if not isValid(currentItem.Artists)
|
||||
useMetaTask = true
|
||||
end if
|
||||
|
||||
if useMetaTask
|
||||
m.LoadMetaDataTask.itemId = currentItem.id
|
||||
m.LoadMetaDataTask.observeField("content", "onMetaDataLoaded")
|
||||
m.LoadMetaDataTask.control = "RUN"
|
||||
else
|
||||
if isValid(currentItem.ParentBackdropItemId)
|
||||
setBackdropImage(ImageURL(currentItem.ParentBackdropItemId, "Backdrop", { "maxHeight": "720", "maxWidth": "1280" }))
|
||||
end if
|
||||
|
||||
setPosterImage(ImageURL(currentItem.id, "Primary", { "maxHeight": 500, "maxWidth": 500 }))
|
||||
setScreenTitle(currentItem)
|
||||
setOnScreenTextValues(currentItem)
|
||||
m.songDuration = currentItem.RunTimeTicks / 10000000.0
|
||||
|
||||
' Update displayed total audio length
|
||||
m.totalLengthTimestamp.text = ticksToHuman(currentItem.RunTimeTicks)
|
||||
end if
|
||||
|
||||
m.global.audioPlayer.content = data
|
||||
m.global.audioPlayer.control = "none"
|
||||
m.global.audioPlayer.control = "play"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,11 +16,13 @@ sub quickConnectStatus()
|
|||
m.quickConnectTimer.control = "stop"
|
||||
m.checkTask = CreateObject("roSGNode", "QuickConnect")
|
||||
m.checkTask.secret = m.top.quickConnectJson.secret
|
||||
m.checkTask.saveCredentials = m.top.saveCredentials
|
||||
m.checkTask.observeField("authenticated", "OnAuthenticated")
|
||||
m.checkTask.control = "run"
|
||||
end sub
|
||||
|
||||
sub OnAuthenticated()
|
||||
m.checkTask.control = "stop"
|
||||
m.checkTask.unobserveField("authenticated")
|
||||
|
||||
' Did we get the A-OK to authenticate?
|
||||
|
@ -28,28 +30,18 @@ sub OnAuthenticated()
|
|||
if authenticated < 0
|
||||
' Still waiting, check again in 3 seconds...
|
||||
authenticated = 0
|
||||
m.checkTask.observeField("authenticated", "OnAuthenticated")
|
||||
m.quickConnectTimer.control = "start"
|
||||
else if authenticated > 0
|
||||
' We've been given the go ahead, try to authenticate via Quick Connect...
|
||||
authenticated = AuthenticateViaQuickConnect(m.top.quickConnectJson.secret)
|
||||
if authenticated <> invalid and authenticated = true
|
||||
currentUser = AboutMe()
|
||||
session.user.Login(currentUser, m.top.saveCredentials)
|
||||
session.user.LoadUserPreferences()
|
||||
LoadUserAbilities()
|
||||
m.top.close = true
|
||||
m.top.authenticated = true
|
||||
else
|
||||
m.top.close = true
|
||||
m.top.authenticated = false
|
||||
end if
|
||||
' We've been logged in via Quick Connect...
|
||||
m.top.close = true
|
||||
m.top.authenticated = true
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub quickConnectClosed()
|
||||
m.quickConnectTimer.control = "stop"
|
||||
if m.checkTask <> invalid
|
||||
m.checkTask.control = "stop"
|
||||
m.checkTask.unobserveField("authenticated")
|
||||
end if
|
||||
m.top.close = true
|
||||
|
|
|
@ -258,8 +258,17 @@ end sub
|
|||
|
||||
' Event handler for when selectedSubtitle changes
|
||||
sub onSubtitleChange()
|
||||
' If the global caption mode is on, that means Roku can display the subtitles natively and doesn't need a video stop/start
|
||||
if LCase(m.top.globalCaptionMode) = "on" then return
|
||||
switchWithoutRefresh = true
|
||||
|
||||
if m.top.SelectedSubtitle <> -1
|
||||
' If the global caption mode is off, then Roku can't display the subtitles natively and needs a video stop/start
|
||||
if LCase(m.top.globalCaptionMode) <> "on" then switchWithoutRefresh = false
|
||||
end if
|
||||
|
||||
' If previous sustitle was encoded, then we need to a video stop/start to change subtitle content
|
||||
if m.top.previousSubtitleWasEncoded then switchWithoutRefresh = false
|
||||
|
||||
if switchWithoutRefresh then return
|
||||
|
||||
' Save the current video position
|
||||
m.global.queueManager.callFunc("setTopStartingPoint", int(m.top.position) * 10000000&)
|
||||
|
@ -340,7 +349,7 @@ sub onVideoContentLoaded()
|
|||
' Allow default subtitles
|
||||
m.top.unobserveField("selectedSubtitle")
|
||||
|
||||
' Set subtitleTrack property is subs are natively supported by Roku
|
||||
' Set subtitleTrack property if subs are natively supported by Roku
|
||||
selectedSubtitle = invalid
|
||||
for each subtitle in m.top.fullSubtitleData
|
||||
if subtitle.Index = videoContent[0].selectedSubtitle
|
||||
|
@ -352,7 +361,10 @@ sub onVideoContentLoaded()
|
|||
if isValid(selectedSubtitle)
|
||||
availableSubtitleTrackIndex = availSubtitleTrackIdx(selectedSubtitle.Track.TrackName)
|
||||
if availableSubtitleTrackIndex <> -1
|
||||
m.top.subtitleTrack = m.top.availableSubtitleTracks[availableSubtitleTrackIndex].TrackName
|
||||
if not selectedSubtitle.IsEncoded
|
||||
m.top.globalCaptionMode = "On"
|
||||
m.top.subtitleTrack = m.top.availableSubtitleTracks[availableSubtitleTrackIndex].TrackName
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
|
|
|
@ -94,8 +94,7 @@
|
|||
startLoadingSpinner()
|
||||
print "A public user was selected with username=" + userSelected
|
||||
session.user.Update("name", userSelected)
|
||||
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
|
||||
session.user.Update("friendlyName", regex.ReplaceAll(userSelected, ""))
|
||||
|
||||
' save userid to session
|
||||
for each user in publicUsersNodes
|
||||
if user.name = userSelected
|
||||
|
@ -161,8 +160,7 @@
|
|||
print "Auth token found in registry"
|
||||
session.user.Update("authToken", myAuthToken)
|
||||
session.user.Update("name", myUsername)
|
||||
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
|
||||
session.user.Update("friendlyName", regex.ReplaceAll(myUsername, ""))
|
||||
|
||||
print "Attempting to use API with auth token"
|
||||
currentUser = AboutMe()
|
||||
if currentUser = invalid
|
||||
|
|
Loading…
Reference in New Issue
Block a user