Java Reference
In-Depth Information
✓
✓
16.37
When the game starts, what value is in
whoseTurn
? When the game is over, what
value is in
whoseTurn
?
Check
Point
16.38
What happens when the user clicks on an empty cell if the game is not over? What
happens when the user clicks on an empty cell if the game is over?
16.39
How does the program check whether a player wins? How does the program check
whether all cells are filled?
You can use the
Media
class to obtain the source of the media, the
MediaPlayer
class to play and control the media, and the
MediaView
class to display the video.
Key
Point
Media (video and audio) is essential in developing rich Internet applications. JavaFX provides
the
Media
,
MediaPlayer
, and
MediaView
classes for working with media. Currently, JavaFX
supports MP3, AIFF, WAV, and MPEG-4 audio formats and FLV and MPEG-4 video formats.
The
Media
class represents a media source with properties
duration
,
width
, and
height
,
as shown in Figure 16.30. You can construct a
Media
object from an Internet URL string.
VideoNote
Use Media, MediaPlayer,
and MediaView
The getter and setter methods for property
values and a getter for property itself are provided
in the class, but omitted in the UML diagram for brevity.
javafx.scene.media.Media
-duration: ReadOnlyObjectProperty
<Duration>
-width: ReadOnlyIntegerProperty
-height: ReadOnlyIntegerProperty
The durations in seconds of the source media.
The width in pixels of the source video.
The height in pixels of the source video.
+Media(source: String)
Creates a
Media
from a URL source.
F
IGURE
16.30
Media
represents a media source such as a video or an audio.
The
MediaPlayer
class plays and controls the media with properties such as
autoPlay
,
currentCount
,
cycleCount
,
mute
,
volume
, and
totalDuration
, as shown in Figure 16.31.
You can construct a
MediaPlayer
object from a media and use the
pause()
and
play()
method to pause and resume playing.
The getter and setter methods for property
values and a getter for property itself are provided
in the class, but omitted in the UML diagram for brevity.
javafx.scene.media.MediaPlayer
-autoPlay: BooleanProperty
-currentCount: ReadOnlyIntegerProperty
-cycleCount: IntegerProperty
-mute: BooleanProperty
-volume: DoubleProperty
-totalDuration:
ReadOnlyObjectProperty<Duration>
Specifies whether the playing should start automatically.
The number of completed playback cycles.
Specifies the number of time the media will be played.
Specifies whether the audio is muted.
The volume for the audio.
The amount of time to play the media from start to finish.
+MediaPlayer(media: Media)
+play(): void
+pause(): void
+seek(): void
Creates a player for a specified media.
Plays the media.
Pauses the media.
Seeks the player to a new playback time.
F
IGURE
16.31
MediaPlayer
plays and controls a media.
Search WWH ::
Custom Search