Skip to content

Commit

Permalink
Update API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jellyfin-bot committed Jan 14, 2024
1 parent 127d08f commit 424951c
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 68 deletions.
15 changes: 11 additions & 4 deletions docs/api/components_ItemGrid_LoadVideoContentTask.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
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
Expand Down Expand Up @@ -496,26 +496,33 @@
"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
Expand Down
12 changes: 10 additions & 2 deletions docs/api/components_home_HomeItem.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
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


Expand Down
8 changes: 8 additions & 0 deletions docs/api/components_manager_ViewCreator.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
' 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 = ""
Expand Down
78 changes: 41 additions & 37 deletions docs/api/components_music_AudioPlayerView.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,46 +390,10 @@
' 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"
Expand All @@ -453,6 +417,46 @@
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"
Expand Down
14 changes: 11 additions & 3 deletions docs/api/components_quickConnect_QuickConnect.bs.html

Large diffs are not rendered by default.

20 changes: 6 additions & 14 deletions docs/api/components_quickConnect_QuickConnectDialog.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,32 @@
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?
authenticated = m.checkTask.authenticated
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
Expand Down
20 changes: 16 additions & 4 deletions docs/api/components_video_VideoPlayerView.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,17 @@

' 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&)
Expand Down Expand Up @@ -340,7 +349,7 @@
' 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
Expand All @@ -352,7 +361,10 @@
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

Expand Down
6 changes: 2 additions & 4 deletions docs/api/source_ShowScenes.bs.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 424951c

Please sign in to comment.