Files
playlet-piped/playlet-lib/src/components/EcpArgs.bs
T

49 lines
1.3 KiB
Plaintext

import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function InitEcpArgs()
m.videoQueue = m.top.findNode("VideoQueue")
LaunchArgumentsReceived()
m.scene.ObserveField("inputArgs", FuncName(InputArgumentsReceived))
if m.scene.inputArgs <> invalid
InputArgumentsReceived()
end if
end function
function LaunchArgumentsReceived() as void
launchArgs = m.scene.launchArgs
LogInfo("LaunchArgumentsReceived", launchArgs)
ProcessArguments(launchArgs)
end function
function InputArgumentsReceived() as void
inputArgs = m.scene.inputArgs
LogInfo("InputArgumentsReceived", inputArgs)
ProcessArguments(inputArgs)
end function
function ProcessArguments(args as object) as void
if args = invalid
return
end if
if not StringUtils.IsNullOrEmpty(args.contentId) and StringUtils.IsNullOrEmpty(args.videoId)
args.videoId = args.contentId
end if
if args.timestamp <> invalid
args.timestamp = args.timestamp.ToInt()
end if
if not StringUtils.IsNullOrEmpty(args.videoId)
node = CreateObject("roSGNode", "VideoContentNode")
node.videoId = args.videoId
if args.timestamp <> invalid
node.timestamp = args.timestamp
end if
m.videoQueue.playVideo = node
end if
end function