|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Hook which gets called periodically ?
Is there a hook in SageTV which gets called periodically, e.g. every n minutes ? I need a way to execute code (check a status, and possibly perform an action) in regular intervals. I thougth about implementing the wait-loop in a separate java thread (started at server startup) which checks the status and performs the action by using the sage.SageTV.api interface, but if there was an appropriate hook in Sage I could use this one instead and don't have to mess with java at all ... Or could I implement this sleep-check-action thread by using "fork()" in Studio itself ? Any suggestions appreciated ...
Thanks, Dirk |
#2
|
||||
|
||||
The comskip background file processing code in my STV is done using Fork and Wait like you described. I added the code to BeforeMenuLoad of the Main Menu and use AddGlobalContext to set a variable which I check to insure the code is only started once.
Note: If SageTV is just running as a service, the service doesn't use an STV file so this type of background process won't run unless the client/gui is running. |
#3
|
|||
|
|||
Thanks malore !
The Fork() method works well, much easier than dealing with external java code. At first I couldnt figure out how to get the flag initialized only once - I added the AddGobalContext("flag", false) to the hook, but soon discovered that this got called every time I revisited the menu. Then I found a note in the manual that Studio will return null if a variable is accessed which has not been defined yet, so I changed it to -if (flag == null) -AddGobalContext("flag", false) and then it worked . Please correct me if there is a better approach. Studio is awesome, I am slowly but steadily getting the hang of it. Currently I face two other problems: 1) my code implements a sleep timer and basically consists of an option menu which I successfully linked to the setup menu by adding it to the "customize" menu tree in Studio. As a next step I tried to move this code to a top level menu page so that I can link to it via nielm's dynamic menus. I finally got it working, but only with a hitch: in my first version (hooked directly into the setup menu) it was sufficient to call '"CloseOptionsMenu()" to close the menu, but in the second one (linked to a dynamic menus) the options menu doesn't close any more. I had to add an explicit SageCommand("Home") to get it to close. Am I doing something wrong ? The structure is Code:
- Menu - AfterMenuLoad - OptionMenu - Option1 - ... - Option2 - ... - OptionN - CloseOptionsMenu() - SageCommand("Home") <-- without it it does not work Thanks again for any help, Dirk |
#4
|
||||
|
||||
have a look at my Exit Sage plugin to see how to handle poping up a popup from a dynamic menus menu...
You need a menu with a default theme (Album theme is good for this) so that the background is cleared, and you need a 'CloseOptionsMenu(); SageCommand("Back") (or "Home")' whenever the options menu is closed to go back to the dynamic menus -- this includes adding a listener for the Options command otherwise you can be left with a blank screen!... I also have seen a hang on import once -- (or rather an endless loop) -- the delete widget tree code is apparantly not brilliant at handling loops, so if you are deleting some existing widgets (such as deleting an old version of your import), you may want to try not doing that for the moment! BTW, one other way of making a periodic timer start only once is to add it to the ApplicationStarted hook -- which is called only once. But apparantly you have to be careful what you do there...
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#5
|
|||
|
|||
Quote:
Quote:
Quote:
Thanks for your help, Dirk |
#6
|
|||
|
|||
Quote:
Nielm, what is the difference between the two deletion action chains, and what is the second one supposed to do ? Anyway, thanks so much for this tool, without it it would have taken a novice like me an eternity to figure out how to generate a simple import Dirk |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|