JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

expand all

Profile: desktop, common

Overview

The MediaPlayer class provides the controls for playing media. It is used in combination with the Media and MediaView classes to display and control media playing. Note that the MediaPlayer does not contain any visual elements so must be used with the MediaView class to view the media. The number of MediaPlayers that can concurrently display media may vary depending on the JavaFX runtime implementation.

See Also:
Media, MediaView

Profile: common

Script Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicBUFFERINGInteger

This state is unimplemented and may be deprecated in future releases.

public-readPAUSEDInteger

Value of status when playback is stopped or paused.

publicPLAYINGInteger

Value of status while the player is playing the media.

publicREPEAT_FOREVERInteger

When repeatCount is set to this value, the player will repeat playback of the Media until stopped.

publicREPEAT_NONENumber

When repeatCount is set to this value, the player will play the Media only once.

publicSTALLEDInteger

This state is unimplemented and may be deprecated in future releases.

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicautoPlayBoolean

If autoPlay is true, playing will start as soon as possible

publicbalanceNumber

Defines the balance, or left/right setting, of the audio output.

Defines the balance, or left/right setting, of the audio output. Value ranges continuously from -1.0 being full left, 0.0 being center, and 1.0 being full right.

Profile: common

 
public-readbufferProgressTimeDuration

For a bufferred stream, the current buffer position which indicates how much media can be played without stalling the MediaPlayer.

For a bufferred stream, the current buffer position which indicates how much media can be played without stalling the MediaPlayer. Setting currentTime to a value beyond bufferProgressTime is undefined and behavior may be implementation dependent. This issue will be resolved in a future release.

Profile: common

 
public-readcurrentCountNumber

Defines the current number of times the media has repeated.

Defines the current number of times the media has repeated. This property is incremented just prior to seeking back to startTime.

Profile: common

 
publiccurrentTimeDuration

The current media time, may be read to indicate the current position or written to cause the media to seek to the set position.

The current media time, may be read to indicate the current position or written to cause the media to seek to the set position. Note that since the variable is being updated by the JavaFX rutime, bind with inverse must be used if it is being bound from another variable.

Note that setting currentTime to a value outside of the range defined by startTime and stopTime will reset currentTime to startTime.

Profile: common

 
publicenabledTracksTrack[]

The sequence of tracks that are currently enabled on this MediaPlayer.

The sequence of tracks that are currently enabled on this MediaPlayer. To enable or disable tracks, a Track is respectively added or removed from this sequence.

See Also:
Media.tracks

 
publicfaderNumber

The fader, or forward and back setting, of audio output on 4+ channel output.

The fader, or forward and back setting, of audio output on 4+ channel output. Value ranges continuously from -1.0 being rear, 0.0 being center, and 1.0 being forward.

NOTE: This property is not implemented yet.

Profile: common

 
publicmediaMedia

Defines the source Media to be played

publicmuteBoolean

When true the player's audio is muted, false otherwise.

publiconBufferingfunction(:Duration):Void

This property is unimplemented and may be deprecated in future releases.

publiconEndOfMediafunction():Void

Invoked when the player currentTime reaches stopTime and is not repeating.

publiconErrorfunction(:MediaError):Void

The onError function is called when a MediaError occurs on this player.

The onError function is called when a MediaError occurs on this player. Note that onError should be intitialized before other variables so that errors can be handled properly.

See Also:
MediaError

Profile: common

 
publiconRepeatfunction():Void

Invoked when the player reaches stopTime and will be repeating.

Invoked when the player reaches stopTime and will be repeating. This callback is made prior to seeking back to startTime

See Also:
repeatCount

Profile: common

 
publiconStalledfunction(:Duration):Void

This property is unimplemented and may be deprecated in future releases.

publicpausedBoolean

Indicates if the player has been paused, either programatically, by the user, or because the media has finished playing.

publicrateNumber

Defines the rate at which the media is being played.

Defines the rate at which the media is being played. Rate 1.0 plays at the media's normal playback rate, 2.0 plays back at 2 times the normal rate, -1.0 plays at the normal rate in reverse. Note that all not media formats support playing backwards or at arbitrary rates.

Profile: common

 
publicrepeatCountNumber

Defines the number of times the media should be played.

Defines the number of times the media should be played. If repeatCount is 1 or REPEAT_NONE the media will play once then stop. If set to REPEAT_FOREVER, it will repeat indefinitely until manually stopped.

Profile: common

 
publicstartTimeDuration

Defines the time offset where media should start playing, or restart from when repeating.

Defines the time offset where media should start playing, or restart from when repeating. When playback is stopped, the current time is reset to this value.

Constraints: 0 <= startTime < stopTime

Profile: common

 
publicstatusInteger

Reflects the current status of the MediaPlayer.

Reflects the current status of the MediaPlayer. The status is one of:
PAUSED: The player has been paused or stopped
PLAYING: The player is playing

BUFFERING and STALLED are currently unimplemented and may be deprecated in future releases.

Profile: common

 
publicstopTimeDuration

Defines the time offset where media should stop playing or restart when repeating

public-readsupportsMultiViewsBoolean

Indicates if this player can have multiple views associated with it.

publictimersMediaTimer[]

The sequence of media timers for this player.

The sequence of media timers for this player. For each MediaTimer in this sequence, its action function will be invoked when the time is reached by this MediaPlayer

See Also:
MediaTimer

Profile: common

 
publicvolumeNumber

Defines the volume at which the media is being played.

Defines the volume at which the media is being played. 1.0 is full volume, which is the default. A value of 0.0 effectively mutes the audio.

Profile: common

 

Inherited Variables

Function Summary

public pause() : Void

Pauses the player.

Pauses the player.

Profile: common

 
public play() : Void

Starts playing the media.

Starts playing the media. If previously paused, then playback resumes where it was paused.

Profile: common

 
public stop() : Void

Stop playing the media.

Stop playing the media. This operation resets playback to startTime, and resets currentCount to zero.

Profile: common

 

Inherited Functions