×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    17

    Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    hi everyone,

    I have developed Voice Recording and Photo Capture midlets for my Project..
    The Voice recording Midlet is running fine in my emulator.. But When i run in my mobile(Nokia 6330), that app does not running..While I click the APP icon, it shows Invalid Application and asking the option for delete.,,The Same problem occurs in photo capture apps too..

    Could Anyone tell me How do i solve the above problem.,,

    Regards,
    Thambirajan

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    Check the MIDP and CLDC version of your app, see to it that MIDP version is set to 2.0
    You might have created the build with MIDP 2.1
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    17

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    Yes, I have created using MIDP 2.1,,


    Thanks Mr.Amitabh.,, I'll try and post my result.,

  4. #4
    Registered User
    Join Date
    Aug 2010
    Posts
    17

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    Mr Amitabh ji, Now it's working.. but when i press the capture button on my mobile, It doesn't take capture... It means, that command is not working.,,

    could you help me.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Location
    India
    Posts
    37

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    exactly what code you are using for initialising camera??

  6. #6
    Registered User
    Join Date
    Aug 2010
    Posts
    17

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    Hi, guys.,

    Now both codes are working.. this is my actual code for photo snap.,, It is executed in nokia 6330..

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import javax.microedition.io.Connection;
    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.media.control.VideoControl;
    import javax.microedition.rms.RecordStore;
    import javax.microedition.rms.RecordStoreException;

    public class CameraMIDlet extends MIDlet implements CommandListener {

    private Display display;
    private Form form;
    private Command exit, back, capture, camera;
    private Player player;
    private VideoControl videoControl;
    private Video video;
    private Image image;
    byte[] buffer;
    private Alert alert;

    public CameraMIDlet() {

    exit = new Command("Exit", Command.EXIT, 0);
    camera = new Command("Camera", Command.SCREEN, 0);
    back = new Command("Back", Command.BACK, 0);
    capture = new Command("Capture", Command.SCREEN, 0);

    form = new Form("Capture Video");
    form.addCommand(camera);
    form.setCommandListener(this);
    }

    public void startApp() {
    display = Display.getDisplay(this);
    display.setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable s) {
    if (c == exit) {
    destroyApp(true);
    notifyDestroyed();
    } else if (c == camera) {
    showCamera();
    } else if (c == back) {
    display.setCurrent(form);
    } else if (c == capture) {
    video = new Video(this);
    video.start();
    }
    }

    public void showCamera() {
    try {
    player = Manager.createPlayer("capture://image"); // "capture://image" is used for 40 devices
    //player = Manager.createPlayer("capture://image"); // "capture://video" is used for Series S60devices
    player.realize();

    videoControl = (VideoControl) player.getControl("VideoControl");
    Canvas canvas = new VideoCanvas(this, videoControl);
    canvas.addCommand(back);
    canvas.addCommand(capture);
    canvas.setCommandListener(this);
    display.setCurrent(canvas);
    player.start();
    } catch (IOException ioe) {
    } catch (MediaException me) {
    }
    }

    class Video extends Thread {

    CameraMIDlet midlet;

    public Video(CameraMIDlet midlet) {
    this.midlet = midlet;
    }

    public void run() {
    captureVideo();

    }

    public void captureVideo() {
    try {
    byte[] raw = videoControl.getSnapshot("encoding=jpg");
    image = Image.createImage(raw, 0, raw.length);
    buffer = raw;
    form.append(image);
    display.setCurrent(form);
    saveToFile();
    player.close();
    player = null;
    videoControl = null;
    } catch (MediaException me) {
    }
    }
    };

    void saveToFile() {
    try {
    FileConnection fc = (FileConnection) Connector.open("file://E:/Images/images.jpg");
    if (!fc.exists()) {
    fc.create();
    alert = new Alert("Alert", "File Created", null, AlertType.ALARM);
    alert.setTimeout(1000);
    //display.setCurrent(alert);
    }
    OutputStream output = fc.openOutputStream();
    output.write(buffer);

    } catch (Exception e) {
    alert = new Alert("Alert",e.toString(), null, AlertType.ERROR);
    alert.setTimeout(1000);
    display.setCurrent(alert);
    }
    }
    }


    import javax.microedition.lcdui.*;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.control.VideoControl;

    public class VideoCanvas extends Canvas {
    private CameraMIDlet midlet;

    public VideoCanvas(CameraMIDlet midlet, VideoControl videoControl) {
    int width = getWidth();
    int height = getHeight();
    this.midlet = midlet;

    videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
    try {
    videoControl.setDisplayLocation(2, 2);
    videoControl.setDisplaySize(width - 4, height - 4);
    } catch (MediaException me) {}
    videoControl.setVisible(true);
    }

    public void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();

    g.setColor(0x00ff00);
    g.drawRect(0, 0, width - 1, height - 1);
    g.drawRect(1, 1, width - 3, height - 3);
    }
    }

    And this is the code for Recording sound and store that sound in Memory card with .amr format:::::


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package hello;

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.media.Manager;
    import javax.microedition.media.Player;
    import javax.microedition.media.control.RecordControl;
    import javax.microedition.midlet.*;

    /**
    * @author krishnan
    */
    public class VoiceRecorderMidlet extends MIDlet {
    Display display;
    public void startApp() {
    display = Display.getDisplay(this);
    display.setCurrent(new VoiceRecordForm());
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
    }

    class VoiceRecordForm extends Form implements CommandListener{

    private StringItem message;
    private StringItem errormessage;
    private Command record, play;
    private Player player;
    private byte[] recordedAudioArray = null;


    public VoiceRecordForm(){
    super("Recording Audio");
    message= new StringItem("", "Select Record to Start recording.");
    this.append(message);
    errormessage = new StringItem("", "");
    this.append(errormessage);
    record = new Command("Record", Command.OK, 0);
    this.addCommand(record);
    this.setCommandListener(this);
    }
    public void commandAction(Command c, Displayable d) {
    if( c == record )
    {
    Thread t = new Thread(){
    public void run() {
    try{


    player = Manager.createPlayer("capture://audio");
    player.realize();
    RecordControl rc = (RecordControl) player.getControl("RecordControl");

    FileConnection fc = (FileConnection) Connector.open("file://E:/Audio/record1.amr", Connector.READ_WRITE);
    if(!fc.exists())
    {
    fc.create();
    }
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    rc.setRecordStream(fc.openOutputStream());
    rc.startRecord();
    player.start();
    message.setText("Recording...");
    Thread.sleep(5000);
    message.setText("Recording Done!");
    rc.commit();
    player.close();

    }
    catch(Exception e){
    System.out.println("Exception while: "+e);
    errormessage.setLabel("Error");
    errormessage.setText(e.toString());
    }
    }
    };
    t.start();
    }
    }
    }


    I hope these ll use for some one...

    Thanks & Regards,
    Thambirajan.A

  7. #7
    Registered User
    Join Date
    Aug 2010
    Posts
    17

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    voice Recording is working.. this is the actual code

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package hello;

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.media.Manager;
    import javax.microedition.media.Player;
    import javax.microedition.media.control.RecordControl;
    import javax.microedition.midlet.*;

    /**
    * @author krishnan
    */
    public class VoiceRecorderMidlet extends MIDlet {
    Display display;
    public void startApp() {
    display = Display.getDisplay(this);
    display.setCurrent(new VoiceRecordForm());
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
    }

    class VoiceRecordForm extends Form implements CommandListener{

    private StringItem message;
    private StringItem errormessage;
    private Command record, play;
    private Player player;
    private byte[] recordedAudioArray = null;


    public VoiceRecordForm(){
    super("Recording Audio");
    message= new StringItem("", "Select Record to Start recording.");
    this.append(message);
    errormessage = new StringItem("", "");
    this.append(errormessage);
    record = new Command("Record", Command.OK, 0);
    this.addCommand(record);
    this.setCommandListener(this);
    }
    public void commandAction(Command c, Displayable d) {
    if( c == record )
    {
    Thread t = new Thread(){
    public void run() {
    try{


    player = Manager.createPlayer("capture://audio");
    player.realize();
    RecordControl rc = (RecordControl) player.getControl("RecordControl");

    FileConnection fc = (FileConnection) Connector.open("file://E:/Audio/record1.amr", Connector.READ_WRITE);
    if(!fc.exists())
    {
    fc.create();
    }
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    rc.setRecordStream(fc.openOutputStream());
    rc.startRecord();
    player.start();
    message.setText("Recording...");
    Thread.sleep(5000);
    message.setText("Recording Done!");
    rc.commit();
    player.close();

    }
    catch(Exception e){
    System.out.println("Exception while: "+e);
    errormessage.setLabel("Error");
    errormessage.setText(e.toString());
    }
    }
    };
    t.start();
    }
    }
    }

  8. #8
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    Instead of byte[] raw = videoControl.getSnapshot("encoding=jpg");
    try using byte[] raw = videoControl.getSnapshot(null);

    It will give you PNG format and will be supported by most of the devices, JPG Capture might not be supported by all the devices.
    Thanks,
    Ekta

  9. #9
    Registered User
    Join Date
    Jan 2010
    Location
    India
    Posts
    37

    Re: Problem in Voice Recording & photo Capture Midlets for Nokia 6330

    byte[] raw = videoControl.getSnapshot(null);

    this will give default size and quality image which is depended on every mobile and
    in S40 it is not giving good quality output so it is better to use JPG format if your mobile is suported...

Similar Threads

  1. At&T USA Nokia 6555 and 6126 video recording problem
    By vijaypatidar in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-06-30, 23:46
  2. Voice Capture without Recording
    By Aliencse in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-04-25, 06:08
  3. problem of voice recording in NOKIA N70
    By adiilah in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2008-03-13, 07:50
  4. Voice Recording Problem
    By irshad201 in forum Mobile Java General
    Replies: 3
    Last Post: 2007-10-31, 11:48
  5. i got a problem with capture voice with 7610
    By ononokung in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2004-09-30, 05:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •