Please enter your text to search.

Roku Programming Pitfalls: roVideoScreen DOA

As I become more and more comfortable with programming the Roku DVP, I am slowly amassing a small mountain of notes on common pitfalls. These are the little mistakes that I make over and over and need a quick reminder of what I’m doing wrong.

Here’s a big one. Often times, I will attempt to play a video on the Roku DVP, but when I activate the roVideoSrreen, nothing happens. The roVideoScreen appears on screen, the title of my video appears in the center of the screen, and an empty progress bar appears at the bottom of the screen. Then, nothing happens. The progress indicator never gets populated and no error is logged to the debug terminal. Fixing this situation is usually pretty simple, but the solution is something I need to be reminded of occasionally because it is not included in the Roku SDK documentation.

For any piece of content you want to play on the Roku DVP, you must construct a data structure called a content-meta-data that tells the box how to present your content. The content-meta-data is nothing more than an associative array and building it is fairly straight forward. One of the items in this associative array must have a key of “StreamURLs” (plural). The value of the StreamURLs item must be an array of URLs to video streams. Why an array rather than just one stream URL? Because the Roku DVP is able to intelligently choose between multiple content streams based on the bandwidth available to it at any given moment. Simple enough, right?

In order for the Roku DVP to make the appropriate stream choice from the list of StreamURLs, your content-meta-data must also contain an item with a key of “StreamBitrates”. The value of the StreamBitrates item must be an array of integers. The first integer in that array represents the bitrate of the first stream in the StreamURLs item, the second integer represents the bitrate of the second stream, and so on.

In many cases, the data a developer is using to populate their content-meta-data structure is coming from an XML file. It’s tempting to simply populate the StreamBitrates array with the strings parsed out of your XML. This is a mistake, the items in the StreamBitrates array must be integers. This is what causes the DOA roVideoScreen, a StreamBitrates array populated with non-integers.

How do you turn a string into an integer with BrightScript? A quick glance through the BrightScript Reference Manual isn’t much help. There is not a documented function that takes a string as an argument and returns an integer. There is a function Val(s As String) that takes a string and returns a float, but that is no help. Populating the StreamBitrates array with the results of the Val function yields the same DOA roVideoScreen with an empty progress bar that never gets populated. We need integers, but how do we get them?

The solution to this little issue is an apparently undocumented function that I have only found by digging through the example code distributed with the Roku SDK. The function StrToI(s As String) takes a string as an argument and returns an integer with the value represented by that string. Populating the StreamBitrates array with the results of the StrToI function solves the problem and makes the roVideoScreen behave properly.

Why the StrToI function is not documented in the BrightScript Reference manual is a mystery, especially given its importance to the process of building a working channel.


6 Responses to “Roku Programming Pitfalls: roVideoScreen DOA”

  1. Ignacio says:

    You have no idea how much I thank you for showing how toStrToI(s As String). Even two years later this is not documented. Roku’s documentation is bad, and they should feel bad.

  2. manoflinux says:

    do you know the trancoding settings for VLC so I can stream to the roku from vlc?
    I tried modifying the simple vidoe player and chaning the url or a mp4 file to the streaming url. I am using h.264 (using x264) and mp4a for audio. From what I read that should work, but doesnt. or do I need to modify a different example? Also I am able to stream from the stream using vlc so I know I have the streaming working. I just to modify it work with vlc I think, or my roku code is fubar.
    urls = [""]
    qualities = ["SD"]
    StreamFormat = “mp4″
    title = “a stream test”
    srt = “file://pkg:/source/”

  3. Ryan says:

    Are you implying that Roku can play video content from a user-defined internet source (for example, an HTML5 video from my local new channel’s website)?


    • nowhereman says:

      Sorry, not entirely sure what you’re asking. HTML5 is not a video format, just a web authoring standard. If the videos themselves are in a compatible format they could conceivably be played on Roku.

Leave a Reply