com.almilli.tivo.bananas.hd
Class HDApplication

java.lang.Object
  extended by com.tivo.hme.sdk.HmeObject
      extended by com.tivo.hme.sdk.Resource
          extended by com.tivo.hme.sdk.StreamResource
              extended by com.tivo.hme.sdk.Application
                  extended by com.tivo.hme.bananas.BApplication
                      extended by com.almilli.tivo.bananas.hd.HDApplication
All Implemented Interfaces:
com.tivo.hme.bananas.IBananas, com.tivo.hme.interfaces.IApplication, com.tivo.hme.sdk.IHmeEventHandler, com.tivo.hme.sdk.IHmeProtocol

public class HDApplication
extends com.tivo.hme.bananas.BApplication

The HDApplication class is a BApplication with support for changing resolutions to support HD displays. The default implementation of this class will attempt to change the resolution of the TiVo receiver to the preferred resolution of the application which is generally the highest resolution. Once the resolution has been initialized, it will call the initService() method where you can initialize your application's main display.

If you wish to override this default functionality you may extend the initApp(IContext) method to change the resolution as desired. To change the resolution, you would do something like the following:

        ResolutionInfo resInfo = getResolutionInfo();
        Resolution currentRes = resInfo.getCurrentResolution();
        desiredResolution = resInfo.getPreferredResolution();

        if (currentRes.equals(desiredResolution)) {
            if (!initialized) {
                initService();
                initialized = true;
            }
        } else {
            // switch the the preferred resolution
            setReceiverResolution(desiredResolution);
        }
 
After calling setReceiverResolution(Resolution), the receiver will send back a ResolutionInfo event to the handleEvent(HmeEvent) method which should be handled appropriately such as calling the initService() method to initialize the application's main display.

If you wish to add extra images to the CustomSkin, then you can call the BApplication.getSkin() method to access the CustomSkin object.

Since:
0.1
Author:
s2kdave

Nested Class Summary
 
Nested classes/interfaces inherited from class com.tivo.hme.sdk.Resource
com.tivo.hme.sdk.Resource.FontResource
 
Field Summary
static int CMD_RECEIVER_SET_RESOLUTION
           
protected  boolean initialized
           
 
Fields inherited from class com.tivo.hme.bananas.BApplication
FADE_ANIM, SLIDE_ANIM
 
Fields inherited from class com.tivo.hme.sdk.Resource
EVT_RSRC_STATUS, status
 
Fields inherited from interface com.tivo.hme.bananas.IBananas
A_ANCHOR_MASK, A_BOTTOM, A_CENTER, A_DELTA_MASK, A_LEFT, A_NEGATIVE_MASK, A_RIGHT, A_TOP, ARROW_NAMES, BAR_DEFAULT, BAR_HANG, BEVT_ACTION, BEVT_FOCUS, BEVT_SCREEN_ENTER, BEVT_SCREEN_EXIT, H_BAR, H_DOWN, H_KEYBOARD, H_LEFT, H_PAGEDOWN, H_PAGEUP, H_RIGHT, H_UP, H_VIS_FALSE, H_VIS_FOCUS, H_VIS_TRUE, TRANSITION_FADE, TRANSITION_LEFT, TRANSITION_NONE
 
Fields inherited from interface com.tivo.hme.sdk.IHmeProtocol
APP_ERROR_BAD_ARGUMENT, APP_ERROR_BAD_COMMAND, APP_ERROR_OTHER, APP_ERROR_OUT_OF_MEMORY, APP_ERROR_RSRC_NOT_FOUND, APP_ERROR_UNKNOWN, APP_ERROR_VIEW_NOT_FOUND, CMD_RECEIVER_ACKNOWLEDGE_IDLE, CMD_RECEIVER_TRANSITION, CMD_RESERVED, CMD_RSRC_ADD_ANIM, CMD_RSRC_ADD_COLOR, CMD_RSRC_ADD_FONT, CMD_RSRC_ADD_IMAGE, CMD_RSRC_ADD_SOUND, CMD_RSRC_ADD_STREAM, CMD_RSRC_ADD_TEXT, CMD_RSRC_ADD_TTF, CMD_RSRC_CLOSE, CMD_RSRC_REMOVE, CMD_RSRC_SEND_EVENT, CMD_RSRC_SET_ACTIVE, CMD_RSRC_SET_POSITION, CMD_RSRC_SET_SPEED, CMD_VIEW_ADD, CMD_VIEW_REMOVE, CMD_VIEW_SET_BOUNDS, CMD_VIEW_SET_PAINTING, CMD_VIEW_SET_RESOURCE, CMD_VIEW_SET_SCALE, CMD_VIEW_SET_TRANSLATION, CMD_VIEW_SET_TRANSPARENCY, CMD_VIEW_SET_VISIBLE, EVT_APP_INFO, EVT_DEVICE_INFO, EVT_FONT_INFO, EVT_IDLE, EVT_INIT_INFO, EVT_KEY, EVT_RESERVED, EVT_RSRC_INFO, FONT_BOLD, FONT_BOLDITALIC, FONT_ITALIC, FONT_METRICS_BASIC, FONT_METRICS_GLYPH, FONT_PLAIN, ID_ALERT_SOUND, ID_BONK_SOUND, ID_CLIENT, ID_CLIENT_PRE_0_38, ID_DEFAULT_TTF, ID_DESELECT_SOUND, ID_ERROR_SOUND, ID_LEFT_SOUND, ID_NULL, ID_PAGEDOWN_SOUND, ID_PAGEUP_SOUND, ID_RESERVED, ID_RIGHT_SOUND, ID_ROOT_STREAM, ID_ROOT_VIEW, ID_SELECT_SOUND, ID_SLOWDOWN1_SOUND, ID_SPEEDUP1_SOUND, ID_SPEEDUP2_SOUND, ID_SPEEDUP3_SOUND, ID_SYSTEM_TTF, ID_THUMBSDOWN_SOUND, ID_THUMBSUP_SOUND, ID_TIVO_SOUND, ID_UPDOWN_SOUND, KEY_ADVANCE, KEY_CHANNELDOWN, KEY_CHANNELUP, KEY_CLEAR, KEY_DISPLAY, KEY_DOWN, KEY_ENTER, KEY_FORWARD, KEY_INFO, KEY_LEFT, KEY_LIVETV, KEY_MUTE, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_OPT_ANGLE, KEY_OPT_ASPECT, KEY_OPT_DVD, KEY_OPT_EXIT, KEY_OPT_GUIDE, KEY_OPT_LIST, KEY_OPT_MENU, KEY_OPT_PIP, KEY_OPT_STOP, KEY_OPT_TOP_MENU, KEY_OPT_WINDOW, KEY_PAUSE, KEY_PLAY, KEY_PRESS, KEY_RECORD, KEY_RELEASE, KEY_REPEAT, KEY_REPLAY, KEY_REVERSE, KEY_RIGHT, KEY_SELECT, KEY_SLOW, KEY_THUMBSDOWN, KEY_THUMBSUP, KEY_TIVO, KEY_UNKNOWN, KEY_UP, KEY_VOLUMEDOWN, KEY_VOLUMEUP, LIMIT_CMD_NBYTES, LIMIT_EVENT_NBYTES, LIMIT_FONT_POINT_SIZE, LIMIT_IMAGE_HEIGHT, LIMIT_IMAGE_NBYTES, LIMIT_IMAGE_WIDTH, LIMIT_SOUND_NBYTES, LIMIT_TEXT_NBYTES, LIMIT_URL_NBYTES, LIMIT_VIEW_DEPTH, MAGIC, RSRC_ERROR_BAD_ARGUMENT, RSRC_ERROR_BAD_DATA, RSRC_ERROR_BAD_MAGIC, RSRC_ERROR_BAD_STATE, RSRC_ERROR_BAD_VERSION, RSRC_ERROR_CONNECT_FAILED, RSRC_ERROR_CONNECTION_LOST, RSRC_ERROR_CONNECTION_TIMEOUT, RSRC_ERROR_HOST_NOT_FOUND, RSRC_ERROR_INCOMPATIBLE, RSRC_ERROR_NOT_SUPPORTED, RSRC_ERROR_OTHER, RSRC_ERROR_UNKNOWN, RSRC_HALIGN_CENTER, RSRC_HALIGN_LEFT, RSRC_HALIGN_MASK, RSRC_HALIGN_RIGHT, RSRC_IMAGE_BESTFIT, RSRC_IMAGE_HFIT, RSRC_IMAGE_MASK, RSRC_IMAGE_VFIT, RSRC_STATUS_CLOSED, RSRC_STATUS_COMPLETE, RSRC_STATUS_CONNECTED, RSRC_STATUS_CONNECTING, RSRC_STATUS_ERROR, RSRC_STATUS_LOADING, RSRC_STATUS_PAUSED, RSRC_STATUS_PLAYING, RSRC_STATUS_READY, RSRC_STATUS_SEEKING, RSRC_STATUS_UNKNOWN, RSRC_TEXT_MASK, RSRC_TEXT_WRAP, RSRC_VALIGN_BOTTOM, RSRC_VALIGN_CENTER, RSRC_VALIGN_MASK, RSRC_VALIGN_TOP, SAFE_ACTION_H, SAFE_ACTION_V, SAFE_TITLE_H, SAFE_TITLE_V, TRANSITION_BACK, TRANSITION_FORWARD, TRANSITION_TELEPORT, VERSION, VERSION_0_38, VERSION_0_40, VERSION_MAJOR, VERSION_MINOR, VERSION_STRING
 
Constructor Summary
HDApplication()
           
 
Method Summary
 int getHeight()
          Gets the height of the application
 ResolutionInfo getResolutionInfo()
          Gets the current resolution information about the receiver that this application is running against.
 int getSafeActionHorizontal()
          Gets the safe action horizontal inset from the edge of the left/right edges.
 int getSafeActionVertical()
          Gets the safe action vertical inset from the edge of the top/bottom edges.
 int getSafeTitleHorizontal()
          Gets the safe title horizontal inset from the edge of the left/right edges.
 int getSafeTitleVertical()
          Gets the safe title vertical inset from the edge of the top/bottom edges.
 int getWidth()
          Gets the width of the application
 boolean handleChunk(java.io.InputStream in)
          Adds support for handling the resolution change events
 boolean handleEvent(com.tivo.hme.sdk.HmeEvent event)
          This event handler snoops on resolution changes and reinitializes the service when it sees one.
 void init(com.tivo.hme.interfaces.IContext context)
          Initializes the the HDApplication with the context.
protected  void initApp(com.tivo.hme.interfaces.IContext context)
          Provides the default functionality of changing to the preferred resolution.
protected  void initService()
          This method is called after the resolution has been initialized and is used for the extending class to set up the main application.
 void rootBoundsChanged(java.awt.Rectangle r)
          Gets called when the root bounds changes.
protected  void setContext(com.tivo.hme.interfaces.IContext context, int version)
          This will initialize the context by configuring the current resolution and application bounds.
 void setReceiverResolution(Resolution res)
          Sends a request to change the receiver's resolution.
 
Methods inherited from class com.tivo.hme.bananas.BApplication
dispatchEvent, dispatchKeyEvent, getAbove, getBelow, getCurrentScreen, getNormal, getSkin, getStackDepth, handleAction, play, playSoundForKey, pop, pop, push, push, setSkin
 
Methods inherited from class com.tivo.hme.sdk.Application
acknowledgeIdle, close, destroy, flush, getAppFactory, getContext, getFactory, getFocus, getResource, getResources, getRoot, getStream, handleActive, handleApplicationError, handleIdle, handlePing, isAChunk, isApplicationClosing, log, open, setFactory, setFocus, transitionBack, transitionForward
 
Methods inherited from class com.tivo.hme.sdk.StreamResource
getContentType, getSpeed, getStatus, getURI, isPaused, pause, play, setPosition, setSpeed, toString
 
Methods inherited from class com.tivo.hme.sdk.Resource
addHandler, dump, finalize, postEvent, remove, removeHandler, sendEvent, sendEvent, setActive
 
Methods inherited from class com.tivo.hme.sdk.HmeObject
createAnimation, createAnimation, createColor, createFont, createFont, createImage, createImage, createImage, createImage, createSound, createSound, createSound, createStream, createStream, createStream, createText, createTrueType, getApp, getID, handleKeyPress, handleKeyRelease, handleKeyRepeat, parseQuery, rsrcFlagsToString, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CMD_RECEIVER_SET_RESOLUTION

public static final int CMD_RECEIVER_SET_RESOLUTION
See Also:
Constant Field Values

initialized

protected boolean initialized
Constructor Detail

HDApplication

public HDApplication()
Method Detail

setContext

protected void setContext(com.tivo.hme.interfaces.IContext context,
                          int version)
This will initialize the context by configuring the current resolution and application bounds.

Overrides:
setContext in class com.tivo.hme.sdk.Application

init

public void init(com.tivo.hme.interfaces.IContext context)
          throws java.lang.Exception
Initializes the the HDApplication with the context. Do not override this method unless you know what you are doing. The resolution information may or may not be available by the time this method is called.

Overrides:
init in class com.tivo.hme.bananas.BApplication
Throws:
java.lang.Exception

handleChunk

public boolean handleChunk(java.io.InputStream in)
Adds support for handling the resolution change events

Specified by:
handleChunk in interface com.tivo.hme.interfaces.IApplication
Overrides:
handleChunk in class com.tivo.hme.sdk.Application
Parameters:
in - the input stream the read from
Returns:
true if the application should handle more

setReceiverResolution

public void setReceiverResolution(Resolution res)
Sends a request to change the receiver's resolution. This is an asynchronous call and may or may not change the resolution.

Parameters:
res - the requested resolution

getResolutionInfo

public ResolutionInfo getResolutionInfo()
Gets the current resolution information about the receiver that this application is running against.

Returns:
the TiVo receiver resolution information

getWidth

public int getWidth()
Gets the width of the application

Overrides:
getWidth in class com.tivo.hme.sdk.Application
Returns:
the application width

getHeight

public int getHeight()
Gets the height of the application

Overrides:
getHeight in class com.tivo.hme.sdk.Application
Returns:
the application height

getSafeActionHorizontal

public int getSafeActionHorizontal()
Gets the safe action horizontal inset from the edge of the left/right edges.

Returns:
the safe action horizontal inset

getSafeActionVertical

public int getSafeActionVertical()
Gets the safe action vertical inset from the edge of the top/bottom edges.

Returns:
the safe action vertical inset

getSafeTitleHorizontal

public int getSafeTitleHorizontal()
Gets the safe title horizontal inset from the edge of the left/right edges.

Returns:
the safe title horizontal inset

getSafeTitleVertical

public int getSafeTitleVertical()
Gets the safe title vertical inset from the edge of the top/bottom edges.

Returns:
the safe title vertical inset

rootBoundsChanged

public void rootBoundsChanged(java.awt.Rectangle r)
Gets called when the root bounds changes. This will change the bounds of the below, normal, and above view layers and then reinitialize the skin.

Parameters:
r - the new bounds of the root application

initApp

protected void initApp(com.tivo.hme.interfaces.IContext context)
                throws java.lang.Exception
Provides the default functionality of changing to the preferred resolution. If you want, you can override this method to change the functionality of what happens on initialization.

Parameters:
context - the context for the application
Throws:
java.lang.Exception

handleEvent

public boolean handleEvent(com.tivo.hme.sdk.HmeEvent event)
This event handler snoops on resolution changes and reinitializes the service when it sees one.

Overrides:
handleEvent in class com.tivo.hme.bananas.BApplication

initService

protected void initService()
This method is called after the resolution has been initialized and is used for the extending class to set up the main application.



Copyright © -2007 . All Rights Reserved.