Java Reference
In-Depth Information
} catch (Exception e) {}
finally {
if (c != null) {
try {
c.close();
} catch (IOException e) {}
}
}
}
…other fields and other methods remain the same from Chapter 14…
}
Note The implementation in Listing 16-18 assumes that the image that the VideoControl returns is a
PNG image; if you're writing this for a production application, you should extend MMSSender to accept the
MIME type of the image data you're providing, as well as specify a specific MIME type for the getSnapshot
method.
Playing SVG Content
Returning to the MultimediaMIDlet , the flow for playing SVG content is similar. The
playFromResource method invokes initSvgPlayer and configViewSvg and then starts the
playback using the resulting svgAnimator 's play method. Because the SVGAPI's approach
to media rendering is a little different than the MMAPI, the flow in initSvgPlayer is differ-
ent, although configViewSvg remains an empty method, just as configViewSound is. The
initSvgPlayer method bears a strong resemblance to the pseudocode you first saw in
Listing 16-12.
The initSvgPlayer method begins by getting an InputStream instance to the SVG
image in the JAR file, and then creates a new SVGImage instance using that data and
the default SVGAPI ExternalResourceHandler . With the image, the method next creates
the svgAnimator it will use to play the animation; if the SVG is a static image, that's OK,
because it'll just be rendered by the svgAnimator instance when playFromResource
invokes svgAnimator.play . Using the svgAnimator , the initSvgPlayer gets an instance
of the SVGAnimator 's Canvas instance, which it sets aside as the Displayable that the
MIDlet should show when playFromResource sets the next Displayable . Finally, this
method obtains the default bounds for the svgCanvas and uses them to initialize the
svgImage 's viewport to obtain and set the optimum rendering rectangle for the image
on the display.
 
Search WWH ::




Custom Search