Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Media recording properties

When you capture an audio or video recording, or take a picture, you can control the properties of the recording, such as the codecs and bitrates used to encode the data, and control the focus mode.

Codecs and bitrates

You can specify the codec and bitrate used to encode the media that you record. Invoke System.getProperty() to discover which codecs and bitrates a device supports.

// Retrieve the audio codecs and bitrates
String audioCodecs = System.getProperty("audio.encodings.bitrate.ranges");

//Retrieve the video codecs and bitrates
String videoCodecs = System.getProperty("video.encoding.bitrate.ranges");
The System.getProperty() method returns a String that lists the available codecs, and their respective bitrates. The String has the following format:
codec1:[<minBitrate>]-[<maxBitrate>] codec2:[<minBitrate>]-[<maxBitrate>] codec3...

After you decide which codecs to use for your recording, you can specify them in the locator string you use to create a Player object.

You can specify audio and video codecs and bitrates when you record a video. If you want to capture video without audio, specify none in the audio_codec parameter.

Player myPlayer = javax.microedition.media.Manager.createPlayer(
       "capture://video?encoding=video/3gpp&audio_codec=AAC" +
       "&video_codec=H264&rate=32000&video_rate=282000);

If you take a picture, you can omit the audio codec parameters from your locator string.

Player myPlayer = javax.microedition.media.Manager.createPlayer(
       "capture://video?encoding=png&colors=rgb888);

If you create an audio recording, you can omit the video codec parameters from your locator string.

Player myPlayer = javax.microedition.media.Manager.createPlayer(
       "capture://audio?encoding=pcm&rate=11025&bits=16&channels=1);

Using the enhanced focus controls

The net.rim.device.api.amms.control.camera.EnhancedFocusControl interface extends javax.microedition.amms.control.camera.FocusControl to provide more control over camera focus. The available focus modes are:

Mode

Behavior

Fixed

Sets focus to extended depth of field

Singleshot

The focus is computed when the capture requested

Continuous

Focus is computed continuously until capture

To obtain an EnhancedFocusControl object, invoke javax.microedition.media.Player.getControl() on your application's Player object. When you invoke getControl(), you must pass in the fully qualified class name of the control (for example, "net.rim.device.api.amms.control.camera.EnhancedFocusControl").

To set the focus mode, invoke setFocusMode() on the EnhancedFocusControl object and reference the focus mode that you want to set.

//Obtain the control
EnhancedFocusControl efc = (EnhancedFocusControl) myPlayer.getControl(
         "net.rim.device.api.amms.control.camera.EnhancedFocusControl");
 
//Verify that the focus mode is supported by the device.
if( efc.isFocusModeSupported(EnhancedFocusControl.FOCUS_MODE_FIXED))
{
    //Set the focus.

    efc.setFocusMode(EnhancedFocusControl.FOCUS_MODE_FIXED );                        
}
else
{
    Dialog.alert("Focus mode is not supported");
}

Using camera scene modes

The net.rim.device.api.amms.control.camera.FeatureControl interface extends javax.microedition.media.Control to provide predefined scene modes that adjust the camera's white balance, shutter speed, and other properties. The available scene modes are:

Mode

Behavior

Auto

Captures a wide range of subjects under most conditions

Face detection

Detects the faces of subjects and puts them in focus in most lighting conditions

Protrait

Accurately reproduces skin tones

Sport

Captures quickly moving objects

Landscape

Captures bright outdoor scenes

Party

Captures people in dim indoor environments

Macro

Enhances the detail and sharpness of objects close to the camera

Snow

Accurately reproduces colors in scenes with highly reflective surfaces

Beach

Accurately reproduces colors in scenes with high contrast

Night

Captures dim outdoor scenes

Text

Enhances the detail and sharpness of text

To obtain a FeatureControl object, invoke javax.microedition.media.Player.getControl() on your application's Player object. When you invoke getControl(), you must pass in the fully qualified class name of the control (for example, "net.rim.device.api.amms.control.camera.FeatureControl").

To set the scene mode, invoke setSceneMode() on the FeatureControl object and reference the scene mode that you want to set.

// Obtain the control.
FeatureControl featureControl = (FeatureControl) myPlayer.getControl("net.rim.device.api.amms.control.camera.FeatureControl");

// Check for support of face detection mode.
if(featureControl.isSceneModeSupported(FeatureControl.SCENE_MODE_FACEDETECTION))
{
    // Set the scene mode.
    featureControl.setSceneMode(FeatureControl.SCENE_MODE_FACEDETECTION);
}
else
{
    Dialog.alert("Scene mode not supported");
}