fi.hut.tml.xsmiles.mlfc.smil.viewer.awt.media
Interface Media

All Known Implementing Classes:
ImageMedia, JMFMedia, TextMedia

public interface Media

This is the interface for media.


Method Summary
 void addMediaListener(MediaListener listener)
          Adds a MediaListener for this media.
 void close()
          This will freeze all memory and references to this media.
 int getOriginalHeight()
          Get the real height of the media.
 int getOriginalWidth()
          Get the real width of the media.
 boolean isStatic()
          Checks if this media is static or continuous.
 void pause()
          Pauses the media.
 void play()
          Plays the media.
 void prefetch()
          Prefetches media.
 void setBounds(int x, int y, int width, int height)
          Set the coordinates for the media.
 void setContainer(java.awt.Container container)
          Sets the container the media will be rendered in.
 void setMediaTime(int millisecs)
          This moves the time position in media.
 void setSoundVolume(int percentage)
          Set the sound volume for media.
 void setUrl(java.net.URL url)
          Sets the URL for this media.
 void stop()
          Stops the media.
 

Method Detail

isStatic

public boolean isStatic()
Checks if this media is static or continuous.

Returns:
true if media is static.

setUrl

public void setUrl(java.net.URL url)
Sets the URL for this media. This method will only set the URL for the media. To actually download the data, prefetch() or play() should be called.

Parameters:
url - URL for media

setContainer

public void setContainer(java.awt.Container container)
Sets the container the media will be rendered in. If media is audio, this can be null.

Parameters:
container - This container will contain the media.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Set the coordinates for the media. These are relative to the given container, set using setContainer().


setSoundVolume

public void setSoundVolume(int percentage)
Set the sound volume for media. Only applicable for sound media formats.

Parameters:
percentage - Sound volume, 0-100- (0 is quiet, 100 is original loudness, 200 twice as loud; dB change in signal level = 20 log10(percentage / 100) )

getOriginalWidth

public int getOriginalWidth()
Get the real width of the media. If not visible, or size is unknown, then returns -1.

Returns:
Original width of the media.

getOriginalHeight

public int getOriginalHeight()
Get the real height of the media. If not visible, or size is unknown, then returns -1.

Returns:
Original height of the media.

prefetch

public void prefetch()
Prefetches media. The URL must have been set using setUrl(). The data will be downloaded from the URL. After calling this method, the media will be in memory and can be played. This is a blocking method.


play

public void play()
Plays the media. The media will be added to the container set using setContainer(). It will be visible. It will also play any animation it possibly has. Also, audio media is started using this method.

If the media is not yet prefetched, it will first be prefetched.


pause

public void pause()
Pauses the media. The media will stay visible, but any animations will be paused. Audio media will be silent. NOT IMPLEMENTED YET. ?How to restart paused media?


stop

public void stop()
Stops the media. The media will be stopped and it will be invisible. Audio will be silent.


close

public void close()
This will freeze all memory and references to this media. If the media is not yet stopped, it will first be stopped.


setMediaTime

public void setMediaTime(int millisecs)
This moves the time position in media. Works only for video/audio.

Parameters:
millisecs - Time in millisecs

addMediaListener

public void addMediaListener(MediaListener listener)
Adds a MediaListener for this media. The listener will be called
  1. When the media has been prefetched. (NOT IMPLEMENTED YET).
  2. When the media ends. (animation or audio media)
Static media, such as text and images will end immediately, notifying immediately about the end of the media.



X-Smiles 1.2