mediaframe.mpeg1
Class MovieScreen

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--mediaframe.mpeg1.MovieScreen
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable

class MovieScreen
extends java.awt.Panel
implements java.lang.Runnable

The MovieScreen class represents a panel on which the movie is shown.


Field Summary
 boolean appletStarted
          True if the applet is started.
 java.awt.image.ColorModel colorModel
          The Color model for the movie picture.
 int currentBufferingPercent
          The current "buffering" percent.
(package private)  Element elem
          The Element object with the pixels of the current frame.
static int ENDED
          "Ended" state of the player.
static int ErrNum
          The code of last error.
static int ERROR
          "Error" state of the player.
private  java.awt.Font ERROR_FONT
          The font of the text to print errors.
private  java.awt.Graphics graphics
          The graphics context to paint the movie screen.
private  boolean java2_platform
          Flag, eguals true, if the current JRE is java2.
static int L_STOPPING
          "Stopped" after locking state of the player.
private  long lastPts
          Presentation timestamp for last frame (reqd when estimating).
static int LOCKED
          "Locked" state of the player.
 boolean movieDestroy
          True if the applet's destroy method has been called.
 int movieState
          The state of the player.
private  io_tool mpeg_stream
          The tool for accessing the mpeg bit stream.
static java.lang.String Msg
          The message text of last error.
private  long now
          The current playing time in milliseconds.
static int PAUSED
          "Paused" state of the player.
private static int[] picLags
          1/picrate, delay in milliseconds between frames.
 java.awt.Image Picture
          The movie picture.
static int PLAYED
          "Played" state of the player.
 boolean playing
          The current playing status.
 int post_screen_delay
          The delay in milliseconds between end images to show.
 boolean post_screen_loop
          True if end images are looped.
private  boolean post_started
          True if movie end image animation is showing.
 java.awt.Image[] postImage
          The array of end images.
private  int postImageIndex
          Current image index for end images.
 int pre_screen_delay
          The delay in milliseconds between startup images to show.
 boolean pre_screen_loop
          True if startup images are looped.
private  boolean pre_started
          True if the startup image animation is showing.
 java.awt.Image[] preImage
          The array of startup images.
private  int preImageIndex
          Current image index for startup images.
private  long pts
          The time in milliseconds of the current frame to play.
static int REBUFFERING
          "Re-buffering" state of the player.
 int scanSize
          The current size of the scan line.
 java.awt.Image screen
          The image for double buffering.
private  java.lang.Thread screen_thread
          The thread for playing startup or end image animation.
 java.awt.image.MemoryImageSource source
          The producer to produce pixels for the movie picture.
 long startPlayingTime
          The start time of the movie playback.
 long startPrintingBandwidth
          The start time when the 'detecting bandwith' message is shown.
 long startTime
          The start playing time.
static int STARTUP
          "Startup" state of the player.
static int STOPPED
          "Stopped" state of the player.
private  java.awt.Font TEXT_BI_FONT
          The bold font of the text to print messages.
private  java.awt.Font TEXT_FONT
          The font of the text to print messages.
private  MPEG1 videoPlayer
          The main applet's object.
private  boolean windows_platform
          Flag, eguals true, if the current os is Windows.
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MovieScreen(MPEG1 videoPlayer)
          Constructs a MovieScreen using the specified applet object.
 
Method Summary
private  int getLag()
          Calculates amount of intra-frame delay from current picRate.
 void init(io_tool _mpeg_stream)
          Inits this MovieScreen object with the specified tool for accessing the mpeg bit stream.
 void myPaint()
          Draws the movie screen.
 boolean nextFrame()
          Pauses the movie playback or calibrates the playing time depending from the state of the player (playing, pausing, etc), the current playing time and the current time of the frame.
 void paint(java.awt.Graphics g)
          Paints the controls and applet's detecting bandwidth/buffering text on the screen's graphics context and calls to the method that paints the movie's frame and prints other text/error messages.
private  void paintScreen(java.awt.Graphics g)
          Paints the movie's frame on the screen's graphics context and prints text/error messages (f.e. rebuffering information or MediaFrame locked error).
 void repaint()
          Redraws the movie screen.
 void run()
          The main thread's method (enter point) that plays startup or end image animation of the applet.
 void setElement(Element _elem)
          Sets the Element object with the pixels of the current frame.
 void start()
          Starts playing startup or end image animation of the applet.
 void stop()
          Stops playing startup or end image animation of the applet.
 void update(java.awt.Graphics g)
          Stub, overwrites the "update()" method of Panel (does nothing).
 void write(java.lang.String s, int x, int y)
          Prints the string on the screen.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elem

Element elem
The Element object with the pixels of the current frame.


mpeg_stream

private io_tool mpeg_stream
The tool for accessing the mpeg bit stream.


Picture

public java.awt.Image Picture
The movie picture.


screen

public java.awt.Image screen
The image for double buffering.


source

public java.awt.image.MemoryImageSource source
The producer to produce pixels for the movie picture.


colorModel

public java.awt.image.ColorModel colorModel
The Color model for the movie picture.


scanSize

public int scanSize
The current size of the scan line.


currentBufferingPercent

public int currentBufferingPercent
The current "buffering" percent.


playing

public boolean playing
The current playing status.


ErrNum

public static int ErrNum
The code of last error.


Msg

public static java.lang.String Msg
The message text of last error.


appletStarted

public boolean appletStarted
True if the applet is started.


preImageIndex

private int preImageIndex
Current image index for startup images.


postImageIndex

private int postImageIndex
Current image index for end images.


preImage

public java.awt.Image[] preImage
The array of startup images.


postImage

public java.awt.Image[] postImage
The array of end images.


pre_screen_delay

public int pre_screen_delay
The delay in milliseconds between startup images to show.


post_screen_delay

public int post_screen_delay
The delay in milliseconds between end images to show.


pre_screen_loop

public boolean pre_screen_loop
True if startup images are looped.


post_screen_loop

public boolean post_screen_loop
True if end images are looped.


startPlayingTime

public long startPlayingTime
The start time of the movie playback.


startPrintingBandwidth

public long startPrintingBandwidth
The start time when the 'detecting bandwith' message is shown.


pre_started

private boolean pre_started
True if the startup image animation is showing.


post_started

private boolean post_started
True if movie end image animation is showing.


STARTUP

public static final int STARTUP
"Startup" state of the player.

See Also:
Constant Field Values

PLAYED

public static final int PLAYED
"Played" state of the player.

See Also:
Constant Field Values

PAUSED

public static final int PAUSED
"Paused" state of the player.

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
"Stopped" state of the player.

See Also:
Constant Field Values

ENDED

public static final int ENDED
"Ended" state of the player.

See Also:
Constant Field Values

ERROR

public static final int ERROR
"Error" state of the player.

See Also:
Constant Field Values

LOCKED

public static final int LOCKED
"Locked" state of the player.

See Also:
Constant Field Values

L_STOPPING

public static final int L_STOPPING
"Stopped" after locking state of the player.

See Also:
Constant Field Values

REBUFFERING

public static final int REBUFFERING
"Re-buffering" state of the player.

See Also:
Constant Field Values

movieState

public int movieState
The state of the player.


startTime

public long startTime
The start playing time.


TEXT_FONT

private java.awt.Font TEXT_FONT
The font of the text to print messages.


TEXT_BI_FONT

private java.awt.Font TEXT_BI_FONT
The bold font of the text to print messages.


windows_platform

private boolean windows_platform
Flag, eguals true, if the current os is Windows.


java2_platform

private boolean java2_platform
Flag, eguals true, if the current JRE is java2.


ERROR_FONT

private java.awt.Font ERROR_FONT
The font of the text to print errors.


movieDestroy

public boolean movieDestroy
True if the applet's destroy method has been called.


now

private long now
The current playing time in milliseconds.


pts

private long pts
The time in milliseconds of the current frame to play.


lastPts

private long lastPts
Presentation timestamp for last frame (reqd when estimating).


videoPlayer

private MPEG1 videoPlayer
The main applet's object.


picLags

private static int[] picLags
1/picrate, delay in milliseconds between frames.


graphics

private java.awt.Graphics graphics
The graphics context to paint the movie screen.


screen_thread

private volatile java.lang.Thread screen_thread
The thread for playing startup or end image animation.

Constructor Detail

MovieScreen

public MovieScreen(MPEG1 videoPlayer)
Constructs a MovieScreen using the specified applet object. Adds mouse listener to the applet and if necessary fixs the netscape bug under linux platform with the italic fonts.

Parameters:
videoPlayer - the applet object.
Method Detail

init

public void init(io_tool _mpeg_stream)
Inits this MovieScreen object with the specified tool for accessing the mpeg bit stream.

Parameters:
_mpeg_stream - the tool for accessing the mpeg bit stream.

setElement

public void setElement(Element _elem)
Sets the Element object with the pixels of the current frame.

Parameters:
_elem - the Element object with the pixels of the current frame.

getLag

private int getLag()
Calculates amount of intra-frame delay from current picRate. This value is used only when an explicit PTS value is not available.

Returns:
the amount of intra-frame delay from current picRate.

update

public void update(java.awt.Graphics g)
Stub, overwrites the "update()" method of Panel (does nothing).

Overrides:
update in class java.awt.Container
Parameters:
g - the graphics context to paint.

myPaint

public void myPaint()
Draws the movie screen. Gets the graphics context and calls the method to draw the screen on it.


write

public void write(java.lang.String s,
                  int x,
                  int y)
Prints the string on the screen.

Parameters:
s - the string to print.
x - the x coordinate of the string's first character (left baseline point).
y - the y coordinate of the string's first character (left baseline point).

repaint

public void repaint()
Redraws the movie screen.

Overrides:
repaint in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Paints the controls and applet's detecting bandwidth/buffering text on the screen's graphics context and calls to the method that paints the movie's frame and prints other text/error messages.

Overrides:
paint in class java.awt.Container
Parameters:
g - the graphics context to paint.

paintScreen

private void paintScreen(java.awt.Graphics g)
Paints the movie's frame on the screen's graphics context and prints text/error messages (f.e. rebuffering information or MediaFrame locked error).

Parameters:
g - the graphics context to paint.

nextFrame

public boolean nextFrame()
                  throws java.lang.InterruptedException
Pauses the movie playback or calibrates the playing time depending from the state of the player (playing, pausing, etc), the current playing time and the current time of the frame.

Returns:
true, if the frame should be painted.
Throws:
java.lang.InterruptedException - raises if another process interrupts the current process.

start

public void start()
Starts playing startup or end image animation of the applet.


run

public void run()
The main thread's method (enter point) that plays startup or end image animation of the applet.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stops playing startup or end image animation of the applet.