You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过BrightScript判断用户是否持有语音遥控器

BrightScript 场景下判断语音遥控器的可行方案

以下是ECP不可用后的两种主流替代实现方案:

  • 方案一:通过roDeviceInfo接口直接查询遥控器属性
    该方法支持同步获取当前已配对所有遥控器的能力属性,Roku OS 8.1及以上版本均支持,代码示例如下:

    Function HasConnectedVoiceRemote() As Boolean
        deviceInfo = CreateObject("roDeviceInfo")
        connectedRemotes = deviceInfo.GetConnectedRemoteControllers()
        
        For Each remote In connectedRemotes
            If remote.DoesExist("supportsVoice") And remote.supportsVoice = True
                Return True
            End If
        End For
        
        Return False
    End Function
    

    只要返回值为true,即代表当前设备已配对至少一个支持语音功能的遥控器。

  • 方案二:监听语音输入事件被动校验
    如果你的业务不需要提前判断语音遥控器存在,仅需要在用户触发操作时响应,可以通过监听语音输入事件反向验证:

    Sub InitVoiceDetection()
        m.voiceInput = CreateObject("roVoiceInput")
        m.voiceInput.SetInputMode("voice")
        m.msgPort = CreateObject("roMessagePort")
        m.voiceInput.SetMessagePort(m.msgPort)
    End Sub
    
    ' 在事件循环中处理回调
    msg = Wait(0, m.msgPort)
    If Type(msg) = "roVoiceInputEvent"
        If msg.GetMessage() = "RecognitionStarted"
            ' 收到该事件即可确认当前使用的是语音遥控器
            m.hasVoiceRemote = True
        End If
    End If
    

注意事项

  • 低版本Roku OS(低于8.1)不支持GetConnectedRemoteControllers接口,可优先使用方案二做兼容
  • 建议两种方案搭配使用,避免部分老旧设备属性返回异常导致的误判

内容的提问来源于stack exchange,提问作者kaho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.10 05:06:03