Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor austin007's Avatar
    Join Date
    Mar 2008
    Posts
    133
    Nowadays, we should espicially talk about JSR234 (Advanced Multimedia API). Because it allows to you more controls on device’s camera, radio,etc. But currently there are a few phones those are integrated JSR234. (For e.g. Sony Ericsson K800i) But there is no Nokia phones.

    First of all, we have to be sure that our device supports camera encodings.
    For check this use below code.


    private String[] capabilitiesIdx = {
    “supports.audio.capture”,
    “supports.video.capture”,
    “supports.recording”,
    “audio.encodings”,
    “video.encodings”,
    “video.snapshot.encodings”, // “streamable.contents”
    };
    StringItem[] str = new StringItem[capabilitiesIdx.length];
    for (int i = 0; i < capabilitiesIdx.length; ++i) {
    str[i] = new StringItem(System.getProperty(capabilitiesIdx[i]), “-” + capabilitiesIdx[i]);
    }

    if your phone supports video capture now you can control your camera.

    Initiliaze Camera
    try {
    //creates a new player and set it to realize
    player = Manager.createPlayer("capture://video");
    player.realize();
    //Grap the Video control and set it to the current display
    videoControl = (VideoControl) (player.getControl("VideoControl"));
    if (videoControl != null) {
    append((Item) (videoControl.initDisplayMode(
    VideoControl.USE_GUI_PRIMITIVE, null)));
    captureCommand = new Command("Çek", Command.SCREEN, 1);
    addCommand(captureCommand);
    } else {
    messageItem.setText("No video control");
    }
    } catch (IOException ioe) {
    messageItem.setText("IOException: " + ioe.getMessage());
    } catch (MediaException me) {
    messageItem.setText("Media Exception: " + me.getMessage());
    } catch (SecurityException se) {
    messageItem.setText("Security Exception: " + se.getMessage());
    }

    Start Camera

    try {
    if (player != null) {
    player.start();
    }
    if (videoControl != null) {
    videoControl.setVisible(true);
    }
    } catch (MediaException me) {
    messageItem.setText("Media Exception: " + me.getMessage());
    } catch (SecurityException se) {
    messageItem.setText("Security Exception: " + se.getMessage());
    }
    active = true;

    Get SnapShot
    try {
    image = videoControl.getSnapshot("encoding=jpeg&width=640&height=480");
    } catch (MediaException me) { //yüksek çözünürlük destekle
    check = false;
    }
    if(!check){//hata varsa
    image = videoControl.getSnapshot("encoding=png");
    }

    Stop Camera
    try {
    if (videoControl != null) {
    videoControl.setVisible(false);
    }
    if (player != null) {
    player.stop();
    player.close();
    }
    } catch (MediaException me) {
    messageItem.setText("Media Exception: " + me.getMessage());
    }

  2. #2
    Nokia Developer Moderator ltomuta's Avatar
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,335
    Quote Originally Posted by austin007 View Post
    Nowadays, we should espicially talk about JSR234 (Advanced Multimedia API). Because it allows to you more controls on device’s camera, radio,etc. But currently there are a few phones those are integrated JSR234. (For e.g. Sony Ericsson K800i) But there is no Nokia phones.
    According to http://library.forum.nokia.com/topic...4FB5D741B.html the JSR and its camera capabilities are supported by Series 40 6th Edition devices.

    Quote Originally Posted by austin007 View Post
    First of all, we have to be sure that our device supports camera encodings.
    For check this use below code.


    Code:
    private String[] capabilitiesIdx = {
    “supports.audio.capture”,
    “supports.video.capture”,
    “supports.recording”,
    “audio.encodings”,
    “video.encodings”,
    “video.snapshot.encodings”, //  “streamable.contents”
    };
    StringItem[] str = new StringItem[capabilitiesIdx.length];
    for (int i = 0; i < capabilitiesIdx.length; ++i) {
    str[i] = new StringItem(System.getProperty(capabilitiesIdx[i]), “-” + capabilitiesIdx[i]);
    }
    if your phone supports video capture now you can control your camera.

    Initiliaze Camera
    Code:
    try {
    //creates a new player and set it to realize
    player = Manager.createPlayer("capture://video");
    player.realize();
    //Grap the Video control and set it to the current display
    videoControl = (VideoControl) (player.getControl("VideoControl"));
    if (videoControl != null) {
    append((Item) (videoControl.initDisplayMode(
    VideoControl.USE_GUI_PRIMITIVE, null)));
    captureCommand = new Command("Çek", Command.SCREEN, 1);
    addCommand(captureCommand);
    } else {
    messageItem.setText("No video control");
    }
    } catch (IOException ioe) {
    messageItem.setText("IOException: " + ioe.getMessage());
    } catch (MediaException me) {
    messageItem.setText("Media Exception: " + me.getMessage());
    } catch (SecurityException se) {
    messageItem.setText("Security Exception: " + se.getMessage());
    }
    Start Camera

    Code:
    try {
    if (player != null) {
    player.start();
    }
    if (videoControl != null) {
    videoControl.setVisible(true);
    }
    } catch (MediaException me) {
    messageItem.setText("Media Exception: " + me.getMessage());
    } catch (SecurityException se) {
    messageItem.setText("Security Exception: " + se.getMessage());
    }
    active = true;
    Get SnapShot
    Code:
    try {
    image = videoControl.getSnapshot("encoding=jpeg&width=640&height=480");
    } catch (MediaException me) { //yüksek çözünürlük destekle
    check = false;
    }
    if(!check){//hata varsa
    image = videoControl.getSnapshot("encoding=png");
    }
    Stop Camera
    Code:
    try {
    if (videoControl != null) {
    videoControl.setVisible(false);
    }
    if (player != null) {
    player.stop();
    player.close();
    }
    } catch (MediaException me) {
    messageItem.setText("Media Exception: " + me.getMessage());
    }
    This looks like a nice tutorial, but its place is in the Wiki. Maybe expanding the How to take snapshot using JSR234 article.

  3. #3
    Registered User vaisakh31's Avatar
    Join Date
    Jan 2012
    Posts
    1
    hi,
    i have a problem when i'm trying to take photos continuously, the code is same and Err shows 'Out of Memory Error java/lang/OutOfMemoryError nativeDecodeImage'.

    if you have any suggestions plz replay....

    tanks,

  4. #4
    Nokia Developer Moderator r2j7's Avatar
    Join Date
    Aug 2007
    Posts
    1,595
    Hello vaisakh31,

    and welcome to Nokia Developer Discussion Boards!

    Couple of startup questions:

    -which device do you use for testing?

    -could you provide your source code for review?

    Regards,
    r2j7

Similar Threads

  1. Using Camera Light While Taking Photo Using J2ME
    By sprateek in forum Mobile Java General
    Replies: 2
    Last Post: 2011-04-26, 11:27
  2. Security/spy phone camera
    By ashraflatif in forum Python
    Replies: 3
    Last Post: 2008-12-30, 08:52
  3. Bluetooth GPS simulator for j2me phone
    By vgps in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2007-02-09, 04:30
  4. Nokia 6103 J2ME application crash - reboot phone
    By gpeschiera in forum Mobile Java General
    Replies: 6
    Last Post: 2007-01-10, 01:08
  5. taking pictures in mobile phones with digital cameras through J2ME
    By pedrosalazar in forum Mobile Java General
    Replies: 1
    Last Post: 2002-12-02, 09:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved