Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
matrixebiz
Roku Guru

Change User-Agent of Roku Video Player

Hello, is it possible to change the User-Agent that the Roku video player uses to emulate iPad instead of what it currently uses?

I have a HLS stream feed that only works on an iPad and not in Windows VLC or the Roku Video Player so I would like to change the User-Agent of the Roku Video Player to be an iPad. 
Is this possible? What User-Agent does the Roku Video player currently use? Thank you

I found this thread : https://forums.roku.com/viewtopic.php?t=57084 but I'm not sure what I have to do if possible. I would like to be able to specify/change the User-Agent in the Scengraph Categories/Feed file for the stream/feed
roVideoPlayer will not be supported Jan 2019 so need to know how to do the change with Scenegraph SDK when it reads the Feeds file.
0 Kudos
19 REPLIES 19
matrixebiz
Roku Guru

Re: Change User-Agent of Roku Video Player

Please let me know if you need more info or if this is not possible. Thanks
0 Kudos
marcelo_cabral
Roku Guru

Re: Change User-Agent of Roku Video Player

All you need to do is add the header

          urlXfer = createObject("roUrlTransfer")
          urlXfer.SetCertificatesFile("common:/certs/ca-bundle.crt")
          urlXfer.InitClientCertificates()
          urlXfer.setUrl(uri)
          urlXfer.setPort(m.port)
         urlXfer.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")



The documentation is here:
https://sdkdocs.roku.com/display/sdkdoc/ifHttpAgent#ifHttpAgent-AddHeader(nameasString,valueasString...
0 Kudos
MasterRed
Visitor

Re: Change User-Agent of Roku Video Player

Saludos Marcelo, mi consulta es parecida a la de matrixebiz o sino igual:
Estoy usando la nueva sdk de roku Multilive: https://github.com/rokudev/multi-live-channel, muy diferente a las anteriores versiones del player, entre este paquete se encuentra la carpeta components y el archivo config.brs, el cual relaciono a continuación, es un ejemplo con varios streaming, la pregunta es: en donde debo colocar el encabezado para el User-Agent, ya que algunos de los streaming a emitir solo podrían funcionar con el User-Agent, Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36, he dedicado mucho tiempo a esto pero sin éxito alguno, de antemano gracias por el apoyo y la atención prestada.

' ********** Copyright 2016 Roku Corp.  All Rights Reserved. **********

Function loadConfig() as Object
    arr = [
'##### Format for inputting stream info #####
'## For each channel, enclose in brackets ## 
'{
'   Title: Channel Title
'   streamFormat: Channel stream type (ex. "hls", "ism", "mp4", etc..)
'   Logo: Channel Logo (ex. "http://Roku.com/Roku.jpg)
'   Stream: URL to stream (ex. http://hls.Roku.com/talks/xxx.m3u8)
'}

{
    Title: "CANAL 1"
    streamFormat: "hls"
    Logo: "pkg:/images/canal-1-.jpg"
    Stream: "http://canal-streaming.com/playlist.m3u8"
}
{
    Title: "CANAL 2"
    streamFormat: "hls"
    Logo: "pkg:/images/canal-2-.jpg"
    Stream: "http://canal-streaming.com/playlist.m3u8"
}
{
    Title: "CANAL 3"
    streamFormat: "hls"
    Logo: "pkg:/images/canal-3-.jpg"
    Stream: "http://canal-streaming.com/playlist.m3u8"
}
    
'##### Make sure all Channel content is above this line #####    
    ] 
    return arr
End Functio
0 Kudos
marcelo_cabral
Roku Guru

Re: Change User-Agent of Roku Video Player

"MasterRed" wrote:
Saludos Marcelo, mi consulta es parecida a la de matrixebiz o sino igual:
Estoy usando la nueva sdk de roku Multilive: https://github.com/rokudev/multi-live-channel, muy diferente a las anteriores versiones del player, entre este paquete se encuentra la carpeta components y el archivo config.brs, el cual relaciono a continuación, es un ejemplo con varios streaming, la pregunta es: en donde debo colocar el encabezado para el User-Agent, ya que algunos de los streaming a emitir solo podrían funcionar con el User-Agent, Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36, he dedicado mucho tiempo a esto pero sin éxito alguno, de antemano gracias por el apoyo y la atención prestada.

Sorry but I will answer in english, I'm from Brazil, so I speak portuguese, I do understand spanish but to write I'm more comfortable in english..
According to the documentation of the Video node, you should set the HttpHeaders on the "Content-Metadata", see the following link section "Data Bindings":
https://sdkdocs.roku.com/display/sdkdoc/Content+Meta-Data

Name: HttpHeaders
Type: array of strings
If set, the Scene Graph Audio or Video node sends these headers to the server. Each string must be of the format "name:value" When used with a Scene Graph Audio or Video node, the node or global HttpAgent is found, as explained elsewhere in this documentation. When this Content Meta-Data is played and this attribute is set, all HTTP headers in the agent are cleared and replaced with the headers defined by this attribute.
0 Kudos
matrixebiz
Roku Guru

Re: Change User-Agent of Roku Video Player

"marcelo.cabral" wrote:
All you need to do is add the header

          urlXfer = createObject("roUrlTransfer")
          urlXfer.SetCertificatesFile("common:/certs/ca-bundle.crt")
          urlXfer.InitClientCertificates()
          urlXfer.setUrl(uri)
          urlXfer.setPort(m.port)
         urlXfer.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")



The documentation is here:
https://sdkdocs.roku.com/display/sdkdoc/ifHttpAgent#ifHttpAgent-AddHeader(nameasString,valueasString...

Hello, thank you for responding, so where would I input this code in the example Video Feed file?;
https://devtools.web.roku.com/videoplay ... issues.xml

or do I have to create a separate file.brs in my channel components folder with the above code in it (see bottom of page);
https://sdkdocs.roku.com/display/sdkdoc/Video

Then I add a line somewhere in the "Item" spot to reference the code?

<item sdImg="https://images/RobHopkins.jpg" hdImg="https://mages/RobHopkins.jpg">
<title>Rob Hopkins: Transition to a world without oil</title>
<contentId>10012</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>hls</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/RobHopkins_2009G_480.m3u8</streamUrl>
</media>
<synopsis></synopsis>
<genres></genres>
<runtime></runtime>
</item>

is there a list of the various agents? So the below is iPad?;
("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
0 Kudos
MasterRed
Visitor

Re: Change User-Agent of Roku Video Player

Hi Marcelo, Thanks for the answer, I will test and comment on the next few days, thanks in advance for your support !.
0 Kudos
MasterRed
Visitor

Re: Change User-Agent of Roku Video Player

Hi, matrixebiz do you have the original roku sdk with which you are working ?, I have put to work different urls that require User-Agent and also Referer, But I need to see the brs files and do the test on the roku device, I have live streaming that request the User-Agent to do tests




<item sdImg="https://images/RobHopkins.jpg" hdImg="https://mages/RobHopkins.jpg">
<title>Rob Hopkins: Transition to a world without oil</title>
<contentId>10012</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>hls</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/RobHopkins_2009G_480.m3u8</streamUrl>
</media>
<synopsis></synopsis>
<genres></genres>
<runtime></runtime>
</item>

is there a list of the various agents? So the below is iPad?;
("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
0 Kudos
belltown
Roku Guru

Re: Change User-Agent of Roku Video Player

It depends on what OS version, browser and browser version you're using, etc. But for an iPad running Safari under iOS 10.2.1, the User-Agent string will be something like:

"Mozilla/5.0 (iPad; CPU OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1"
0 Kudos
matrixebiz
Roku Guru

Re: Change User-Agent of Roku Video Player

@ MasterRed - I am just using the "SceneGraph version of the SDK1 VideoPlayer Channel"  located here : https://github.com/rokudev/videoplayer-channel 
So I'm ready when they get rid of the old code Jan 2019, I need to create my channel in SG instead of the old VideoPlayer SDK

@ Belltown - When you say "It depends on what OS version, browser and browser version you're using", I don't have an iPad but what I am doing is accessing the stream URL on a Windows 7 Chrome browser and the server is returning an error "This content is not available to this user agent" so I use the Chrome Agent switcher plug-in and change the agent to iPad which looks to be emulating "Safari 6 on iOS 6 Apple iPad"  and the stream downloads, so I am trying to get the Roku to emulate the iPad the same way using the Roku User-Agent command, so I guess the User-Agent string can be the latest iPad OS if need be, doesn't matter. Not sure if this will work with the Roku video player switching the User-Agent the way I think it should but would like to try it. Hope that clears up what I'm trying to accomplish but I just don't know where to put the code then call it just before the stream is read in my stream code above.
0 Kudos