net.sourceforge.nite.gui.mediaviewer
Class NMediaHandler

java.lang.Object
  extended by net.sourceforge.nite.gui.mediaviewer.NMediaHandler
All Implemented Interfaces:
PlayingTimeHandler, TimeHandler

public class NMediaHandler
extends java.lang.Object
implements PlayingTimeHandler

This is an in-between level class. It shouldn't be used by application programs: it's created by the Clock implementation to control all the other PlayingTimeHandlers registered with the Clock. We want this separation because the messages passed to PlayingTimeHandlers (they're continuous players like media players) should be significantly different to the behaviour of discrete players. The former should get few messages: things like 'play' and 'pause' from button presses, while the latter get an update every time the system clock changes.

Author:
jonathan

Field Summary
 java.util.Set playingHandlers
           
 
Constructor Summary
NMediaHandler(Clock clock)
           
 
Method Summary
 void acceptTimeChange(double systemTime)
          Accept a new time (generally from another registered TimeHandler).
 void acceptTimeSpanChange(double start, double end)
          Accept a new time span from another registered time handler.
 void deregisterPlayer(TimeHandler display)
          Deregister a PlayingTimeHandler so that it is no longer controlled by the parent Clock
 void fastForward()
          fast forward the continuous stream by the pre-defined amount (defaults to 5 seconds)
 void fastForward(int seconds)
          fast forward the continuous stream by the pre-defined amount (defaults to 5 seconds)
 Clock getClock()
          Return the Clock that is currently syncronising this TimeHandler
 java.lang.String getFileName()
          return the file name currently being played by this player - not relevant here!
 double getMaxTime()
          get the latest time handled by this TimeHandler - this returns 0.0 because we leave it to the individual media players to register their times with the clock when they have pre-fetched.
 java.lang.String getName()
          Return the file name being played.
 double getTime()
          return the time of a media source
 boolean isMaster()
          return true if this player has the 'master' button checked, and thus controls time for the application
 boolean isPlaying()
          true if we're playing
 boolean pastEndTime(double ctime)
          return a boolean: true the given time is after the end time of the media file.
 void pause()
          pause the continuous stream
 void play()
          start playing the continuous stream
 void registerPlayer(PlayingTimeHandler display)
          Register a PlayingTimeHandler that will henceforth be controlled from the parent Clock.
 void rewind()
          rewind the continuous stream by the pre-defined amount (defaults to 5 seconds)
 void rewind(int seconds)
          rewind the continuous stream by the pre-defined amount (defaults to 5 seconds)
 void setClock(Clock clock)
          Set the Clock to which this TimeHandler is registered
 void setMaster(boolean mast)
          Make this player control time for the application if the argument is 'true', or stop it from being if 'false'.
 void setPlayRate(float rate)
          fast forward the continuous stream by the pre-defined amount (defaults to 5 seconds)
 void setTime(double time)
          Broadcast a new time from a media player, but only to the elements up the tree.
 void setTime(double time, TimeHandler child)
          Broadcast a new time from a media player, but only to the elements up the tree.
 void setTimeHighlightColor(java.awt.Color color)
          Change the Color used for all registered TimeHandlers to highlight times - this is not relevant to PlayingTimeHandlers
 void setTimeSpan(double start, double end)
          Broadcast a new span to all registered TimeHandlers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

playingHandlers

public java.util.Set playingHandlers
Constructor Detail

NMediaHandler

public NMediaHandler(Clock clock)
Method Detail

acceptTimeChange

public void acceptTimeChange(double systemTime)
Accept a new time (generally from another registered TimeHandler). Do what you have to do in this TimeHandler to represent the fact that the global system time is now 'systemTime' (but don't inform the niteclock to pass it on).

Specified by:
acceptTimeChange in interface TimeHandler

setTime

public void setTime(double time)
Broadcast a new time from a media player, but only to the elements up the tree.

Specified by:
setTime in interface TimeHandler

setTime

public void setTime(double time,
                    TimeHandler child)
Broadcast a new time from a media player, but only to the elements up the tree.


acceptTimeSpanChange

public void acceptTimeSpanChange(double start,
                                 double end)
Accept a new time span from another registered time handler. This may involve changing our on-screen appearance to introduce some new time highlights, or playing a stretch of video, depending on the type of handler.

Specified by:
acceptTimeSpanChange in interface TimeHandler

setTimeSpan

public void setTimeSpan(double start,
                        double end)
Broadcast a new span to all registered TimeHandlers. I don't think we can get this from a media player, so it's not currently implemented

Specified by:
setTimeSpan in interface TimeHandler

getClock

public Clock getClock()
Return the Clock that is currently syncronising this TimeHandler

Specified by:
getClock in interface TimeHandler

setClock

public void setClock(Clock clock)
Set the Clock to which this TimeHandler is registered

Specified by:
setClock in interface TimeHandler

setTimeHighlightColor

public void setTimeHighlightColor(java.awt.Color color)
Change the Color used for all registered TimeHandlers to highlight times - this is not relevant to PlayingTimeHandlers

Specified by:
setTimeHighlightColor in interface TimeHandler

play

public void play()
start playing the continuous stream

Specified by:
play in interface PlayingTimeHandler

pause

public void pause()
pause the continuous stream

Specified by:
pause in interface PlayingTimeHandler

fastForward

public void fastForward()
fast forward the continuous stream by the pre-defined amount (defaults to 5 seconds)

Specified by:
fastForward in interface PlayingTimeHandler

fastForward

public void fastForward(int seconds)
fast forward the continuous stream by the pre-defined amount (defaults to 5 seconds)

Specified by:
fastForward in interface PlayingTimeHandler

rewind

public void rewind()
rewind the continuous stream by the pre-defined amount (defaults to 5 seconds)

Specified by:
rewind in interface PlayingTimeHandler

rewind

public void rewind(int seconds)
rewind the continuous stream by the pre-defined amount (defaults to 5 seconds)

Specified by:
rewind in interface PlayingTimeHandler

registerPlayer

public void registerPlayer(PlayingTimeHandler display)
Register a PlayingTimeHandler that will henceforth be controlled from the parent Clock.


deregisterPlayer

public void deregisterPlayer(TimeHandler display)
Deregister a PlayingTimeHandler so that it is no longer controlled by the parent Clock


setPlayRate

public void setPlayRate(float rate)
fast forward the continuous stream by the pre-defined amount (defaults to 5 seconds)

Specified by:
setPlayRate in interface PlayingTimeHandler

getMaxTime

public double getMaxTime()
get the latest time handled by this TimeHandler - this returns 0.0 because we leave it to the individual media players to register their times with the clock when they have pre-fetched.

Specified by:
getMaxTime in interface TimeHandler

getFileName

public java.lang.String getFileName()
return the file name currently being played by this player - not relevant here!

Specified by:
getFileName in interface PlayingTimeHandler

isPlaying

public boolean isPlaying()
Description copied from interface: PlayingTimeHandler
true if we're playing

Specified by:
isPlaying in interface PlayingTimeHandler

getTime

public double getTime()
return the time of a media source

Specified by:
getTime in interface PlayingTimeHandler

isMaster

public boolean isMaster()
return true if this player has the 'master' button checked, and thus controls time for the application

Specified by:
isMaster in interface PlayingTimeHandler

setMaster

public void setMaster(boolean mast)
Make this player control time for the application if the argument is 'true', or stop it from being if 'false'.

Specified by:
setMaster in interface PlayingTimeHandler

getName

public java.lang.String getName()
Return the file name being played.


pastEndTime

public boolean pastEndTime(double ctime)
return a boolean: true the given time is after the end time of the media file.

Specified by:
pastEndTime in interface PlayingTimeHandler