Transitioning Screensaver to Externally-Pulled Images
Howdy developers! I'm excited to get some feedback on my (hopefully) simple issue. I've built a few screensavers based on the originally-posted code from a couple of years ago (https://github.com/rokudev/samples/tree/master/screen%20savers), but would like to transition to pulling my images from my server instead of having to mash them into the package.
I need to place code in there which goes out and pulls the external content, but am struggling with where this code would go (which BRS file?).
The note that I got from the support folks was that it may need to be a "task node," but I'm still not understanding the concept they're trying to put across after watching the videos and reading their help content.
I believe I've coded this correctly, but just need to know which file to place it in, and how to call it...
Here is the code that I've put together, into source/main.brs (below). You will see that I've created a sub called "getPhotoRoninContent" and am calling it.
I'm not sure this is correct 🙂
Function RunScreenSaver(params As Object) As Object 'Required entry point for screensavers getPhotoRoninContent() Main() End Function sub Main() screen = createObject("roSGScreen") port = createObject("roMessagePort") port2 = createObject("roMessagePort") screen.setMessagePort(port) m.global = screen.getGlobalNode() 'Creates (Global) variable MyField m.global.AddField("MyField", "int", true) m.global.MyField = 0 m.global.AddField("PicSwap", "int", true) 'Creates (Global) variable PicSwap m.global.PicSwap = 0 scene = screen.createScene("ScreensaverFade") 'Creates scene ScreensaverFade screen.show() while(true) 'Message Port that fires every 16 seconds to change value of MyField if the screen isn't closed msg = wait(16000, port) if (msg <> invalid) msgType = type(msg) if msgType = "roSGScreenEvent" if msg.isScreenClosed() then return end if else m.global.MyField += 10 msg = wait(2500, port2) 'Message port that fires 4 seconds after MyField is changed. Must be set to different port than other wait function or it will interfere. m.global.PicSwap += 10 end if end while end sub sub getPhotoRoninContent() fs=createobject("rofilesystem") xfer=createobject("roUrlTransfer") xfer.SetCertificatesFile("common:/certs/ca-bundle.crt") if not fs.exists("cachefs:/photoroninpic-01.jpg") then xfer.seturl("https://photos.smugmug.com/photos/i-DZ3RNCh/0/c6888ff8/X3/i-DZ3RNCh-X3.jpg") xfer.gettofile("cachefs:/photoroninpic-01.jpg") end if end sub
I've already had this redeveloped, and have launched the updated channels a while back. Thanks!