这是一个自我回答的问题。
问题: 无法播放受PlayReady DRM保护的视频。
答案 0 :(得分:0)
这是工作样本
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)。