Top Description Methods
com.sun.media.jfxmedia

public Interface MediaPlayer

Known Direct Implementers
com.sun.media.jfxmediaimpl.NativeMediaPlayer
Imports
com.sun.media.jfxmedia.effects.AudioEqualizer, .AudioSpectrum, com.sun.media.jfxmedia.events.PlayerStateListener, .VideoTrackSizeListener, .AudioSpectrumListener, .MarkerListener, .MediaErrorListener, .BufferListener, .PlayerStateEvent.PlayerState, .PlayerTimeListener, com.sun.media.jfxmedia.control.VideoRenderControl, .MediaPlayerOverlay

MediaPlayer class provides control of media playback. Get a MediaPlayer from either MediaManager or MediaRecorder.
See Also
MediaManager, MediaRecorder

Method Summary

Modifier and TypeMethod and Description
public void
addAudioSpectrumListener(AudioSpectrumListener listener)

Adds a listener for audio spectrum events.

public void
addBufferListener(BufferListener listener)

Adds a listener for all buffer events.

public void
addMarkerListener(MarkerListener listener)

Adds a listener for marker events.

public void
addMediaErrorListener(MediaErrorListener
The warning listener.
listener
)

Adds a listener for warnings which occur within the lifespan of the player.

public void
addMediaPlayerListener(PlayerStateListener listener)

Adds a listener for media state.

public void
addMediaTimeListener(PlayerTimeListener listener)

Adds a listener for player time events.

public void
addVideoTrackSizeListener(VideoTrackSizeListener listener)

Adds a listener for video track frame dimensions.

public void
dispose()

Release any resources held by this player.

public AudioSpectrum

Returns:

AudioSpectrum object
getAudioSpectrum
()

Gets the audio spectrum controller for the player.

public long
getAudioSyncDelay()

Retrieve the audio rendering delay.

public float

Returns:

the current balance
getBalance
()

Gets the current balance.

public double
getDuration()

Gets the duration in seconds.

public AudioEqualizer

Returns:

AudioEqualizer object
getEqualizer
()

Gets the audio equalizer for the player.

public Media

Returns:

Media object.
getMedia
()

Gets a Media object.

public MediaPlayerOverlay

Returns:

A MediaPlayerOverlay instance.
getMediaPlayerOverlay
()

Returns the media player overlay support interface.

public boolean

Returns:

true if audio is muted.
getMute
()

Gets the muted state.

public double

Returns:

the current presentation time
getPresentationTime
()

Gets the current presentation time.

public float
getRate()

Get the rate of playback.

public double
getStartTime()

Gets the time within the duration of the media to start playing.

public PlayerStateEvent.PlayerState

Returns:

the current player state.
getState
()

Retrieves the current state of the player.

public double
getStopTime()

Gets the time within the duration of the media to stop playing.

public VideoRenderControl

Returns:

A VideoRenderControl instance.
getVideoRenderControl
()

Returns the video rendering support interface.

public float

Returns:

the current volume
getVolume
()

Gets the current volume.

public boolean
isErrorEventCached()

Returns true if we have cached error event.

public void
pause()

Pauses the media playing.

public void
play()

Begins playing of the media.

public void
removeAudioSpectrumListener(AudioSpectrumListener listener)

Removes a listener for audio spectrum events.

public void
removeBufferListener(BufferListener listener)

Removes a listener for buffer events.

public void
removeMarkerListener(MarkerListener listener)

Removes a listener for marker events.

public void
removeMediaErrorListener(MediaErrorListener
The warning listener.
listener
)

Removes a listener for warnings.

public void
removeMediaPlayerListener(PlayerStateListener listener)

Removes a listener for media state.

public void
removeMediaTimeListener(PlayerTimeListener listener)

Removes a listener for player time events.

public void
removeVideoTrackSizeListener(VideoTrackSizeListener listener)

Removes a listener for video track frame dimensions.

public void
seek(double
The time in seconds to which to seek.
streamTime
)

Seeks playback to the specified time.

public void
setAudioSyncDelay(long
time in milliseconds
delay
)

Set the amount of time to delay the audio.

public void
setBalance(float
A value in the range [-1.0, 1.0].
balance
)

Sets the balance.

public void
setMute(boolean enable)

Enables/disable mute.

public void
setRate(float rate)

Sets the rate of playback.

public void
setStartTime(double streamTime)

Sets the start time within the media to play.

public void
setStopTime(double streamTime)

Sets the stop time within the media to stop playback.

public void
setVolume(float
A value in the range [0, 1.0].
volume
)

Sets the volume.

public void
stop()

Stops playing of the media and resets the play time to 0.

Method Detail

addAudioSpectrumListenerback to summary
public void addAudioSpectrumListener(AudioSpectrumListener listener)

Adds a listener for audio spectrum events.

Exceptions
IllegalArgumentException:
if listener is null.
addBufferListenerback to summary
public void addBufferListener(BufferListener listener)

Adds a listener for all buffer events.

Exceptions
IllegalArgumentException:
if listener is null.
addMarkerListenerback to summary
public void addMarkerListener(MarkerListener listener)

Adds a listener for marker events.

Exceptions
IllegalArgumentException:
if listener is null.
addMediaErrorListenerback to summary
public void addMediaErrorListener(MediaErrorListener listener)

Adds a listener for warnings which occur within the lifespan of the player.

Parameters
listener:MediaErrorListener

The warning listener.

Exceptions
IllegalArgumentException:
if listener is null.
addMediaPlayerListenerback to summary
public void addMediaPlayerListener(PlayerStateListener listener)

Adds a listener for media state.

Exceptions
IllegalArgumentException:
if listener is null.
addMediaTimeListenerback to summary
public void addMediaTimeListener(PlayerTimeListener listener)

Adds a listener for player time events.

addVideoTrackSizeListenerback to summary
public void addVideoTrackSizeListener(VideoTrackSizeListener listener)

Adds a listener for video track frame dimensions.

Exceptions
IllegalArgumentException:
if listener is null.
disposeback to summary
public void dispose()

Release any resources held by this player. The player will be unusable after this method is invoked.

getAudioSpectrumback to summary
public AudioSpectrum getAudioSpectrum()

Gets the audio spectrum controller for the player.

Returns:AudioSpectrum

AudioSpectrum object

getAudioSyncDelayback to summary
public long getAudioSyncDelay()

Retrieve the audio rendering delay.

getBalanceback to summary
public float getBalance()

Gets the current balance.

Returns:float

the current balance

getDurationback to summary
public double getDuration()

Gets the duration in seconds. If the duration is unknown or cannot be obtained when this method is invoked, a negative value will be returned.

getEqualizerback to summary
public AudioEqualizer getEqualizer()

Gets the audio equalizer for the player.

Returns:AudioEqualizer

AudioEqualizer object

getMediaback to summary
public Media getMedia()

Gets a Media object.

Returns:Media

Media object.

getMediaPlayerOverlayback to summary
public MediaPlayerOverlay getMediaPlayerOverlay()

Returns the media player overlay support interface.

Returns:MediaPlayerOverlay

A MediaPlayerOverlay instance.

getMuteback to summary
public boolean getMute()

Gets the muted state. While muted no audio will be heard.

Returns:boolean

true if audio is muted.

getPresentationTimeback to summary
public double getPresentationTime()

Gets the current presentation time. If the time is unknown or cannot be obtained when this method is invoked, a negative value will be returned.

Returns:double

the current presentation time

getRateback to summary
public float getRate()

Get the rate of playback.

getStartTimeback to summary
public double getStartTime()

Gets the time within the duration of the media to start playing.

getStateback to summary
public PlayerStateEvent.PlayerState getState()

Retrieves the current state of the player.

Returns:PlayerStateEvent.PlayerState

the current player state.

getStopTimeback to summary
public double getStopTime()

Gets the time within the duration of the media to stop playing.

getVideoRenderControlback to summary
public VideoRenderControl getVideoRenderControl()

Returns the video rendering support interface.

Returns:VideoRenderControl

A VideoRenderControl instance.

getVolumeback to summary
public float getVolume()

Gets the current volume.

Returns:float

the current volume

isErrorEventCachedback to summary
public boolean isErrorEventCached()

Returns true if we have cached error event.

pauseback to summary
public void pause()

Pauses the media playing. Calling play() after pause() will continue playing the media from where it left off.

playback to summary
public void play()

Begins playing of the media. To ensure smooth playback, catch the onReady event in the MediaPlayerListener before playing.

removeAudioSpectrumListenerback to summary
public void removeAudioSpectrumListener(AudioSpectrumListener listener)

Removes a listener for audio spectrum events.

Exceptions
IllegalArgumentException:
if listener is null.
removeBufferListenerback to summary
public void removeBufferListener(BufferListener listener)

Removes a listener for buffer events.

Exceptions
IllegalArgumentException:
if listener is null.
removeMarkerListenerback to summary
public void removeMarkerListener(MarkerListener listener)

Removes a listener for marker events.

Exceptions
IllegalArgumentException:
if listener is null.
removeMediaErrorListenerback to summary
public void removeMediaErrorListener(MediaErrorListener listener)

Removes a listener for warnings.

Parameters
listener:MediaErrorListener

The warning listener.

Exceptions
IllegalArgumentException:
if listener is null.
removeMediaPlayerListenerback to summary
public void removeMediaPlayerListener(PlayerStateListener listener)

Removes a listener for media state.

Exceptions
IllegalArgumentException:
if listener is null.
removeMediaTimeListenerback to summary
public void removeMediaTimeListener(PlayerTimeListener listener)

Removes a listener for player time events.

removeVideoTrackSizeListenerback to summary
public void removeVideoTrackSizeListener(VideoTrackSizeListener listener)

Removes a listener for video track frame dimensions.

Exceptions
IllegalArgumentException:
if listener is null.
seekback to summary
public void seek(double streamTime)

Seeks playback to the specified time. The state of the player is unchanged. A negative value will be clamped to zero, and a positive value to the duration, if known.

Parameters
streamTime:double

The time in seconds to which to seek.

setAudioSyncDelayback to summary
public void setAudioSyncDelay(long delay)

Set the amount of time to delay the audio. A positive value makes audio render later, and a negative value makes audio render earlier.

Parameters
delay:long

time in milliseconds

setBalanceback to summary
public void setBalance(float balance)

Sets the balance. A negative value indicates left of center and a positive value right of center. Values will be clamped to the range [-1.0, 1.0].

Parameters
balance:float

A value in the range [-1.0, 1.0].

setMuteback to summary
public void setMute(boolean enable)

Enables/disable mute. If mute is enabled then disabled, the previous volume goes into effect.

setRateback to summary
public void setRate(float rate)

Sets the rate of playback. A positive value indicates forward play and a negative value reverse play.

setStartTimeback to summary
public void setStartTime(double streamTime)

Sets the start time within the media to play.

setStopTimeback to summary
public void setStopTime(double streamTime)

Sets the stop time within the media to stop playback.

setVolumeback to summary
public void setVolume(float volume)

Sets the volume. Values will be clamped to the range [0, 1.0].

Parameters
volume:float

A value in the range [0, 1.0].

stopback to summary
public void stop()

Stops playing of the media and resets the play time to 0.