Java Reference
In-Depth Information
Ta b l e 8 . 4
Supported Video Codecs (
Continued
)
Windows
XP
Windows
Vista
MacOS
10.4+
Linux/
Solaris
Codec
H264
X
X
X
H.261, H.263
X
MPEG-1
X
MPEG-2
X
MPEG-4
X
Sorenson Video 2 and 3
X
To develop a media application, you must first create a
javafx.scene.media
.Media
object with the URL
source
that points to the location of the audio or
video data. The
onError
function is called if a media error is encountered. These
errors might include media that cannot be located or the media format is unsup-
ported on the platform.
var media = Media {
onError
: function(e:MediaError) {
println("got a media error {e}");
}
source
:
"http://www.nps.gov/cany/planyourvisit/upload/ClipOne.wmv"
};
After the media object is created, you can query it for certain information. The
duration
specifies the total time for playing the media. The
height
and
width
may tell you the resolution of video media unless it cannot be determined, for
example if it is a streaming source or is only audio. The variable
metadata
holds
any information about the media, such as title and artist. The actual information
varies depending on the media handler.
Next, you need to create a
javafx.scene.media.MediaPlayer
object. Note that
the
MediaPlayer
has no visual capability, and you need other scene graph nodes
for the user to control the play. Listing 8.5 shows how to create a
MediaPlayer
.
Search WWH ::
Custom Search