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: 
SoutheastTv
Visitor

How to get instant updates to Roku?

I'm using the videoplayer example and I need Roku to update instantly when I change my xml files on the server. As it is now it takes hours for it to update or it updates sometimes when I repackage everything and send it to the channel as a new version.

Here is the code in categoryFeed.brs:
Function InitCategoryFeedConnection() As Object

conn = CreateObject("roAssociativeArray")

conn.UrlPrefix = "http://scclib.com/demo/roku/xml"
conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.xml?ts=" + dt.AsSeconds().ToStr()

conn.Timer = CreateObject("roTimespan")

conn.LoadCategoryFeed = load_category_feed
conn.GetCategoryNames = get_category_names

print "created feed connection for " + conn.UrlCategoryFeed
return conn

End Function


categories.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<categories>
<category title="Awesomeness" description="Here it iskhj"
sd_img="http://scclib.com/demo/roku/images/test_sd_poster.jpg"
hd_img="http://scclib.com/demo/roku/images/test_hd_poster.jpg">
<categoryLeaf title="Awesomeness" description="" feed="http://scclib.com/demo/roku/xml/xmlfeed.php"/>
</category>
</categories>


xmlfeed.php
<?php
echo file_get_contents('awesomeness.xml?ts=23423423');
?>


awesomeness.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<feed>
<resultLength>2</resultLength>
<endIndex>2</endIndex>
<item sdImg="" hdImg="">
<title>Awesomeness</title>
<contentId>10001</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<media>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://vidego-http.multicastmedia.com/mm/flvmedia/2878/M/a/k/MakingTheMostofIt_wk1-865721.f4v?cid=2878&aid=865721&afid=1099746</streamUrl>
</media>
<synopsis>This is what's happening</synopsis>
<genres>Crap</genres>
<runtime>120</runtime>
</item>
</feed>
0 Kudos
13 REPLIES 13
bandal
Visitor

Re: How to get instant updates to Roku?

Not sure why, but my xml feeds update immediately when I ftp the files to my servers. Even changing the categories.xml updates within seconds. No modifications to the .brs files in videoplayer. I update my feeds daily and see results now. I used to have a problem with images in the past, but do not see it now. I have the XS and micro memory card too. My feeds are MP4 and HLS and MP3 only. No .flv or .f4v is supported.
0 Kudos
RokuMarkn
Visitor

Re: How to get instant updates to Roku?

Did you add a cache buster parameter to your URL as was suggested in your other thread?

--Mark
0 Kudos
TheEndless
Channel Surfer

Re: How to get instant updates to Roku?

I'd check the content caching and expiration settings on your web server, or try adding something like the following to your php:
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
SoutheastTv
Visitor

Re: How to get instant updates to Roku?

I don't quite know what a cachebuster url means, but I did add ?ts= with a timestamp. You can see it in the code I posted. Did I do it correctly?
0 Kudos
gonzotek
Visitor

Re: How to get instant updates to Roku?

The code in categoryFeed.brs looks mostly right. It should assure that each time the Roku goes to access categories.xml it requests a fresh copy from your server. But then in the categories.xml file, you point to a categoryLeaf feed:

<categoryLeaf title="Awesomeness" description="" feed="http://scclib.com/demo/roku/xml/xmlfeed.php"/>

That feed should have a unique parameter (timestamp) appended to it, so that when the Roku looks for it, it doesn't use cached data:

<categoryLeaf title="Awesomeness" description="" feed="http://scclib.com/demo/roku/xml/xmlfeed.php?ts=20120223104501"/>

Your php script, xmlfeed.php, should only echo the file contents of awesomness.xml. Appending the timestamp in that function is unnecessary (and I'd be surprised if it worked at all):
<?php
echo file_get_contents('awesomeness.xml');
?>

What I would do is dynamically generate the category.xml file so that it timestamps the feed links:
categories.php
<?php
// Send the headers
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');

//Store the current time in seconds into variable $now:
$now = time();

echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
echo '<xml>';
echo ' <categories>';
echo ' <category title="Awesomeness" description="Here it iskhj"';
echo ' sd_img="http://scclib.com/demo/roku/images/test_sd_poster.jpg"';
echo ' hd_img="http://scclib.com/demo/roku/images/test_hd_poster.jpg">';

//Append a timestamp to the category feed:
echo ' <categoryLeaf title="Awesomeness" description="" feed="http://scclib.com/demo/roku/xml/xmlfeed.php?ts=' . $now . '"/>';

echo ' </category>';
echo ' </categories>';
echo '</xml>';
?>
So instead of pointing at category.xml in categoryFeed.brs, you point at categories.php (keeping the timestamp!!😞
conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.php?ts=" + dt.AsSeconds().ToStr()

Awesomness.xml looks fine to me, but if the contents will change often, you'll want to dynamically generate this too. I assume that's why you have the xmlfeed.php script just echoing the file contents, as a placeholder until you are dynamically generating?

PHP has a lot of built-in xml functions, simply echoing everything is definitely not the way to go for production use (I used it only so it would be easier for you to see what's going on). If you aren't comfortable with xml yet, the language may initially be a little intimidating, but it's really quite easy to work with. I recommend reading up on it and the php functions you can use to generate and manipulate it. XML in a Nutshell, or the XML Pocket reference, both published by O'Reilly might be good places to start with XML learning, and the php reference for SimpleXML might help for when you're ready to generate it on the fly
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
0 Kudos
SoutheastTv
Visitor

Re: How to get instant updates to Roku?

I'm gonna mess around with what you gave me, so far it's just giving me a black screen, but I probably missed something.

Also, yes, my goal is to use that as a placeholder. I'd all the xml to be dynamic, so it's good that I'm doing that for categories. The goal I have now is just to get the page running where it updates instantly with my files so I don't have to keep repackaging and uploading, instead I can just work with the xml feeds and stuff and see instant changes.
0 Kudos
SoutheastTv
Visitor

Re: How to get instant updates to Roku?

Here is what I have now:

categoryFeed.brs
Function InitCategoryFeedConnection() As Object
conn = CreateObject("roAssociativeArray")

conn.UrlPrefix = "http://scclib.com/demo/roku"
conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.php?ts=" + dt.AsSeconds().ToStr()

conn.Timer = CreateObject("roTimespan")

conn.LoadCategoryFeed = load_category_feed
conn.GetCategoryNames = get_category_names

print "created feed connection for " + conn.UrlCategoryFeed
return conn
End Function


categories.php
<?php
// Send the headers
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');

//Store the current time in seconds into variable $now:
$now = time();

echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
echo '<xml>';
echo ' <categories>';
echo ' <category title="Awesomeness" description="Here it iskhj"';
echo ' sd_img="http://scclib.com/demo/roku/images/test_sd_poster.jpg"';
echo ' hd_img="http://scclib.com/demo/roku/images/test_hd_poster.jpg">';

//Append a timestamp to the category feed:
echo ' <categoryLeaf title="Awesomeness" description="" feed="http://scclib.com/demo/roku/xml/xmlfeed.php?ts=' . $now . '" />';

echo ' </category>';
echo ' </categories>';
echo '</xml>';
?>


xmlfeed.php
<?php
echo file_get_contents('awesomeness.xml');
?>


The result is that when I try clicking the channel in my Home area, nothing happens. When I view channel by finding it in "My Channels" then it comes up with a blank black screen.
0 Kudos
RokuMarkn
Visitor

Re: How to get instant updates to Roku?

What do you see on the debug console?

--Mark
0 Kudos
SoutheastTv
Visitor

Re: How to get instant updates to Roku?

How do I get to a debug console?
0 Kudos