|
IBM Toolkit for MPEG-4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
MPEG-4 Player Control interface. This is the interface via which the MPEG-4
player subsystem can be controlled. It has high level methods to open content,
play, pause, stop etc that control the playback of MPEG-4 media content from
files and over a variety of network protocols. There are also methods to get
and set other parameters that affect playback such as volume, render rate,
scaling etc.
In addition PlayerListener instance(s) can be added to receive state change
and other event notifications from the MPEG-4 player subsystem.
Field Summary | |
static int |
CLOSED
Player presentation state 'CLOSED' constant |
static int |
END_ACTION_CONTINUE
Player constant to set Continue at end action |
static int |
END_ACTION_REPEAT
Player constant to set Repeat (loop) at end action |
static int |
END_ACTION_STOP
Player constant to set Stop at end action |
static int |
PAUSED
Player presentation state 'PAUSED' constant |
static int |
PLAYING
Player presentation state 'PLAYING' constant |
static int |
RTSP_AUTO
RTSP Mode Automatic. |
static int |
RTSP_HTTP_TUNNEL
RTSP Mode HTTP Tunnelling. |
static int |
RTSP_TCP_INTERLEAVE
RTSP Mode TCP Interleave. |
static int |
RTSP_TCP_INTERLEAVE_UDP
RTSP Mode TCP Interleave and/or UDP. |
static int |
RTSP_UDP
RTSP Mode UDP. |
static int |
STOPPED
Player presentation state 'STOPPED' constant |
Method Summary | |
void |
addListener(PlayerListener pl)
Add (register) a player listener. |
boolean |
canPause()
Indicates whether the player has the ability to pause the current presentation or not. |
boolean |
canSeek()
Return whether the player has the ability to seek into the current presentation or not. |
boolean |
canSetVolume()
Indicates whether the player has the ability to set the audio volume. |
void |
close()
Close any opened content. |
float |
getActualFPS()
Get actual compositor rendering frame rate. |
boolean |
getAutoSize()
Indicates the autoSize value |
long |
getDuration()
Get the specified (known) duration of the current presentation. |
float |
getFPS()
Get the compositor render frame rate that is set |
boolean |
getMetrics()
Indicates if pixel metrics are being used for scene. |
boolean |
getMute()
Get the mute state. |
int |
getPlayerEndAction()
Get the EndAction behavior. |
java.awt.Dimension |
getPreferredSceneSize()
Get the desired scene size of the presentation. |
java.awt.Component |
getRendererComponent()
Get the player component that contains the rendered output so it can be added to an appropriate container of the applications choosing. |
int |
getRTSPMode()
Gets the current RTSP mode set |
boolean |
getScaling()
Get the scaling setting. |
PlayerScreenCapture |
getScreenCapture()
Returns a PlayerScreenCapture interface to access the pixels captured from the current rendered image. |
java.lang.String[] |
getScreenCaptureFormats()
Returns an array of supported formats that can be specified for writing in the PlayerScreenCapture object returned by getScreenCapture(). |
java.awt.Dimension |
getSize()
Get the actual player Size at this time. |
double |
getSpeed()
Get the speed of the presentation. |
boolean |
getSpeedScaling()
Gets speed scaling hint |
int |
getState()
Get the current MPEG-4 player presentation state. |
java.lang.String |
getStateName()
Get the current MPEG-4 player presentation state. |
long |
getTime()
Get the current presentation time. |
double |
getVolume()
Get the volume level of the presentation. |
boolean |
hasDuration()
Return whether the duration of the current presentation is known. |
boolean |
hasPreferredSceneSize()
Indicates whether the presentation has a desired scene size. |
boolean |
isListener(PlayerListener pl)
Test if PlayerListener object is a registered player listener |
void |
open(java.lang.String url)
Open content referenced by the URL. |
void |
pause()
Pause the currently playing presentation (playing is resumed with the resume() method). |
boolean |
playUrl(java.lang.String url)
Play a URL. |
void |
removeListener(PlayerListener pl)
Remove a player listener |
void |
resume()
Resume playing a presentation from where it is currently paused. |
void |
seek(long presTime)
Seek to a particular point in the presentation. |
void |
setAutoSize(boolean autoSize)
Sets the Player to auto size or not. |
void |
setFPS(float fps)
Set compositor render frame rate in frames per second. |
void |
setMute(boolean mute)
Mute any audio. |
void |
setPlayerEndAction(int action)
Set the EndAction. |
boolean |
setRTSPMode(int mode)
Sets the RTSP playback mode for when/if media is retrieved using RTSP. |
void |
setScaling(boolean scale)
Set whether presentations in pixel metrics can scale or not (presentations that are in meter metrics always scale such that the display width is +/- one meter and vertical dimension is ratio of height/width as per MPEG-4 Systems specification) |
void |
setSize(int width,
int height)
Set the actual player Size. |
void |
setSpeed(double speed)
Set the speed of the presentation. |
void |
setSpeedScaling(boolean speedScaling)
Set speed scaling hint - true to do scaling by speed, false to do quality. |
void |
setVolume(double volume)
Set the volume level of the presentation. |
void |
start()
Start playing content that has already been opened by a prior call to open(URL). |
void |
step(long mSecs)
Step the presentation forward by the given number of milliseconds. |
void |
stop()
Stop playing the current presentation, which may be playing, paused, or already stopped. |
boolean |
stopUrl()
Stop playing a URL. |
Field Detail |
public static final int CLOSED
public static final int STOPPED
public static final int PLAYING
public static final int PAUSED
public static final int END_ACTION_CONTINUE
public static final int END_ACTION_STOP
public static final int END_ACTION_REPEAT
public static final int RTSP_AUTO
public static final int RTSP_UDP
public static final int RTSP_TCP_INTERLEAVE
public static final int RTSP_HTTP_TUNNEL
public static final int RTSP_TCP_INTERLEAVE_UDP
Method Detail |
public void addListener(PlayerListener pl)
pl
- The PlayerListenerpublic boolean isListener(PlayerListener pl)
pl
- The PlayerListenerpublic void removeListener(PlayerListener pl)
pl
- The PlayerListenerpublic java.awt.Component getRendererComponent()
public boolean playUrl(java.lang.String url)
url
- URL of the presentation.
public boolean stopUrl()
public int getState()
public java.lang.String getStateName()
public void open(java.lang.String url) throws java.io.IOException, java.lang.IllegalStateException
This will initialize the various components of the player and go to the Stopped state, so it will not start playing the presentation . A network connection will be established as needed to access the content (e.g. when using RTSP a session will be established with the media server). In this state information about the content is now available such as its duration, whether the content can be paused and seek supported. This information can be used to set-up the user interface before the presentation is started. To start playback, a call to start() must be made.
url
- URL string referencing the content.
java.io.IOException
- If there's an I/O problem with this URL.
java.lang.IllegalStateException
- If there's a presentation already open
(state must be Closed).public void close() throws java.io.IOException
java.io.IOException
- If there's an I/O problem closing.public void start() throws java.io.IOException, java.lang.IllegalStateException
Note: if start() is called when the player is in Closed state the PlayerListener method playRequestWhenClosed() is called. This to allow a main player shell to use the various PlayerControlPanels and have the Play button enabled even though content has not been opened. Since opening content creates a network connection and allocates resources it may be undesirable to open content unless the user wants to play it - e.g. in an applet setting on a web page there may be content presented this way such that the play button indicates it can be played. The main shell should implement the playRequestWhenClosed() method if it uses the PlayerControlPanel feature to enable play button in Closed state. In the implementation the player should open(url) for the content and then start() to play the content as per the users request.
java.io.IOException
- If there's an I/O problem starting.
java.lang.IllegalStateException
- If the state is Playing or Pausedpublic void stop() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- If there's an I/O problem stopping.
java.lang.IllegalStateException
- If there's no presentation open
(so the state may not be Closed).public void setPlayerEndAction(int action)
The EndAction can be set before or during playback. If the playback point is already beyond the specified duration then the endAction will occur as soon as the new action is set. The player is initialized with behavior of END_ACTION_CONTINUE
action
- The action required - END_ACTION_CONTINUE, END_ACTION_STOP,
END_ACTION_REPEATpublic int getPlayerEndAction()
public boolean canPause()
public void pause() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- Pause may require a remote server to be notified and
an IO error may occur if there are network problems
java.lang.IllegalStateException
- If state is Stopped or Closed, or if pause is not supportedpublic void resume() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- Resume may require a remote server to be notified and
an IO error may occur if there are network problems
java.lang.IllegalStateException
- If state is Stopped or Closedpublic boolean canSeek()
public void seek(long presTime) throws java.io.IOException, java.lang.IllegalStateException
Note: currently this is not supported by the player
presTime
- Absolute time in the presentation to seek to, in
milliseconds.
java.io.IOException
- Seek may require a remote server to be notified and
an IO error may occur if there are network problems
java.lang.IllegalStateException
- If state is Closed, or if seek is not supportedpublic void step(long mSecs) throws java.io.IOException, java.lang.IllegalStateException
Note: currently this is not supported by the player
mSecs
- Step size in milliseconds.
java.io.IOException
java.lang.IllegalStateException
public long getTime()
public boolean hasDuration()
public long getDuration()
public void setSpeed(double speed)
Note: this is not supported in a limited fashion by the player. Playback of all media is affected except audio. Speed is also reset back to a factor of 1 when the content playback is stopped.
speed
- Speed factor, with 1 is regular speed, 1/2 is a slow
down by a factor of 2, 2 is speed-up by a factor of 2, etc.public double getSpeed()
public void setScaling(boolean scale)
public boolean getScaling()
public void setSpeedScaling(boolean speedScaling)
public boolean getSpeedScaling()
public java.lang.String[] getScreenCaptureFormats()
The current encodings supported are BMP (all VMs), JPG (Java 1.2 and above with Sun codec, or 1.4 and above with ImageIO), PNG (Java 1.4 and above with ImageIO). The actual list returned will be dependent on the VM environment; minimally this will return bmp, but in the presence of the other capabilities listed above, and when supported, the other formats would be included too.
public PlayerScreenCapture getScreenCapture()
The captured image is that which is being used for rendering. Generally this will be exactly what is displayed, i.e same size. However, in the case of scaling by speed being set, see setSpeedScaling(), the image will be as if the player is rendering at x1 size even if the display is scaled (this is because scaling by speed creates the composite image at x1 preferred size and then finally scales when its drawn).
public boolean hasPreferredSceneSize()
public java.awt.Dimension getPreferredSceneSize()
public boolean getMetrics()
public java.awt.Dimension getSize()
public void setSize(int width, int height)
Note concerning Size, Pixel versus Meter metrics and Preferred Size. The size of the player as set here is always in pixels. MPEG-4 content can specify dimensions within the scene as pixels or in meters. MPEG-4 content is rendered using center of the display as 0,0 with x and y positive directions being to the right and up respectively.
In both cases the preferred size, when set, acts as a guide for the initial dimensions although a player can choose to ignore this indication if it so chooses and does not have to set the size that the content (author) has expressed a preference for.
public void setMute(boolean mute)
mute
- Mutes audio playback, i.e turns it off if true, on if false.public boolean getMute()
public boolean canSetVolume()
public void setVolume(double volume)
volume
- Volume in the range [0,1].public double getVolume()
public void setFPS(float fps)
fps
- public float getFPS()
public float getActualFPS()
public void setAutoSize(boolean autoSize)
autoSize
- True for forced automatic re-sizing, false to do it manually.public boolean getAutoSize()
public boolean setRTSPMode(int mode)
In addition there is an AUTO mode that uses a combination approach to its connection attempt.
Note: the mode will only become effective when the next content is opened, or any existing content re-opened, it will thus not affect any ongoing playback.
mode
- One of the RTSP_xxxx playback mode constants
public int getRTSPMode()
|
IBM Toolkit for MPEG-4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |