Roku滑动面板

时间:2018-01-25 07:11:00

标签: roku brightscript

我在项目中使用滑动面板。假设我在面板集中有面板A(左侧)和B(右侧)。现在我从B滑到面板C,现在我的面板设置有面板B和C.同样,我继续保持水平深度,现在面板集有面板E(左侧)和F(右侧)。

现在我希望我的面板设置为滑动并在我执行某些操作后直接显示初始面板A和B(例如,按下面板F上的按钮)。

如何实现这一目标?它与你在Roku主屏幕上看到的行为类似。例如:如果我使用Roku字幕样式设置并按下主页按钮,屏幕将滑回主页列表并设置为Home选项的动画,而不管它们之间存在多少个面板。 我尝试了面板的goBackCount属性,但无济于事。请帮忙。

2 个答案:

答案 0 :(得分:0)

将goBackCount设置为大于1的值后,尝试调用onKeyEvent()函数并传递“key”和“press”参数,如下所示:searchTwitter("abc")#pulls all twits that contain keyword 'abc' searchTwitter("from:abc") #pulls all twits from user 'abc' 。如果我正确理解Roku文档,goBackCount仅在按下“left”遥控键后才能工作。

答案 1 :(得分:0)

我使用Roku Tasks和ECP(外部控制API)开始工作。 首先,我创建了一个任务来执行ECP调用以按下远程按钮。 RemoteControlTask​​.xml:

<component name = "RemoteControlTask" extends = "Task" >

<interface>
    <field id = "url" type = "string" />
    <field id = "content" type = "node" />
</interface>
<script type = "text/brightscript" >

<![CDATA[

    sub init()
        m.deviceIP = GetDeviceIP()
        m.top.functionName = "SlideLeft"
    end sub

    function PressKey(key as String)
        request = CreateObject("roUrlTransfer")
        request.SetRequest("POST")
        port = CreateObject("roMessagePort")
        request.SetMessagePort(port)
        url = "http://" + m.deviceIP + ":8060/keypress/" + key
        request.SetUrl(url)
        if(request.AsyncGetToString())
            while(true)
                msg = wait(0, port)
                if(type(msg) = "roUrlEvent")
                    code = msg.GetResponseCode()
                    if(code = 200)                   
                        return true
                    else
                        print code
                    end if
                else if(event = invalid)
                    request.AsyncCancel()
                end if
            end while
        end if
        return invalid
    end function

    function SlideLeft()
        PressKey("left")
    end function

    function GetDeviceIP() as String
        device = CreateObject("roDeviceInfo")
        deviceIP = device.GetIPAddrs()["eth1"]
        return deviceIP
    end function
]]>


</script>


</component>

然后,在将触发回滚的脚本中,将以下内容添加到init()方法:

m.remoteControlTask = CreateObject("roSGNode", "RemoteControlTask")

并添加子程序:

sub RunRemoteControlTask()
    m.remoteControlTask.control = "RUN"
end sub

最后,按下按钮时调用RunRemoteControlTask​​:

RunRemoteControlTask()