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

Simple Quesiton on URLs

I am trying to learn Roku channel development. I took the "videoplayer" example and was going to experiment with the category feeds. I discovered that the category files were present in the application's tree as well as online, and I changed the line:

    conn.UrlPrefix   = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml"


to

    conn.UrlPrefix   = "file://pkg:/xml"


to pull the local copy of the file instead of hitting the web server at rokudev.roku.com. The only other change i made was to add a debugging line after the "Can't parse feed" so I could see the results of the fetch of the URL:

    if not xml.Parse(rsp) then
print "Can't parse feed"
print "'" + rsp + "'"
return invalid
endif


It looks like the HTTP fetch returns nothing:

created feed connection for file://pkg:/xml/categories.xml
url: file:///tmp/plugin/FDAAAA1tnmYw/pkg:/xml/categories.xml
Took: 5ms
Can't parse feed
''


Any clues on what I'm doing wrong?
0 Kudos
8 REPLIES 8
RokuChris
Roku Employee
Roku Employee

Re: Simple Quesiton on URLs

Two things. First, the path should look more like this:

conn.UrlPrefix   = "pkg:/xml"


Also, you can't read a local file using roURLTransfer. You'll need to use ReadASCIIFile() as documented on p34 of the BrightScript Reference Manual.
0 Kudos
MikeL1
Visitor

Re: Simple Quesiton on URLs

Thanks for the quick response. Added the following line after
    xml=CreateObject("roXMLElement")
rsp = ReadAsciiFile("pkg:/xml/categories.xml")
if not xml.Parse(rsp)
'...

No joy in mudville. The app doesn't seem to run at all - connecting to the debug port 8085 yields nothing.
0 Kudos
kbenson
Visitor

Re: Simple Quesiton on URLs

"MikeL1" wrote:

No joy in mudville. The app doesn't seem to run at all - connecting to the debug port 8085 yields nothing.


At a minimum is should state it's running the code, and it should give you an error message and the debugging console if there's an error. Sometimes it seems the debugging port can get stuck for me (if, for example, I let the computer go to sleep and time out the telnet connection), and I need to reset the Roku.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
MikeL1
Visitor

Re: Simple Quesiton on URLs

Thanks, will try rebooting.
0 Kudos
MikeL1
Visitor

Re: Simple Quesiton on URLs

Post-reboot I actually get it to install and get debugging output but it's not reading the file:
    xml=CreateObject("roXMLElement")
rsp = ReadAsciiFile("pkg:/xml/categories.xml")
if not xml.Parse(rsp)
print "Can't parse feed"
print "Rsp = '" + rsp + "'"
return invalid
endif

gives me the following:
Can't parse feed
Rsp = ''
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Simple Quesiton on URLs

If you're using included makefile to package and install the sample channel, the xml directory will be excluded from the package, which could cause the problem you're seeing.
0 Kudos
MikeL1
Visitor

Re: Simple Quesiton on URLs

Doh! Should have done more checking, but I'm new to this. That did the trick. Hopefully I wont' be pestering you all anymore (at least not for a while).

Thank you!
0 Kudos
MikeL1
Visitor

Re: Simple Quesiton on URLs

"RokuChris" wrote:
Also, you can't read a local file using roURLTransfer. You'll need to use ReadASCIIFile() as documented on p34 of the BrightScript Reference Manual.


FYI you can read a local file using roURLTransfer just as with a web browser, the URL syntax is "file://pkg:/xml/categories.xml".
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.