SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-11-2005, 12:08 AM
davin's Avatar
davin davin is offline
Sage Advanced User
 
Join Date: Jan 2005
Location: El Segundo, CA
Posts: 138
Custom hooks for events from Java?

Another Java question... I have a feeling that this isn't possible right now, but I'll go ahead and ask!

I want to be able to pass information from Java code to Studio without Studio asking for it. Basically, I would like to be able to set up a call from Java that could trigger a custom hook inside studio.

For example, the Java code is running along doing it's own thing... and so is Sage. The java code suddenly sends a message to Sage and Sage detects it, stops what it's doing, and goes to a specified widget chain.

Is there any way of doing this?

Thanks!
Reply With Quote
  #2  
Old 11-11-2005, 12:27 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
The info below is from an old email I received from Jeff. It sounds like what you are looking for. Or else Jeff can update it later.

BTW: you could place such Studio code some place where it would never normally get executed, such as under a Menu widget that never gets called and/or under an 'if false' conditional widget.

- Andy
-----------------------

Your own hooks can be created by just using Actions. So let's say you want to make your own 'hook' called "MessageNotification()". Just make an Action with the name "MessageNotification()" (put it in quotes so it doesn't try to execute it). Then when you want that hook called, execute this from Java:

Code:
Object[] actWidgets = (Object[])sage.SageTV.api("GetWidgetsByType", new Object[]{"Action"});
for (int i = 0; i < actWidgets.length; i++)
{
  if ("\"MessageNotification()\"".equals( sage.SageTV.api("GetWidgetName", new Object[]{actWidgets[i]}))
  {
    sage.SageTV.api("ExecuteWidgetChain",new Object[]{actWidgets[i]});
    break;
  }
}
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.

Last edited by Opus4; 11-12-2005 at 12:45 AM. Reason: fixed API function name
Reply With Quote
  #3  
Old 11-11-2005, 01:08 AM
davin's Avatar
davin davin is offline
Sage Advanced User
 
Join Date: Jan 2005
Location: El Segundo, CA
Posts: 138
Ah!!! Calling a widget chain with a api call from Java. That should do it. I should have known to look in the Sage API docs. The curse of an early adopter.
Reply With Quote
  #4  
Old 11-11-2005, 02:11 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
Or... a blocking call to your java class eg 'GetNextEvent()', which is called in a Fork()'ed action tree. When the call is returned, the forked action tree resumes and can handle the event...

(used in my info popup -- java java.net.ServerSocket.accept() is called in a forked action tree, and when it returns, the rest of the action tree is handled, causing the infopopup window to be popped up.)
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #5  
Old 11-11-2005, 05:19 AM
salsbst's Avatar
salsbst salsbst is offline
SageTVaholic
 
Join Date: Jun 2003
Posts: 2,592
Quote:
Originally Posted by nielm
Or... a blocking call to your java class eg 'GetNextEvent()', which is called in a Fork()'ed action tree. When the call is returned, the forked action tree resumes and can handle the event...

(used in my info popup -- java java.net.ServerSocket.accept() is called in a forked action tree, and when it returns, the rest of the action tree is handled, causing the infopopup window to be popped up.)
I like this a lot better than looping over every action in the STV!
Reply With Quote
  #6  
Old 11-12-2005, 12:42 AM
davin's Avatar
davin davin is offline
Sage Advanced User
 
Join Date: Jan 2005
Location: El Segundo, CA
Posts: 138
I tried out the code that Opus posted and it works, with one exception. The first API call should be to "GetWidgetsByType", not "GetAllWidgetsByType". Other than that, it works fine.

I will look into the fork() method once I get everything working as I want... I agree that it's the better method.

Thanks again...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 12:58 PM.


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