Java Reference
In-Depth Information
Figure 8.6
Video Play and Player Controls
The left button toggles the play of the media. If the player is stopped or paused,
play begins. If the player is running, play is paused. The next button stops the
play and resets the media back to the beginning. The third control mutes the
sound. These are followed with the volume, balance, and fade controls.
The first three controls are rather simple to implement. For the first one, if the
player is stopped or paused, invoke the play function on the media player. Other-
wise, invoke the pause function. The next button merely invokes the stop func-
tion. The third control just toggles the media player's mute variable. Listing 8.11
contains the code snippet with only the media player interaction shown.
Listing 8.11
Media Control
var playing =
bind mediaControl.player.status == MediaPlayer.PLAYING
on replace {
currentPlayShape = if(playing) parallelBars
else rightArrow;
};
ControlButton {
id: " play "
centerShape: bind currentPlayShape
action: function () {
if(playing) {
mediaControl.player.pause();
}else {
mediaControl.player.play();
}
}
},
ControlButton {
id: " stop "
action: function () {
mediaControl.player.stop();
}
},
ControlButton {
id: " mute "
action: function () {
mediaControl.player.mute =
not mediaControl.player.mute;
Search WWH ::




Custom Search