首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Roku (Brightscript) -播放受DRM保护的视频内容

Roku (Brightscript) -播放受DRM保护的视频内容
EN

Stack Overflow用户
提问于 2018-11-02 17:36:53
回答 1查看 571关注 0票数 0

这是一个自我回答的问题。

问题:无法播放受PlayReady数字版权管理保护的视频。

EN

回答 1

Stack Overflow用户

发布于 2018-11-02 17:36:53

以下是工作示例

代码语言:javascript
运行
复制
    if m.VideoPlayer = invalid
        m.VideoPlayer = m.top.createChild("Video")
        m.VideoPlayer.id = "VideoPlayer"
        m.VideoPlayer.observeField("state", "OnVideoStateChange")
    end if
    drmParams = {}

    videoContent = createObject("RoSGNode", "ContentNode")
    videoContent.Live = remoteContent.IsLive
    videoContent.Url = remoteContent.Path

    if remoteContent.CodecType = "DashWideVineDrm" then
        videoContent.StreamFormat = "dash"
        drmparams.licenseServerURL = remoteContent.DrmRightsUrl
        drmParams.KeySystem = "widevine"
    else if remoteContent.CodecType = "PlayReadyDrm" then
        videoContent.StreamFormat = "ism"
        drmParams.KeySystem = "playready"
        drmParams.encodingType = "PlayReadyLicenseAcquisitionUrl"
        drmParams.encodingKey = remoteContent.DrmRightsUrl
    else
        videoContent.StreamFormat = "mp4"
    end if
    videoContent.drmParams = drmParams

    device = CreateObject("roDeviceInfo")

    httpAgent = CreateObject("roHttpAgent")
    if httpAgent <> invalid then
        httpAgent.SetCertificatesFile("common:/certs/ca-bundle.crt")
        httpAgent.InitClientCertificates()
        httpAgent.EnableCookies()
        httpAgent.AddHeader("X-Roku-Reserved-Dev-Id", "")
        if remoteContent.MYCUSTOMHEADER1 <> invalid and remoteContent.MYCUSTOMHEADER1 <> "" then 
            httpAgent.AddHeader("MY-CUSTOM-HEADER2", remoteContent.MYCUSTOMHEADER1)
        end if
        if remoteContent.MYCUSTOMHEADER2 <> invalid and remoteContent.MYCUSTOMHEADER2 <> "" then 
            httpAgent.AddHeader("MY-CUSTOM-HEADER2", remoteContent.MYCUSTOMHEADER2)
        end if
        m.VideoPlayer.setHttpAgent(httpAgent)
    else
        headers = []
        headers.push("X-Roku-Reserved-Dev-Id:")
        if remoteContent.MYCUSTOMHEADER1 <> invalid and remoteContent.MYCUSTOMHEADER1 <> "" then headers.push("MY-CUSTOM-HEADER1:" + remoteContent.MYCUSTOMHEADER1)
        if remoteContent.MYCUSTOMHEADER2 <> invalid and remoteContent.MYCUSTOMHEADER2 <> "" then headers.push("MY-CUSTOM-HEADER2:" + remoteContent.MYCUSTOMHEADER2)
        videoContent.HttpHeaders = headers
        videoContent.HttpSendClientCertificates = true
        videoContent.HttpCertificatesFile = "common:/certs/ca-bundle.crt"
        m.VideoPlayer.EnableCookies()
        m.VideoPlayer.SetCertificatesFile("common:/certs/ca-bundle.crt")
        m.VideoPlayer.InitClientCertificates()
    end if

    m.VideoPlayer.content = videoContent
    m.VideoPlayer.control = "play"

注意:如果您使用PlayReady,请不要填充drmParams.licenseServerURL,因为它将无法播放DRM错误(-6)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53115997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档