gpt4 book ai didi

roku - 如何从 Brightscript 调用 Roku channel 的 XML 代码?

转载 作者:行者123 更新时间:2023-12-02 09:44:54 25 4
gpt4 key购买 nike

我正在尝试使用下面的 XML Roku Channel、Scenegraph 代码填充标签列表。我收到这些错误:

BRIGHTSCRIPT: ERROR: roSGScreen: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)

调用Brightscript代码:

   ' on Button press handle
Sub onItemSelected()
showChannelSGScreen()
End Sub

sub showChannelSGScreen()
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("LabelListExample")
screen.show()

while(true)
msg = wait(0, m.port)
msgType = type(msg)

if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end while

end sub

XML代码:

<?xml version = "1.0" encoding = "utf-8" ?>

<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->

<component name = "LabelListExample" extends = "Group" initialFocus = "exampleLabelList" >

<script type = "text/brightscript" >

<![CDATA[

sub init()
examplerect = m.top.boundingRect()
centerx = (1280 - examplerect.width) / 2
centery = (720 - examplerect.height) / 2
m.top.translation = [ centerx, centery ]
end sub

]]>

</script>

<children >

<LabelList id = "exampleLabelList" >

<ContentNode role = "content" >
<ContentNode title = "Renderable Nodes" />
<ContentNode title = "Z-Order/Parent-Child" />
<ContentNode title = "Animations" />
<ContentNode title = "Events and Observers" />
</ContentNode>

</LabelList>

</children>

</component>

我的问题是:从 Brightscript 调用 XML 的正确方法是什么?

*****完整错误消息**:

BRIGHTSCRIPT: ERROR: roSGScreen: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected: 1* ...ailsScreen/DetailsScreen.brs(103) screen.setMessagePort(m.port)

Current Function:
100: sub showChannelSGScreen()
101: screen = CreateObject("roSGScreen")
102: m.port = CreateObject("roMessagePort")
103:* screen.setMessagePort(m.port)
104: scene = screen.CreateScene("LabelListExample")
105: screen.show()
106:
107: while(true)
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/components/screens/DetailsScreen/DetailsScreen.brs(103)
103: screen.setMessagePort(m.port)
Backtrace:
#1 Function showchannelsgscreen() As Void
file/line: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(103)
#0 Function onitemselected() As Void
file/line: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(95)
Local Variables:
global Interface:ifGlobal
m roAssociativeArray refcnt=3 count:7
screen Invalid
scene <uninitialized>
msg <uninitialized>
msgtype <uninitialized>
Threads:
ID Location Source Code
0 pkg:/source/main.brs(20) msg = wait(0, port)
1* ...ailsScreen/DetailsScreen.brs(103) screen.setMessagePort(m.port)
*selected

Brightscript Debugger>
Thread detached
>>> Details >> OnkeyEvent

Thread detached

最佳答案

CreateScene 方法只能以场景组件作为参数来调用。您的情况下的 LabelListExample 组件不是场景,因为它扩展了 Group。更改此行:

<component name = "LabelListExample" extends = "Group" initialFocus = "exampleLabelList" >

对此:

<component name = "LabelListExample" extends = "Scene" initialFocus = "exampleLabelList" >

关于roku - 如何从 Brightscript 调用 Roku channel 的 XML 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45618109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com