SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Studio (http://forums.sagetv.com/forums/forumdisplay.php?f=34)
-   -   Using the default STV in Custom STV Mode from custom STVs (v6.4 & later) (http://forums.sagetv.com/forums/showthread.php?t=32921)

Opus4 05-21-2008 10:53 PM

Using the default STV in Custom STV Mode from custom STVs (v6.4 & later)
 
1 Attachment(s)
Version 6.4 of the default STV has a Custom STV Mode that custom STVs can use for configuration options, such as setting up recording sources, or for use of any other menu in the default STV. This makes sure that users are always using the most up to date setup code and the custom STV authors do not need to worry about that code at all.

I believe SageMC does something like that already, but it provides a customized version of the default STV which could get out of date since the default STV's setup code gets modified often.

To use the default STV in Custom STV Mode, a custom STV would set these global variables:

Code:

AddGlobalContext("gCurCustomSTVFilePath", GetCurrentSTVFile())

 Optional variable to reload the custom STV w/o confirmation,
 set to true or false, default false:
AddGlobalContext("gReloadCustomSTVWithoutConfirm", true)

 Optional variable to set name of menu to jump to, default null:
AddGlobalContext("gTargetMenuName", "<name of menu widget>")

 Optional variable to use the Home command to return to the custom STV,
 set to true or false, default false:
AddGlobalContext("gReloadCustomSTVOnHome", true)

 Optional variables used to call a custom init method - set gCustomSTVInit
 to the name of the method to call and gCustomSTVInitParams are the
 parameters:
AddGlobalContext("gCustomSTVInit", <name of method to call> )
AddGlobalContext("gCustomSTVInitParams", <parameters> )

 Use the GetDefaultSTVFile() API call to load the default STV:
LoadSTVFile(GetDefaultSTVFile())

 Optional variable to reload the custom STV after entering
 the playback menu, set to true or false, default false:
AddGlobalContext("gReloadCustomSTVOnPlayback", true)

Then, it would just load the default STV via the LoadSTVFile() API call. The default STV will initially jump directly to the Setup Menu, where the user can then use any configuration options. Once done using setup, the user can choose the "Exit Setup Mode" button at the bottom of the Setup Menu or Main Menu to return to the custom STV file that was defined in the code shown above.

If gReloadCustomSTVWithoutConfirm has been set to true, then the custom STV is reloaded w/o asking the user to confirm that step.

If gTargetMenuName has been set, then the default STV will attempt to jump directly to the menu widget with the specified name. If the name doesn't exist, then the Main Menu will be used. If this variable is null, the Setup Menu will be loaded.

If gReloadCustomSTVOnHome has been set to true, then the default STV will reload the custom STV when the Home command is used. Use the gReloadCustomSTVWithoutConfirm variable to control whether the action is confirmed or not.

If gReloadCustomSTVOnPlayback has been set to true, then the default STV will reload the custom STV after entering the playback menu.

If gCustomSTVInit has been set to the name of a method to call, then this function is called after the default STV has been loaded and its initial settings are configured -- it gets called as one of the last things to be done in the Main Menu's AfterMenuLoad hook, but before the jump to another menu. gCustomSTVInitParams is sent as the array of parameters. This is done via a call to:
sage_SageTV_apiUI( GetUIContextName(), gCustomSTVInit, gCustomSTVInitParams )

Code:

Custom Java code:
package CustomCode;

public class CustomInit {
  public static void initialize(String arg1, String arg2) throws InvocationTargetException {
        [...]
    }
}

Custom STV:
AddGlobalContext("gCustomSTVInit", "CustomCode_CustomInit_initialize" )
AddGlobalContext("gCustomSTVInitParams", CreateArray(param1,param2,...) )


Note: These global variables are cleared before reloading the custom STV. If the custom STV needs to do anything specific when it is reloaded, it should set its own custom global variables before loading the default STV.


I'm looking for comments from custom STV authors regarding anything else they think would be needed.

Nothing else jumps out at me and I don't think the default STV needs to look for or set any other global variables to talk to the custom STV, because the custom STV could set those before loading the default STV so it knows Custom STV Mode was just exited when it gets reloaded.

See the attached STV for sample code used to test jumping between the default & sample STV.

- Andy

dflachbart 05-21-2008 11:10 PM

Quote:

Originally Posted by Opus4 (Post 282897)
I'm looking for comments from custom STV authors regarding anything else they think would be needed.

:thumb::thumb::thumb:

One thing less to worry about. Awesome... :)


Dirk

Opus4 05-21-2008 11:17 PM

Quote:

Originally Posted by flachbar (Post 282899)
:thumb::thumb::thumb:

One thing less to worry about. Awesome... :)

I figured you would like that one. :D And, it was really easy to implement. :thumb:

Are you doing anything else in your customized default STV?

Have you run into usability issues that should be considered? ... it doesn't seem too difficult to me: when done, choose "Exit Setup Mode" and confirm. :)

- Andy

MeInMaui 05-21-2008 11:46 PM

One other feature is that 'Back' and 'Home' both return you to SageMC.

mightyt 05-21-2008 11:49 PM

Not an author, but this sounds awesome. If I am reading this right it will give us a way to keep the original STV "pure" and independent, not have to worry about SageTV3-2, then 3-3, 3-4, etc. Is this true?

GKusnick 05-22-2008 09:56 AM

I've been doing something like this in my own (unreleased) custom STV for some time. In my case I use more than just the Setup menu; I also have menu items that jump into the stock Video Browser and Music Browser screens (since I didn't feel like duplicating that functionality in my STV).

Basically what my code does is this:

1. Remember the name of the currently loaded STV.
2. Load the target STV.
3. Set the STV property in the properties file to the calling STV (so if the user quits and restarts Sage, that's the one that will be loaded).
4. Search for the Standby item on the Main Menu in the target STV.
5. Replace it with a "Return to caller" menu item that reloads the original STV.
6. Jump to the target menu by name.

The interesting thing is that steps 3-6 continue to execute even after the target STV has been loaded, even though the code for those steps is defined in the STV that has just been unloaded. I guess we have Java garbage collection to thank for that.

Opus4 05-22-2008 10:27 AM

Quote:

Originally Posted by MeInMaui (Post 282903)
One other feature is that 'Back' and 'Home' both return you to SageMC.

I don't think I want to do that because I didn't want to limit UI navigation too much -- the user would be free to check out settings on other menus & so on and still easily switch back to the custom STV from the Main Menu or Setup Menu.

Quote:

Originally Posted by mightyt (Post 282904)
Not an author, but this sounds awesome. If I am reading this right it will give us a way to keep the original STV "pure" and independent, not have to worry about SageTV3-2, then 3-3, 3-4, etc. Is this true?

This is different. The default STV already doesn't get modified when you import a customization; that's why there are those -# STV versions created. What I'm talking about has to do with replacement custom STVs needing access to up-to-date configuration options, not the modified-by-imports default STVs, because the modified ones still have the setup code from the default STV.

Quote:

Originally Posted by GKusnick (Post 282962)
I've been doing something like this in my own (unreleased) custom STV for some time. ...

3. Set the STV property in the properties file to the calling STV (so if the user quits and restarts Sage, that's the one that will be loaded).

That's an interesting one that I hadn't thought of. :) I think I'll add that. There's already an option to exit setup mode and NOT return to the calling STV, so if the user selects that option, I can simply reset the STV property back to the default STV.

- Andy

Opus4 05-22-2008 11:49 AM

Quote:

Originally Posted by GKusnick (Post 282962)
The interesting thing is that steps 3-6 continue to execute even after the target STV has been loaded, even though the code for those steps is defined in the STV that has just been unloaded. I guess we have Java garbage collection to thank for that.

BTW: it is sort of garbage collection related -- the code is released when no more active threads reference those widgets any more.

The same thing applies to any forked threads -- they will continue until they hit an exit point... I think I have one to double check for stopping itself when the STV changes. :)

- Andy

Opus4 05-22-2008 12:27 PM

Quote:

Originally Posted by GKusnick (Post 282962)
3. Set the STV property in the properties file to the calling STV (so if the user quits and restarts Sage, that's the one that will be loaded).

5. Replace it with a "Return to caller" menu item that reloads the original STV.

Updates:

I've now set the STV property as you mentioned.

I also added a check for an optional variable named "gExitSetupWithoutConfirm", which will change the exit button so that when selected, the user immediately returns to the custom STV instead of being asked whether to return. (First post has been modified.)

- Andy

GKusnick 05-22-2008 01:04 PM

Will there be a way to jump directly to menus other than Setup? So instead of a boolean gInSetupMode, you might have a string-valued gTargetMenuName that determines which menu to jump to.

Opus4 05-22-2008 02:23 PM

Quote:

Originally Posted by GKusnick (Post 282991)
Will there be a way to jump directly to menus other than Setup? So instead of a boolean gInSetupMode, you might have a string-valued gTargetMenuName that determines which menu to jump to.

Sure... the first post has been updated again. :)

The gInSetupMode variable has been removed; it wasn't really needed in the first place.

I changed gExitSetupWithoutConfirm to gReloadCustomSTVWithoutConfirm.

And, gTargetMenuName was added. As the first post says: "If gTargetMenuName has been set, then the default STV will attempt to jump directly to the menu widget with the specified name. If the name doesn't exist, then the Main Menu will be used. If this variable is null, the Setup Menu will be loaded." I decided that selecting a random menu if the specified menu name doesn't exist just wasn't a good way to handle it. :p

So, for setup mode, you only need to set the gCurCustomSTVFilePath variable & the other 2 are optional.

I should call it something other than "Setup Mode" now... ;)

- Andy

MeInMaui 05-22-2008 03:14 PM

:clap:

Very nice indeed.

When new menus (like online services) are added to the default STV, this could be a great way for users of custom STV's to link to those screens and immediately gain the new functionality.

How would a user return to a custom STV from any given (linked) screen?

In a related (admittedly hair brained) thought, would there be any way to preserve the menu history of the calling STV when linking to a menu in the default STV? The idea is when 'back' is hit within the default STV taking you back to the point where it was originally called (i.e when the menu history in the default STV is exhausted), it would reload the calling custom STV and its menu history. This could make the transition between STV's seamless in both directions.

Aloha,
Mike

Opus4 05-22-2008 05:56 PM

Somehow, I'm not even subscribed to my own thread...

Quote:

Originally Posted by MeInMaui (Post 283025)
How would a user return to a custom STV from any given (linked) screen?

I'm probably going to revisit my previous comment about not using Home for that purpose. I like options, so maybe I should add an option to have Home return to the custom STV (that setting may depend on how much the user is expected to do in the default STV). Between the optional-Home and optional-Comfirm settings, that should allow you to set it up any way you want.

Quote:

In a related (admittedly hair brained) thought, would there be any way to preserve the menu history of the calling STV when linking to a menu in the default STV? The idea is when 'back' is hit within the default STV taking you back to the point where it was originally called (i.e when the menu history in the default STV is exhausted), it would reload the calling custom STV and its menu history. This could make the transition between STV's seamless in both directions.
Menu history is cleared when a new STV is loaded & I've never tried & even if you kept a list of the menu widgets that were in the history, it wouldn't have the cached version of the menu... at least that's the way I look at it.

To return to the original menu in the custom STV, it could set its own variable to track that & then when it gets reloaded, it could jump to that menu when the variable is set.

- Andy

MeInMaui 05-22-2008 06:18 PM

Quote:

Originally Posted by Opus4 (Post 283050)
I'm probably going to revisit my previous comment about not using Home for that purpose. I like options, so maybe I should add an option to have Home return to the custom STV (that setting may depend on how much the user is expected to do in the default STV). Between the optional-Home and optional-Comfirm settings, that should allow you to set it up any way you want.

Sounds good to me.

Quote:

Menu history is cleared when a new STV is loaded & I've never tried & even if you kept a list of the menu widgets that were in the history, it wouldn't have the cached version of the menu... at least that's the way I look at it.
Doh! I totally forgot about that. :bang:

Quote:

To return to the original menu in the custom STV, it could set its own variable to track that & then when it gets reloaded, it could jump to that menu when the variable is set.
That makes much more sense. :)

Thanks!

Aloha,
Mike

Opus4 05-22-2008 09:48 PM

I have Home optionally returning to the custom STV with or w/o confirmation.

I was going to use Back to return to the custom STV when the Back history limit was reached, but there are only so many menus stored in the history. The user could go to more menus than the history can hold & then use Back enough times to hit the history limit w/o reaching the menu where everything started. I don't think I'm going to add that one unless you are really sure you want to have Back return to the custom STV.

- Andy

Opus4 05-22-2008 11:42 PM

I have updated the first post of this thread with the latest global variable info and a simple sample STV used to test this feature.

You can update your current default STV for this & other new features by testing the STV updating feature described here:
STV Update Tests for beta v6.4.3

Let me know how it goes. :)

- Andy

jusjoken 05-24-2008 01:23 PM

How would Themes work in the case where a Custom STV branches out to the default STV? I assume that while in the default STV function, the default STV last selected Theme would be used? Would there be any way for the Custom STV to handle this so the Custom STV could control the Themed elements from the default STV function it is calling (to try and keey a consistent look/feel for the user)?

I hope this question makes sense :confused:

Opus4 05-24-2008 02:46 PM

The default STV will use whatever theme it has been set to use. If the custom STV author wants the default UI to look similar, then there needs to be an appropriate theme that the default STV can load & it needs to be set to use that theme.

- Andy

Opus4 06-13-2008 10:55 PM

Note that v6.4.4 has a new API call: GetDefaultSTVFile(). You can use this new call to easily load the default STV w/o needing to worry about whether the file name or path for the default STV ever changes:

LoadSTVFile(GetDefaultSTVFile())

The example STV in the first post has been updated.

- Andy

Opus4 07-09-2008 11:17 PM

Based on a request from flachbar, the next version of the default STV will use new global variables gCustomSTVInit and gCustomSTVInitParams to allow calling a custom init method.

Added to the first post, above:
Code:

Optional variables used to call a custom init method - set gCustomSTVInit
 to the name of the method to call and gCustomSTVInitParams are the
 parameters:
AddGlobalContext("gCustomSTVInit", <name of method to call> )
AddGlobalContext("gCustomSTVInitParams", <parameters> )

If gCustomSTVInit has been set to the name of a method to call, then this function is called after the default STV has been loaded and its initial settings are configured -- it gets called as one of the last things to be done in the Main Menu's AfterMenuLoad hook, but before the jump to another menu. gCustomSTVInitParams is sent as the array of parameters. This is done via a call to:
sage_SageTV_apiUI( GetUIContextName(), gCustomSTVInit, gCustomSTVInitParams )

Code:

Custom Java code:
package CustomCode;

public class CustomInit {
  public static void initialize(String arg1, String arg2) throws InvocationTargetException {
        [...]
    }
}

Custom STV:
AddGlobalContext("gCustomSTVInit", "CustomCode_CustomInit_initialize" )
AddGlobalContext("gCustomSTVInitParams", CreateArray(param1,param2,...) )


Any comments/requests about this from other developers?

- Andy

Opus4 07-15-2008 12:19 AM

Note: as of the v6.4.5.3 STV Update, the info in the previous post was changed so that gCustomSTVInitParams is sent as it is received instead of being turned into another array. The Java function now would take a series of typed parameters instead of a single array.

- Andy

mickp 07-19-2008 07:21 AM

I'd realy like to be able to put a link in my mc menu to the "Detailed Setup", "Video / Audio", "Audio renderer" option/dialog from the default stv which would return to SageMC once the selection is made or backed out of. Does this new feature allow for an easy way to do this or would it be better to try to hack this setting dialog into sagemc?

Mick.

Opus4 07-19-2008 09:52 AM

Quote:

Originally Posted by mickp (Post 293765)
I'd realy like to be able to put a link in my mc menu to the "Detailed Setup", "Video / Audio", "Audio renderer" option/dialog from the default stv which would return to SageMC once the selection is made or backed out of. Does this new feature allow for an easy way to do this or would it be better to try to hack this setting dialog into sagemc?

This system doesn't allow jumping to a specific dialog, but it could jump directly to the Detailed Settings menu, where you could choose that setting.

- Andy

GKusnick 02-03-2009 08:54 PM

Obviously I'm a bit late with this suggestion for 6.5, but at some point you might want to add the capability to jump to a stock menu by widget symbol (e.g. "BASE-44367") instead of by widget name (e.g. "Setup Menu"). Presumably this is exactly the kind of widget-addressing problem that symbols are meant to solve.

Perhaps the simplest approach is to first look up FindWidgetBySymbol(gTargetMenuName). If that fails, then do what you do now to look it up by widget name. That way it's backward-compatible with existing code, but allows new code to use the speedier and more future-proof symbol lookup.

Opus4 02-03-2009 10:05 PM

Thanks for the suggestion Greg. That obviously never occurred to me & it would certainly help find the correct widget. I've added it to my to-do list.

- Andy

Opus4 02-09-2009 03:27 PM

Update: I've implemented the quoted suggestion, so you'll be able to test it in the next update... whenever that happens to be. :)

Oh, and if the symbol is not for a menu widget, it will skip it.

Quote:

Originally Posted by GKusnick (Post 335519)
Perhaps the simplest approach is to first look up FindWidgetBySymbol(gTargetMenuName). If that fails, then do what you do now to look it up by widget name. That way it's backward-compatible with existing code, but allows new code to use the speedier and more future-proof symbol lookup.

- Andy

GKusnick 02-10-2009 01:23 PM

Great, thanks!

Crashless 06-20-2009 05:48 PM

1 Attachment(s)
I'm trying this out, and I'm able to successfully load the default STV, but it goes to the main menu of the Default STV.

Then upon return, it's failing to go back to the specified menu. I feel like I'm missing something obvious. :(

Thoughts? Code attached.

razrsharpe 06-20-2009 06:50 PM

Quote:

Originally Posted by Crashless (Post 365100)
I'm trying this out, and I'm able to successfully load the default STV, but it goes to the main menu of the Default STV.

Then upon return, it's failing to go back to the specified menu. I feel like I'm missing something obvious. :(

Thoughts? Code attached.

take a look at the sagemc code. It does exactly what you are trying to do and you should be able to copy it :)

I just did this a couple days ago to link to the system messages window before mike was able to patch sagemc and was able to get it working pretty easily

GKusnick 06-20-2009 07:47 PM

Quote:

Originally Posted by Crashless (Post 365100)
I'm trying this out, and I'm able to successfully load the default STV, but it goes to the main menu of the Default STV.

Then upon return, it's failing to go back to the specified menu. I feel like I'm missing something obvious.

gTargetMenuName specifies the name of the menu in the stock STV that you want to jump to. You've specified "Settings", but there is no stock menu by that name, so it goes to the stock Main Menu.

On return to your custom STV, it will load your Main Menu. If you want to jump to some other menu in your STV on reload, it's up to you to put code in your Main Menu's BeforeMenuLoad hook to accomplish that.

Crashless 06-20-2009 11:19 PM

Quote:

Originally Posted by GKusnick (Post 365111)
gTargetMenuName specifies the name of the menu in the stock STV that you want to jump to. You've specified "Settings", but there is no stock menu by that name, so it goes to the stock Main Menu.

On return to your custom STV, it will load your Main Menu. If you want to jump to some other menu in your STV on reload, it's up to you to put code in your Main Menu's BeforeMenuLoad hook to accomplish that.

Doh! Mis-read how that variable worked. I thought it meant it would RETURN to that screen after finishing - not GO TO that screen in the default STV.

I really should have stepped through the SageMC code one more step before messing with it on my own. I saw the "Default STV Menu" reference and my memory flashed to this thread, thinking "SageMC hasn't been updated" and I went trodding off the cliff.

Ah well - thanks for the pointers - the world makes sense again. :)

GKusnick 10-17-2009 09:23 PM

I have another wish for this mechanism. Suppose I want to use the stock STV for video browsing, but then revert to my custom STV for media playback. It would be handy to have a gReloadCustomSTVOnPlayback variable that I could set so that the next time the MediaPlayer OSD menu is loaded, it returns to the custom STV instead. (Obviously it's then up to me to dispatch to my own MediaPlayer menu as needed on reload.)

This should amount to no more than a couple of widgets in the OSD menu's AfterMenuLoad hook. (As an experiment I tried doing it in BeforeMenuLoad, but apparently that's not a good time to call LoadSTVFile(). It did load the new STV, but the menu that got displayed was the old STV's OSD menu instead of the new STV's Main Menu.)

Thanks.

Opus4 10-22-2009 01:41 PM

Quote:

Originally Posted by GKusnick (Post 387113)
It would be handy to have a gReloadCustomSTVOnPlayback variable that I could set so that the next time the MediaPlayer OSD menu is loaded, it returns to the custom STV instead.

The STV v6.6.2.19 (2009102001) update includes this request, so this is now part of the instructions in the first post of this thread:


If gReloadCustomSTVOnPlayback has been set to true, then the default STV will reload the custom STV after entering the playback menu.

This note was also added to the first post:

Note: These global variables are cleared before reloading the custom STV. If the custom STV needs to do anything specific when it is reloaded, it should set its own custom global variables before loading the default STV.

- Andy

GKusnick 10-22-2009 01:49 PM

Thanks, Andy.

bialio 12-03-2010 12:57 PM

Is all of this in place and unchanged in V7?

GKusnick 12-03-2010 01:12 PM

Quote:

Originally Posted by bialio (Post 467312)
Is all of this in place and unchanged in V7?

As I recall there have been a few bug fixes and tweaks to the rules by which it decides when to return to the custom STV v. the stock Main Menu. But yes, this machinery is still present and functional (if not exactly "unchanged").

bialio 12-07-2010 01:06 PM

Hey Opus,

In V7 I've set up two entry points for the default UI from our Phoenix STV - one going to Detailed Setup, the other to Configure Video Sources

"Detailed Setup" and
"Setup Wizard - Summary Page" respectively

When navigating away from these pages (using left key) they both end up back at the V7 Main Menu.

Other links that I've set up, like to Music / Pictures / Online areas of the default STV, behave differently on LEFT event - they reload Phoenix.

I am supposing that in one case it's 'BACK' and others it's a hard coded link to 'Main Menu', athough I haven't dug through the default STV code to verify this.

Is this something I'll need an STVi (ie UI Mod) for the default UI in order to get the Detailed Menu and Video Sources to reload the custom STV on Left instead of going to the V7 Main Menu?

btl.

Opus4 12-07-2010 01:52 PM

I think "Detailed Setup" & "Online Services Menu" should function the same, as far as using the Left arrow. Submenus in the online services area use Back, so maybe that's what you are using.

Returning to the custom STV when Back is used & there are no more menus to back to is fairly new.

The custom STV support has been convoluted enough for a while now that I'm not sure why Left on those menus is jumping directly to the Main Menu vs. using Home to do so. Maybe it was to allow getting to the Main Menu _somehow_, because using Home or the Main Menu button in Detailed Setup would probably return to the cusotm STV if you've got that option enabled.


Greg: Are you using this Left vs. Home difference on Detailed Setup/etc, or was this an oversight on my part? I don't want to assume I made a mistake & change something only to find I need to change it back. :)

- Andy

GKusnick 12-07-2010 02:22 PM

Quote:

Originally Posted by Opus4 (Post 468245)
Greg: Are you using this Left vs. Home difference on Detailed Setup/etc, or was this an oversight on my part? I don't want to assume I made a mistake & change something only to find I need to change it back.

I can confirm that Detailed Setup and Online Services behave differently than other screens in that Left arrow returns to the stock Main Menu instead of the custom STV. But I don't depend on that difference, so if you want to change them to be more consistent, I don't have a problem with that.

My main concern, which I believe we resolved back in September, was that if I jump from a custom STV to the stock Main Menu, and then navigate into a menu from there, then Left should take me back out to the stock Main Menu where I came from rather than jumping all the way back to the custom STV. This does seem to be working now as I expect it to, so no change is needed there.

Opus4 12-08-2010 06:12 AM

OK, then I will probably update the default STV to change the way it is jumping to the Main Menu in these cases. This will affect using Left on some menus such that it will issue the Home command, causing a return to the custom STV if you've set the option to return on use of Home. Currently it simply jumps directly to the Main Menu in some places.


BTW: The use of the Back command was one of the items changed in previous discussions with Greg. Now, if there is no more menu history, then using the Back command will return to the custom STV. Note that Left functions as Back only on some menus, so there can be a difference between using Left vs. Back. If you want to go to the previous menu, use Back. If you intend to go to the parent menu, use Left.

- Andy


All times are GMT -6. The time now is 08:39 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.