Java Reference
In-Depth Information
public void startRecording() {
try {
player = Manager.createPlayer("capture://video");
//set up recording
record = (RecordControl) player.getControl("RecordControl");
conn = (FileConnection), Connector.READ_WRITE);
if (!conn.exists())
stream = conn.openOutputStream();
// Grab the video control and set it to the current display.
control = (VideoControl) player.getControl("VideoControl");
if (control != null) {
control.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
control.setDisplaySize(getWidth(), getHeight());
} player.start();
} catch (Exception e) {
Alert error = new Alert("Error", e.toString(), null, AlertType.ERROR);
The code sets up a Player whose locator is capture://video ,
then proceeds to use the RecordControl ,a FileConnection (JSR-
75) and an output stream to record video from the camera and save it
on the device's permanent storage. This code works well on Symbian OS
devices supporting video recording in Mobile Media API. However, if
any of the operations attempted here is not supported, for example, video
recording on Nokia S60 2nd Edition or Series 40 3rd Edition devices, an
error message is displayed which offers little useful information to the
user. For example, if fetching the video stream from the camera is not
supported, a cryptic message, 'Invalid Locator', is shown. This illustrates
the need to perform all the required run-time checks, when using MMAPI,
and handle errors gracefully. In some cases, the MIDlet may still work
with limited functionality. For a video-recording application, however
this is unlikely.
In our example, we must check for the MMAPI system properties in
Table 9.1 before attempting to record video. Failing gracefully in this
case also means giving the user a readable and self-explanatory error
notification. Our corrected code example would then look like:
public void startRecording() {
if(!System.getProperty("").equals("true")) {
Search WWH ::

Custom Search