All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ejmf.toolkit.multiplayer.Track

java.lang.Object
   |
   +----ejmf.toolkit.multiplayer.Track

public class Track
extends Object
A Track maintains information on a Player over time. It does this in two ways. First, it simply provides a repository for Player data, such as start time and stop stop time. Additionally, it does a 'look-ahead', moving the Player to prefetched state, obtaining information that is only valid at that point like duration and start latency. By treating a Player as a Track, you don't have to worry Player is in proper state to get that information.

The Player is moved into prefetched with a call to setPlayer. This method is called at construction when the version of the constructor that takes a Player argument is called. Since Track does not implement ControllerListener, if you want a track to be more active and listen to its Player, you will need to subclass Track. A Track may have a view associated with it. This is typically a slider and can be set with setTrackSlider method. Each Track has a track number assigned upon creation.


Constructor Index

 o Track(int)
Create a track with an assigned track number.
 o Track(int, MediaLocator, Player)
Create a Track from a Player, including its media file (or string representation of URL).

Method Index

 o close()
Close Track.
 o createTrack(int, MediaLocator, double, double)
Create and return a Track from input values.
 o getDuration()
Get the total duration of the media associated with this track.
 o getLatency()
Get start latency of Player associated with Track
 o getMediaLocator()
Get media locator of Player associated with Track
 o getMediaURL()
Get media file of Player associated with Track
 o getPlayer()
Get Player associated with Track
 o getPlayingTime()
Get playing time of Player associated with Track
 o getStartTime()
Get start time of Player associated with Track
 o getState()
 o getTrackNumber()
Get track number associated with Track
 o getTrackSlider()
Get slider view.
 o isAssigned()
 o isAvailable()
Tracks can be used for different Players.
 o setMediaLocator(MediaLocator)
Set MediaLocator of Player associated with Track
 o setPlayer(Player)
Assign a Player to this Track.
 o setPlayingTime(double)
Set playing time of Player associated with Track This is different than duration, ie.
 o setStartTime(double)
Set start time of Player associated with Track
 o setState(int)
 o setTrackSlider(TrackSlider)
Set slider view.

Constructors

 o Track
 public Track(int trackNumber,
              MediaLocator ml,
              Player player)
Create a Track from a Player, including its media file (or string representation of URL).

Parameters:
trackNumber - Assigned track number
player - Player associated with Track
fileName - Media file name of string representation of URL
 o Track
 public Track(int trackNumber)
Create a track with an assigned track number. Other relevant data is set later.

Parameters:
trackNumber - Assigned track number

Methods

 o setPlayer
 public void setPlayer(Player player)
Assign a Player to this Track. The Player is put in the Prefetch state so that it can get from the Player all the info it needs about it. The Player is moved to prefetched using StateWaiter's blockingPrefetch. If a Player is assigned to this track already, it it is closed.

Parameters:
player - A javax.media.Player
See Also:
StateWaiter
 o close
 public void close()
Close Track. Stop and deallocate player if necessary, finally, closing the Player.

 o getPlayer
 public Player getPlayer()
Get Player associated with Track

Returns:
A player associated with Track
 o getTrackNumber
 public int getTrackNumber()
Get track number associated with Track

Parameters:
the - index of Track
 o setMediaLocator
 public void setMediaLocator(MediaLocator ml)
Set MediaLocator of Player associated with Track

Parameters:
ml - MediaLocator of Player associated with Track
 o getMediaLocator
 public MediaLocator getMediaLocator()
Get media locator of Player associated with Track

Returns:
MediaLocator of Player associated with Track
 o getMediaURL
 public URL getMediaURL()
Get media file of Player associated with Track

Returns:
The URL associated with the Track's MediaLocator.
 o setPlayingTime
 public void setPlayingTime(double seconds)
Set playing time of Player associated with Track This is different than duration, ie. it may be shorter.

Parameters:
seconds - Playing time in milliseconds
 o getPlayingTime
 public double getPlayingTime()
Get playing time of Player associated with Track

Returns:
Playing time in milliseconds
 o getDuration
 public Time getDuration()
Get the total duration of the media associated with this track. This value can not be changed.

Returns:
A javax.media.Time object representing duration of Player
 o setStartTime
 public void setStartTime(double startTime)
Set start time of Player associated with Track

Parameters:
startTime - Offset in milliseconds at which Player should be started.
 o getStartTime
 public double getStartTime()
Get start time of Player associated with Track

Returns:
Offset in milliseconds at which Player is to be started.
 o getLatency
 public long getLatency()
Get start latency of Player associated with Track

Returns:
Startup latency of Player associated with this track. If Player reports UNKNOWN, getLatency will report zero.
 o isAvailable
 public synchronized boolean isAvailable()
Tracks can be used for different Players. This method reports whether this Track is available for use. A Track may is available after its close method is called. Additionally, a Track may be created without an associated Player. In that case also isAvailable returns true.

Returns:
true if Track is available.
 o isAssigned
 public boolean isAssigned()
Returns:
true if this Track has a Player assigned to it.
 o setTrackSlider
 public void setTrackSlider(TrackSlider trackSlider)
Set slider view.

Parameters:
trackSlider - Display representation of Track
 o getTrackSlider
 public TrackSlider getTrackSlider()
Get slider view.

Returns:
Display representation of Track
 o setState
 public void setState(int state)
 o getState
 public int getState()
 o createTrack
 public static Track createTrack(int i,
                                 MediaLocator ml,
                                 double startTime,
                                 double playingTime) throws IOException, NoPlayerException
Create and return a Track from input values.

Parameters:
i - The index of Track
ml - The MediaLocator for locating Player
startTime - start time offset in milliseconds
playingTime - playing time in milliseconds
Throws: IOException
thrown if DataSource can not be connected to.
Throws: NoPlayerException
thrown if no handler exists for Player

All Packages  Class Hierarchy  This Package  Previous  Next  Index