jf-roku/docs/api/source_Main.brs.html
2023-10-28 21:26:12 +00:00

954 lines
49 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>jellyfin-roku api docs Source: source/Main.brs</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.dark.css">
<link type="text/css" rel="stylesheet" href="styles/site.darkly.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">jellyfin-roku api docs</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="module-AlbumData.html">AlbumData</a></li><li><a href="module-AlbumGrid.html">AlbumGrid</a></li><li><a href="module-AlbumTrackList.html">AlbumTrackList</a></li><li><a href="module-AlbumView.html">AlbumView</a></li><li><a href="module-Alpha.html">Alpha</a></li><li><a href="module-ArtistView.html">ArtistView</a></li><li><a href="module-AudioPlayer.html">AudioPlayer</a></li><li><a href="module-AudioPlayerView.html">AudioPlayerView</a></li><li><a href="module-AudioTrackListItem.html">AudioTrackListItem</a></li><li><a href="module-ButtonGroupHoriz.html">ButtonGroupHoriz</a></li><li><a href="module-ChannelData.html">ChannelData</a></li><li><a href="module-CollectionData.html">CollectionData</a></li><li><a href="module-ConfigData.html">ConfigData</a></li><li><a href="module-ConfigItem.html">ConfigItem</a></li><li><a href="module-ConfigList.html">ConfigList</a></li><li><a href="module-ExtrasItem.html">ExtrasItem</a></li><li><a href="module-ExtrasRowList.html">ExtrasRowList</a></li><li><a href="module-FavoriteItemsTask.html">FavoriteItemsTask</a></li><li><a href="module-FolderData.html">FolderData</a></li><li><a href="module-GetFiltersTask.html">GetFiltersTask</a></li><li><a href="module-GetNextEpisodeTask.html">GetNextEpisodeTask</a></li><li><a href="module-GetPlaybackInfoTask.html">GetPlaybackInfoTask</a></li><li><a href="module-GetShuffleEpisodesTask.html">GetShuffleEpisodesTask</a></li><li><a href="module-GridItem.html">GridItem</a></li><li><a href="module-GridItemSmall.html">GridItemSmall</a></li><li><a href="module-Home.html">Home</a></li><li><a href="module-HomeData.html">HomeData</a></li><li><a href="module-HomeItem.html">HomeItem</a></li><li><a href="module-HomeRows.html">HomeRows</a></li><li><a href="module-IconButton.html">IconButton</a></li><li><a href="module-Image.html">Image</a></li><li><a href="module-ImageData.html">ImageData</a></li><li><a href="module-ItemGrid.html">ItemGrid</a></li><li><a href="module-ItemGridOptions.html">ItemGridOptions</a></li><li><a href="module-Items.html">Items</a></li><li><a href="module-JFButton.html">JFButton</a></li><li><a href="module-JFButtons.html">JFButtons</a></li><li><a href="module-JFGroup.html">JFGroup</a></li><li><a href="module-JFMessageDialog.html">JFMessageDialog</a></li><li><a href="module-JFOverhang.html">JFOverhang</a></li><li><a href="module-JFScene.html">JFScene</a></li><li><a href="module-JFScreen.html">JFScreen</a></li><li><a href="module-JFServer.html">JFServer</a></li><li><a href="module-JFVideo.html">JFVideo</a></li><li><a href="module-ListPoster.html">ListPoster</a></li><li><a href="module-LoadChannelsTask.html">LoadChannelsTask</a></li><li><a href="module-LoadItemsTask.html">LoadItemsTask</a></li><li><a href="module-LoadItemsTask2.html">LoadItemsTask2</a></li><li><a href="module-LoadPhotoTask.html">LoadPhotoTask</a></li><li><a href="module-LoadProgramDetailsTask.html">LoadProgramDetailsTask</a></li><li><a href="module-LoadScreenSaverTimeoutTask.html">LoadScreenSaverTimeoutTask</a></li><li><a href="module-LoadSheduleTask.html">LoadSheduleTask</a></li><li><a href="module-LoadVideoContentTask.html">LoadVideoContentTask</a></li><li><a href="module-LoginScene.html">LoginScene</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-MovieData.html">MovieData</a></li><li><a href="module-MovieDetails.html">MovieDetails</a></li><li><a href="module-MovieLibraryView.html">MovieLibraryView</a></li><li><a href="module-MovieOptions.html">MovieOptions</a></li><li><a href="module-MusicAlbumData.html">MusicAlbumData</a></li><li><a href="module-MusicAlbumSongListData.html">MusicAlbumSongListData</a></li><li><a href="module-MusicArtistData.html">MusicArtistData</a></li><li><a href="module-MusicArtistGridItem.html">MusicArtistGridItem</a></li><li><a href="module-MusicLibraryView.html">MusicLibraryView</a></li><li><a href="module-MusicSongData.html">MusicSongData</a></li><li><a href="module-OptionNode.html">OptionNode</a></li><li><a href="module-OptionsButton.html">OptionsButton</a></li><li><a href="module-OptionsData.html">OptionsData</a></li><li><a href="module-OptionsSlider.html">OptionsSlider</a></li><li><a href="module-OverviewDialog.html">OverviewDialog</a></li><li><a href="module-PersonData.html">PersonData</a></li><li><a href="module-PersonDetails.html">PersonDetails</a></li><li><a href="module-PhotoData.html">PhotoData</a></li><li><a href="module-PhotoDetails.html">PhotoDetails</a></li><li><a href="module-PlaybackDialog.html">PlaybackDialog</a></li><li><a href="module-PlayedCheckmark.html">PlayedCheckmark</a></li><li><a href="module-PlaylistData.html">PlaylistData</a></li><li><a href="module-PlaylistView.html">PlaylistView</a></li><li><a href="module-PlaystateTask.html">PlaystateTask</a></li><li><a href="module-ProgramDetails.html">ProgramDetails</a></li><li><a href="module-PublicUserData.html">PublicUserData</a></li><li><a href="module-QueueManager.html">QueueManager</a></li><li><a href="module-QuickConnect.html">QuickConnect</a></li><li><a href="module-QuickConnectDialog.html">QuickConnectDialog</a></li><li><a href="module-RadioDialog.html">RadioDialog</a></li><li><a href="module-RecordProgramTask.html">RecordProgramTask</a></li><li><a href="module-SceneManager.html">SceneManager</a></li><li><a href="module-ScheduleProgramData.html">ScheduleProgramData</a></li><li><a href="module-SearchBox.html">SearchBox</a></li><li><a href="module-SearchData.html">SearchData</a></li><li><a href="module-SearchResults.html">SearchResults</a></li><li><a href="module-SearchRow.html">SearchRow</a></li><li><a href="module-SearchTask.html">SearchTask</a></li><li><a href="module-SeriesData.html">SeriesData</a></li><li><a href="module-ServerDiscoveryTask.html">ServerDiscoveryTask</a></li><li><a href="module-SetServerScreen.html">SetServerScreen</a></li><li><a href="module-ShowScenes.html">ShowScenes</a></li><li><a href="module-SongItem.html">SongItem</a></li><li><a href="module-Spinner.html">Spinner</a></li><li><a href="module-StandardDialog.html">StandardDialog</a></li><li><a href="module-Subtitles.html">Subtitles</a></li><li><a href="module-TVEpisode.html">TVEpisode</a></li><li><a href="module-TVEpisodeData.html">TVEpisodeData</a></li><li><a href="module-TVEpisodeRow.html">TVEpisodeRow</a></li><li><a href="module-TVEpisodeRowWithOptions.html">TVEpisodeRowWithOptions</a></li><li><a href="module-TVEpisodes.html">TVEpisodes</a></li><li><a href="module-TVListDetails.html">TVListDetails</a></li><li><a href="module-TVListOptions.html">TVListOptions</a></li><li><a href="module-TVSeasonData.html">TVSeasonData</a></li><li><a href="module-TVSeasonRow.html">TVSeasonRow</a></li><li><a href="module-TVShowDescription.html">TVShowDescription</a></li><li><a href="module-TVShowDetails.html">TVShowDetails</a></li><li><a href="module-TextSizeTask.html">TextSizeTask</a></li><li><a href="module-UserData.html">UserData</a></li><li><a href="module-UserItem.html">UserItem</a></li><li><a href="module-UserLibrary.html">UserLibrary</a></li><li><a href="module-UserRow.html">UserRow</a></li><li><a href="module-UserSelect.html">UserSelect</a></li><li><a href="module-VideoData.html">VideoData</a></li><li><a href="module-VideoPlayer.html">VideoPlayer</a></li><li><a href="module-VideoPlayerView.html">VideoPlayerView</a></li><li><a href="module-VideoTrackListItem.html">VideoTrackListItem</a></li><li><a href="module-ViewCreator.html">ViewCreator</a></li><li><a href="module-WhatsNewDialog.html">WhatsNewDialog</a></li><li><a href="module-baserequest.html">baserequest</a></li><li><a href="module-captionTask.html">captionTask</a></li><li><a href="module-config.html">config</a></li><li><a href="module-deviceCapabilities.html">deviceCapabilities</a></li><li><a href="module-globals.html">globals</a></li><li><a href="module-migrations.html">migrations</a></li><li><a href="module-misc.html">misc</a></li><li><a href="module-quickplay.html">quickplay</a></li><li><a href="module-schedule.html">schedule</a></li><li><a href="module-section.html">section</a></li><li><a href="module-sectionScroller.html">sectionScroller</a></li><li><a href="module-settings.html">settings</a></li><li><a href="module-userauth.html">userauth</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-12">
<div id="main">
<h1 class="page-title">Source: source/Main.brs</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">sub Main (args as dynamic) as void
' The main function that runs when the application is launched.
m.screen = CreateObject("roSGScreen")
' Set global constants
setConstants()
' Write screen tracker for screensaver
WriteAsciiFile("tmp:/scene.temp", "")
MoveFile("tmp:/scene.temp", "tmp:/scene")
m.port = CreateObject("roMessagePort")
m.screen.setMessagePort(m.port)
' Set any initial Global Variables
m.global = m.screen.getGlobalNode()
SaveAppToGlobal()
SaveDeviceToGlobal()
session.Init()
m.scene = m.screen.CreateScene("JFScene")
m.screen.show() ' vscode_rale_tracker_entry
playstateTask = CreateObject("roSGNode", "PlaystateTask")
playstateTask.id = "playstateTask"
sceneManager = CreateObject("roSGNode", "SceneManager")
sceneManager.observeField("dataReturned", m.port)
m.global.addFields({ app_loaded: false, playstateTask: playstateTask, sceneManager: sceneManager })
m.global.addFields({ queueManager: CreateObject("roSGNode", "QueueManager") })
m.global.addFields({ audioPlayer: CreateObject("roSGNode", "AudioPlayer") })
app_start:
' First thing to do is validate the ability to use the API
if not LoginFlow() then return
' tell jellyfin server about device capabilities
PostDeviceProfile()
' remove previous scenes from the stack
sceneManager.callFunc("clearScenes")
' load home page
sceneManager.currentUser = m.global.session.user.name
group = CreateHomeGroup()
group.callFunc("loadLibraries")
sceneManager.callFunc("pushScene", group)
m.scene.observeField("exit", m.port)
' Downloads and stores a fallback font to tmp:/
configEncoding = api.system.GetConfigurationByName("encoding")
if isValid(configEncoding) and isValid(configEncoding.EnableFallbackFont)
if configEncoding.EnableFallbackFont
re = CreateObject("roRegex", "Name.:.(.*?).,.Size", "s")
filename = APIRequest("FallbackFont/Fonts").GetToString()
if isValid(filename)
filename = re.match(filename)
if isValid(filename) and filename.count() > 0
filename = filename[1]
APIRequest("FallbackFont/Fonts/" + filename).gettofile("tmp:/font")
end if
end if
end if
end if
' Save the global last run version of the app
if m.global.app.version &lt;> m.global.app.lastRunVersion
' update global LastRunVersion
set_setting("LastRunVersion", m.global.app.version)
' Show the Whats New popup
if m.global.session.user.settings["load.allowwhatsnew"] = true
dialog = createObject("roSGNode", "WhatsNewDialog")
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
end if
end if
' Save the user last run version of the app
if m.global.session.user.lastRunVersion &lt;> m.global.app.lastRunVersion
' update user LastRunVersion
set_user_setting("LastRunVersion", m.global.app.version)
session.user.Update("lastRunVersion", m.global.app.version)
end if
' Handle input messages
input = CreateObject("roInput")
input.SetMessagePort(m.port)
device = CreateObject("roDeviceInfo")
device.setMessagePort(m.port)
device.EnableScreensaverExitedEvent(true)
device.EnableAppFocusEvent(true)
device.EnableLowGeneralMemoryEvent(true)
device.EnableLinkStatusEvent(true)
device.EnableCodecCapChangedEvent(true)
device.EnableAudioGuideChangedEvent(true)
' Check if we were sent content to play with the startup command (Deep Link)
if isValidAndNotEmpty(args.mediaType) and isValidAndNotEmpty(args.contentId)
deepLinkVideo = {
id: args.contentId,
type: "video"
}
m.global.queueManager.callFunc("push", deepLinkVideo)
m.global.queueManager.callFunc("playQueue")
end if
' This is the core logic loop. Mostly for transitioning between scenes
' This now only references m. fields so could be placed anywhere, in theory
' "group" is always "whats on the screen"
' m.scene's children is the "previous view" stack
while true
msg = wait(0, m.port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
print "CLOSING SCREEN"
return
else if isNodeEvent(msg, "exit")
return
else if isNodeEvent(msg, "closeSidePanel")
group = sceneManager.callFunc("getActiveScene")
if group.lastFocus &lt;> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
else if isNodeEvent(msg, "quickPlayNode")
' measure processing time
timeSpan = CreateObject("roTimespan")
startMediaLoadingSpinner()
group = sceneManager.callFunc("getActiveScene")
reportingNode = msg.getRoSGNode()
itemNode = invalid
if isValid(reportingNode)
itemNode = reportingNode.quickPlayNode
reportingNodeType = reportingNode.subtype()
print "Quick Play reporting node type=", reportingNodeType
' prevent double fire bug
if isValid(reportingNodeType) and (reportingNodeType = "Home" or reportingNodeType = "TVEpisodes")
reportingNode.quickPlayNode = invalid
end if
end if
print "Quick Play started. itemNode=", itemNode
' if itemNode.json &lt;> invalid
' print "itemNode.json=", itemNode.json
' end if
if isValid(itemNode) and isValid(itemNode.id) and itemNode.id &lt;> ""
' make sure there is a type and convert type to lowercase
itemType = invalid
if isValid(itemNode.type) and itemNode.type &lt;> ""
itemType = Lcase(itemNode.type)
else
' grab type from json and convert to lowercase
if isValid(itemNode.json) and isValid(itemNode.json.type)
itemType = Lcase(itemNode.json.type)
end if
end if
print "Quick Play itemNode type=", itemType
' can't play the item without knowing what type it is
if isValid(itemType)
m.global.queueManager.callFunc("clear") ' empty queue/playlist
m.global.queueManager.callFunc("resetShuffle") ' turn shuffle off
if itemType = "episode" or itemType = "movie" or itemType = "video"
quickplay.video(itemNode)
' restore focus
if LCase(group.subtype()) = "tvepisodes"
if isValid(group.lastFocus)
group.lastFocus.setFocus(true)
end if
end if
else if itemType = "audio"
quickplay.audio(itemNode)
else if itemType = "musicalbum"
quickplay.album(itemNode)
else if itemType = "musicartist"
quickplay.artist(itemNode)
else if itemType = "series"
quickplay.series(itemNode)
else if itemType = "season"
quickplay.season(itemNode)
else if itemType = "boxset"
quickplay.boxset(itemNode)
else if itemType = "collectionfolder"
quickplay.collectionFolder(itemNode)
else if itemType = "playlist"
quickplay.playlist(itemNode)
else if itemType = "userview"
quickplay.userView(itemNode)
else if itemType = "folder"
quickplay.folder(itemNode)
else if itemType = "musicvideo"
quickplay.musicVideo(itemNode)
else if itemType = "person"
quickplay.person(itemNode)
else if itemType = "tvchannel"
quickplay.tvChannel(itemNode)
else if itemType = "program"
quickplay.program(itemNode)
end if
m.global.queueManager.callFunc("playQueue")
end if
end if
stopLoadingSpinner()
elapsed = timeSpan.TotalMilliseconds() / 1000
print "Quick Play finished loading in " + elapsed.toStr() + " seconds."
else if isNodeEvent(msg, "selectedItem")
' If you select a library from ANYWHERE, follow this flow
selectedItem = msg.getData()
if isValid(selectedItem)
selectedItemType = selectedItem.type
if selectedItemType = "CollectionFolder"
if selectedItem.collectionType = "movies"
group = CreateMovieLibraryView(selectedItem)
else if selectedItem.collectionType = "music"
group = CreateMusicLibraryView(selectedItem)
else
group = CreateItemGrid(selectedItem)
end if
sceneManager.callFunc("pushScene", group)
else if selectedItemType = "Folder" and selectedItem.json.type = "Genre"
' User clicked on a genre folder
if selectedItem.json.MovieCount > 0
group = CreateMovieLibraryView(selectedItem)
else
group = CreateItemGrid(selectedItem)
end if
sceneManager.callFunc("pushScene", group)
else if selectedItemType = "Folder" and selectedItem.json.type = "MusicGenre"
group = CreateMusicLibraryView(selectedItem)
sceneManager.callFunc("pushScene", group)
else if selectedItemType = "UserView" or selectedItemType = "Folder" or selectedItemType = "Channel" or selectedItemType = "Boxset"
group = CreateItemGrid(selectedItem)
sceneManager.callFunc("pushScene", group)
else if selectedItemType = "Episode"
' User has selected a TV episode they want us to play
audio_stream_idx = 0
if isValid(selectedItem.selectedAudioStreamIndex) and selectedItem.selectedAudioStreamIndex > 0
audio_stream_idx = selectedItem.selectedAudioStreamIndex
end if
selectedItem.selectedAudioStreamIndex = audio_stream_idx
' Display playback options dialog
if selectedItem.json.userdata.PlaybackPositionTicks > 0
m.global.queueManager.callFunc("hold", selectedItem)
playbackOptionDialog(selectedItem.json.userdata.PlaybackPositionTicks, selectedItem.json)
else
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", selectedItem)
m.global.queueManager.callFunc("playQueue")
end if
else if selectedItemType = "Series"
group = CreateSeriesDetailsGroup(selectedItem.json.id)
else if selectedItemType = "Season"
group = CreateSeasonDetailsGroupByID(selectedItem.json.SeriesId, selectedItem.id)
else if selectedItemType = "Movie"
' open movie detail page
group = CreateMovieDetailsGroup(selectedItem)
else if selectedItemType = "Person"
CreatePersonView(selectedItem)
else if selectedItemType = "TvChannel" or selectedItemType = "Video" or selectedItemType = "Program"
' User selected a Live TV channel / program
' Show Channel Loading spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Channel Data")
m.scene.dialog = dialog
' User selected a program. Play the channel the program is on
if LCase(selectedItemType) = "program"
selectedItem.id = selectedItem.json.ChannelId
end if
' Display playback options dialog
if selectedItem.json.userdata.PlaybackPositionTicks > 0
dialog.close = true
m.global.queueManager.callFunc("hold", selectedItem)
playbackOptionDialog(selectedItem.json.userdata.PlaybackPositionTicks, selectedItem.json)
else
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", selectedItem)
m.global.queueManager.callFunc("playQueue")
dialog.close = true
end if
else if selectedItemType = "Photo"
' Nothing to do here, handled in ItemGrid
else if selectedItemType = "MusicArtist"
group = CreateArtistView(selectedItem.json)
if not isValid(group)
message_dialog(tr("Unable to find any albums or songs belonging to this artist"))
end if
else if selectedItemType = "MusicAlbum"
group = CreateAlbumView(selectedItem.json)
else if selectedItemType = "MusicVideo"
group = CreateMovieDetailsGroup(selectedItem)
else if selectedItemType = "Playlist"
group = CreatePlaylistView(selectedItem.json)
else if selectedItemType = "Audio"
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("push", selectedItem.json)
m.global.queueManager.callFunc("playQueue")
else
' TODO - switch on more node types
message_dialog("This type is not yet supported: " + selectedItemType + ".")
end if
end if
else if isNodeEvent(msg, "movieSelected")
' If you select a movie from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
group = CreateMovieDetailsGroup(node)
else if isNodeEvent(msg, "seriesSelected")
' If you select a TV Series from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
group = CreateSeriesDetailsGroup(node.id)
else if isNodeEvent(msg, "seasonSelected")
' If you select a TV Season from ANYWHERE, follow this flow
ptr = msg.getData()
' ptr is for [row, col] of selected item... but we only have 1 row
series = msg.getRoSGNode()
if isValid(ptr) and ptr.count() >= 2 and isValid(ptr[1]) and isValid(series) and isValid(series.seasonData) and isValid(series.seasonData.items)
node = series.seasonData.items[ptr[1]]
group = CreateSeasonDetailsGroup(series.itemContent, node)
end if
else if isNodeEvent(msg, "musicAlbumSelected")
' If you select a Music Album from ANYWHERE, follow this flow
ptr = msg.getData()
albums = msg.getRoSGNode()
node = albums.musicArtistAlbumData.items[ptr]
group = CreateAlbumView(node)
else if isNodeEvent(msg, "appearsOnSelected")
' If you select a Music Album from ANYWHERE, follow this flow
ptr = msg.getData()
albums = msg.getRoSGNode()
node = albums.musicArtistAppearsOnData.items[ptr]
group = CreateAlbumView(node)
else if isNodeEvent(msg, "playSong")
' User has selected audio they want us to play
selectedIndex = msg.getData()
screenContent = msg.getRoSGNode()
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("push", screenContent.albumData.items[selectedIndex])
m.global.queueManager.callFunc("playQueue")
else if isNodeEvent(msg, "playItem")
' User has selected audio they want us to play
selectedIndex = msg.getData()
screenContent = msg.getRoSGNode()
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("push", screenContent.albumData.items[selectedIndex])
m.global.queueManager.callFunc("playQueue")
else if isNodeEvent(msg, "playAllSelected")
' User has selected playlist of of audio they want us to play
screenContent = msg.getRoSGNode()
m.spinner = screenContent.findNode("spinner")
m.spinner.visible = true
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("set", screenContent.albumData.items)
m.global.queueManager.callFunc("playQueue")
else if isNodeEvent(msg, "playArtistSelected")
' User has selected playlist of of audio they want us to play
screenContent = msg.getRoSGNode()
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("set", CreateArtistMix(screenContent.pageContent.id).Items)
m.global.queueManager.callFunc("playQueue")
else if isNodeEvent(msg, "instantMixSelected")
' User has selected instant mix
' User has selected playlist of of audio they want us to play
screenContent = msg.getRoSGNode()
m.spinner = screenContent.findNode("spinner")
if isValid(m.spinner)
m.spinner.visible = true
end if
viewHandled = false
' Create instant mix based on selected album
if isValid(screenContent.albumData)
if isValid(screenContent.albumData.items)
if screenContent.albumData.items.count() > 0
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("set", CreateInstantMix(screenContent.albumData.items[0].id).Items)
m.global.queueManager.callFunc("playQueue")
viewHandled = true
end if
end if
end if
if not viewHandled
' Create instant mix based on selected artist
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("set", CreateInstantMix(screenContent.pageContent.id).Items)
m.global.queueManager.callFunc("playQueue")
end if
else if isNodeEvent(msg, "search_value")
query = msg.getRoSGNode().search_value
group.findNode("SearchBox").visible = false
options = group.findNode("SearchSelect")
options.visible = true
options.setFocus(true)
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Search Data")
m.scene.dialog = dialog
results = SearchMedia(query)
dialog.close = true
options.itemData = results
options.query = query
else if isNodeEvent(msg, "itemSelected")
' Search item selected
node = getMsgPicker(msg)
' TODO - swap this based on target.mediatype
' types: [ Series (Show), Episode, Movie, Audio, Person, Studio, MusicArtist ]
if node.type = "Series"
group = CreateSeriesDetailsGroup(node.id)
else if node.type = "Movie"
group = CreateMovieDetailsGroup(node)
else if node.type = "MusicArtist"
group = CreateArtistView(node.json)
else if node.type = "MusicAlbum"
group = CreateAlbumView(node.json)
else if node.type = "MusicVideo"
group = CreateMovieDetailsGroup(node)
else if node.type = "Audio"
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("push", node.json)
m.global.queueManager.callFunc("playQueue")
else if node.type = "Person"
group = CreatePersonView(node)
else if node.type = "TvChannel"
group = CreateVideoPlayerGroup(node.id)
sceneManager.callFunc("pushScene", group)
else if node.type = "Episode"
group = CreateVideoPlayerGroup(node.id)
sceneManager.callFunc("pushScene", group)
else if node.type = "Audio"
selectedIndex = msg.getData()
screenContent = msg.getRoSGNode()
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("push", screenContent.albumData.items[node.id])
m.global.queueManager.callFunc("playQueue")
else
' TODO - switch on more node types
message_dialog("This type is not yet supported: " + node.type + ".")
end if
else if isNodeEvent(msg, "buttonSelected")
' If a button is selected, we have some determining to do
btn = getButton(msg)
group = sceneManager.callFunc("getActiveScene")
if isValid(btn) and btn.id = "play-button"
' User chose Play button from movie detail view
' Check if a specific Audio Stream was selected
audio_stream_idx = 0
if isValid(group) and isValid(group.selectedAudioStreamIndex)
audio_stream_idx = group.selectedAudioStreamIndex
end if
group.itemContent.selectedAudioStreamIndex = audio_stream_idx
group.itemContent.id = group.selectedVideoStreamId
' Display playback options dialog
if group.itemContent.json.userdata.PlaybackPositionTicks > 0
m.global.queueManager.callFunc("hold", group.itemContent)
playbackOptionDialog(group.itemContent.json.userdata.PlaybackPositionTicks, group.itemContent.json)
else
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", group.itemContent)
m.global.queueManager.callFunc("playQueue")
end if
if isValid(group) and isValid(group.lastFocus) and isValid(group.lastFocus.id) and group.lastFocus.id = "main_group"
buttons = group.findNode("buttons")
if isValid(buttons)
group.lastFocus = group.findNode("buttons")
end if
end if
if isValid(group) and isValid(group.lastFocus)
group.lastFocus.setFocus(true)
end if
else if btn &lt;> invalid and btn.id = "trailer-button"
' User chose to play a trailer from the movie detail view
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading trailer")
m.scene.dialog = dialog
trailerData = api.users.GetLocalTrailers(m.global.session.user.id, group.id)
if isValid(trailerData) and isValid(trailerData[0]) and isValid(trailerData[0].id)
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("set", trailerData)
m.global.queueManager.callFunc("playQueue")
dialog.close = true
end if
if isValid(group) and isValid(group.lastFocus)
group.lastFocus.setFocus(true)
end if
else if btn &lt;> invalid and btn.id = "watched-button"
movie = group.itemContent
if isValid(movie) and isValid(movie.watched) and isValid(movie.id)
if movie.watched
UnmarkItemWatched(movie.id)
else
MarkItemWatched(movie.id)
end if
movie.watched = not movie.watched
end if
else if btn &lt;> invalid and btn.id = "favorite-button"
movie = group.itemContent
if movie.favorite
UnmarkItemFavorite(movie.id)
else
MarkItemFavorite(movie.id)
end if
movie.favorite = not movie.favorite
else
' If there are no other button matches, check if this is a simple "OK" Dialog &amp; Close if so
dialog = msg.getRoSGNode()
if dialog.id = "OKDialog"
dialog.unobserveField("buttonSelected")
dialog.close = true
end if
end if
else if isNodeEvent(msg, "optionSelected")
button = msg.getRoSGNode()
group = sceneManager.callFunc("getActiveScene")
if button.id = "goto_search" and isValid(group)
' Exit out of the side panel
panel = group.findNode("options")
panel.visible = false
if isValid(group.lastFocus)
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
group = CreateSearchPage()
sceneManager.callFunc("pushScene", group)
group.findNode("SearchBox").findNode("search_Key").setFocus(true)
group.findNode("SearchBox").findNode("search_Key").active = true
else if button.id = "change_server"
unset_setting("server")
session.server.Delete()
SignOut(false)
sceneManager.callFunc("clearScenes")
goto app_start
else if button.id = "change_user"
SignOut(false)
sceneManager.callFunc("clearScenes")
goto app_start
else if button.id = "sign_out"
SignOut()
sceneManager.callFunc("clearScenes")
goto app_start
else if button.id = "settings"
' Exit out of the side panel
panel = group.findNode("options")
panel.visible = false
if isValid(group) and isValid(group.lastFocus)
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
sceneManager.callFunc("settings")
end if
else if isNodeEvent(msg, "selectSubtitlePressed")
node = m.scene.focusedChild
if node.focusedChild &lt;> invalid and node.focusedChild.isSubType("JFVideo")
trackSelected = selectSubtitleTrack(node.Subtitles, node.SelectedSubtitle)
if trackSelected &lt;> invalid and trackSelected &lt;> -2
changeSubtitleDuringPlayback(trackSelected)
end if
end if
else if isNodeEvent(msg, "selectPlaybackInfoPressed")
node = m.scene.focusedChild
if node.focusedChild &lt;> invalid and node.focusedChild.isSubType("JFVideo")
info = GetPlaybackInfo()
show_dialog(tr("Playback Information"), info)
end if
else if isNodeEvent(msg, "state")
node = msg.getRoSGNode()
if isValid(node) and isValid(node.state)
if node.selectedItemType = "TvChannel" and node.state = "finished"
video = CreateVideoPlayerGroup(node.id)
m.global.sceneManager.callFunc("pushScene", video)
m.global.sceneManager.callFunc("deleteSceneAtIndex", 2)
else if node.state = "finished"
node.control = "stop"
' If node allows retrying using Transcode Url, give that shot
if isValid(node.retryWithTranscoding) and node.retryWithTranscoding
retryVideo = CreateVideoPlayerGroup(node.Id, invalid, node.audioIndex, true, false)
m.global.sceneManager.callFunc("popScene")
if isValid(retryVideo)
m.global.sceneManager.callFunc("pushScene", retryVideo)
end if
else if not isValid(node.showID)
sceneManager.callFunc("popScene")
else
autoPlayNextEpisode(node.id, node.showID)
end if
end if
end if
else if type(msg) = "roDeviceInfoEvent"
event = msg.GetInfo()
if event.exitedScreensaver = true
sceneManager.callFunc("resetTime")
group = sceneManager.callFunc("getActiveScene")
if isValid(group) and isValid(group.subtype())
' refresh the current view
if group.subtype() = "Home"
currentTime = CreateObject("roDateTime").AsSeconds()
group.timeLastRefresh = currentTime
group.callFunc("refresh")
end if
' todo: add other screens to be refreshed - movie detail, tv series, episode list etc.
end if
else if isValid(event.audioGuideEnabled)
tmpGlobalDevice = m.global.device
tmpGlobalDevice.AddReplace("isaudioguideenabled", event.audioGuideEnabled)
' update global device array
m.global.setFields({ device: tmpGlobalDevice })
else if isValid(event.Mode)
' Indicates the current global setting for the Caption Mode property, which may be one of the following values:
' "On"
' "Off"
' "Instant replay"
' "When mute" (Only returned for a TV; this option is not available on STBs).
print "event.Mode = ", event.Mode
if isValid(event.Mute)
print "event.Mute = ", event.Mute
end if
else if isValid(event.linkStatus)
' True if the device currently seems to have an active network connection.
print "event.linkStatus = ", event.linkStatus
else if isValid(event.generalMemoryLevel)
' This event will be sent first when the OS transitions from "normal" to "low" state and will continue to be sent while in "low" or "critical" states.
' - "normal" means that the general memory is within acceptable levels
' - "low" means that the general memory is below acceptable levels but not critical
' - "critical" means that general memory are at dangerously low level and that the OS may force terminate the application
print "event.generalMemoryLevel = ", event.generalMemoryLevel
session.Update("memoreyLevel", event.generalMemoryLevel)
else if isValid(event.audioCodecCapabilityChanged)
' The audio codec capability has changed if true.
print "event.audioCodecCapabilityChanged = ", event.audioCodecCapabilityChanged
PostDeviceProfile()
else if isValid(event.videoCodecCapabilityChanged)
' The video codec capability has changed if true.
print "event.videoCodecCapabilityChanged = ", event.videoCodecCapabilityChanged
PostDeviceProfile()
else if isValid(event.appFocus)
' It is set to False when the System Overlay (such as the confirm partner button HUD or the caption control overlay) takes focus and True when the channel regains focus
print "event.appFocus = ", event.appFocus
else
print "Unhandled roDeviceInfoEvent:"
print msg.GetInfo()
end if
else if type(msg) = "roInputEvent"
if msg.IsInput()
info = msg.GetInfo()
if info.DoesExist("mediatype") and info.DoesExist("contentid")
inputEventVideo = {
id: info.contentId,
type: "video"
}
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", inputEventVideo)
m.global.queueManager.callFunc("playQueue")
end if
end if
else if isNodeEvent(msg, "dataReturned")
popupNode = msg.getRoSGNode()
if isValid(popupNode) and isValid(popupNode.returnData)
selectedItem = m.global.queueManager.callFunc("getHold")
m.global.queueManager.callFunc("clearHold")
if isValid(selectedItem) and selectedItem.count() > 0 and isValid(selectedItem[0])
if popupNode.returnData.indexselected = 0
'Resume video from resume point
startingPoint = 0
if isValid(selectedItem[0].json) and isValid(selectedItem[0].json.UserData) and isValid(selectedItem[0].json.UserData.PlaybackPositionTicks)
if selectedItem[0].json.UserData.PlaybackPositionTicks > 0
startingPoint = selectedItem[0].json.UserData.PlaybackPositionTicks
end if
end if
selectedItem[0].startingPoint = startingPoint
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", selectedItem[0])
m.global.queueManager.callFunc("playQueue")
else if popupNode.returnData.indexselected = 1
'Start Over from beginning selected, set position to 0
selectedItem[0].startingPoint = 0
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", selectedItem[0])
m.global.queueManager.callFunc("playQueue")
else if popupNode.returnData.indexselected = 2
' User chose Go to series
CreateSeriesDetailsGroup(selectedItem[0].json.SeriesId)
else if popupNode.returnData.indexselected = 3
' User chose Go to season
CreateSeasonDetailsGroupByID(selectedItem[0].json.SeriesId, selectedItem[0].json.seasonID)
else if popupNode.returnData.indexselected = 4
' User chose Go to episode
CreateMovieDetailsGroup(selectedItem[0])
end if
end if
end if
else
print "Unhandled " type(msg)
print msg
end if
end while
end sub
</pre>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="jsdoc-message">Source code: <a href="https://github.com/jellyfin/jellyfin-roku">https://github.com/jellyfin/jellyfin-roku</a></span><span class="jsdoc-message">Jellyfin Roku Development Forum: <a href="https://forum.jellyfin.org/f-roku-development">https://forum.jellyfin.org/f-roku-development</a></span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a>
on Oct 28th 2023
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>