Files
playlet-piped/playlet/src/source/Main.bs
T
Brahim Hadriche 2fdbb18e33 Clear playlet lib arg (#84)
* Clear playlet lib arg

* changelog
2023-06-24 23:58:12 -04:00

82 lines
2.6 KiB
Plaintext

' Playlet (App to play videos from an Invidious server on Roku TVs)
' Copyright (C) 2022 Brahim Hadriche
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU Affero General Public License for more details.
' You should have received a copy of the GNU Affero General Public License
' along with this program. If not, see <https://www.gnu.org/licenses/>.
function Main(args as object) as void
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
m.global = screen.getGlobalNode()
ClearPlayletLibUrlsIfNeeded(args)
scene = screen.CreateScene("BootstrapScene")
screen.show()
scene.ObserveField("exitChannel", m.port)
scene.launchArgs = args
' These vars are needed to pass certification.
' The actual work is done in Playlet Lib
' bs:disable-next-line
contentId = args.contentId
' bs:disable-next-line
mediaType = args.mediaType
' Do not signal app launch complete here, we're doing it over at Playlet Lib
' This is needed to pass cetification
if false
scene.signalBeacon("AppLaunchComplete")
end if
input = CreateObject("roInput")
input.setMessagePort(m.port)
#if DEBUG
' The following comment is to enable the SceneGraph inspector
' on the VSCode BrightScript plugin.
' vscode_rdb_on_device_component_entry
' The following comment is to enable RALE tracking
' vscode_rale_tracker_entry
#end if
while true
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
return
end if
else if msgType = "roSGNodeEvent"
field = msg.getField()
data = msg.getData()
if field = "exitChannel" and data = true
END
end if
else if msgType = "roInputEvent"
scene.inputArgs = msg.getInfo()
end if
end while
end function
function ClearPlayletLibUrlsIfNeeded(launchArgs as object) as void
if launchArgs = invalid or launchArgs.clearPlayletLibUrls = invalid
return
end if
DeleteRegistryKey("playlet_lib_urls", "Playlet")
end function