×

Discussion Board

Results 1 to 6 of 6

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    53

    Question Video Capturing and Recording

    Hi

    I want to capture and record a video on my nokia n73.and for that i have got one code but when i run this code on my mobile phone it dont work.

    I am submitting my code can some body please tell me what i need to change.

    Thanks

    Vineet


    import java.io.IOException;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.media.control.VideoControl;
    import javax.microedition.media.control.RecordControl;
    import java.io.ByteArrayOutputStream;

    public class VideoMIDlet extends MIDlet implements CommandListener
    {

    private Display display;
    private Form form;
    private Command exit, back, capture, camera,stopRecord,Record;
    private Player player;
    private VideoControl videoControl;
    private Video video;
    private RecordControl rControl = null;
    ByteArrayOutputStream bos = null;
    public VideoMIDlet()
    {

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

    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();
    }
    else if (c == Record)
    {
    try
    {
    RecordControl rControl = (RecordControl)player.getControl("RecordControl");
    if (rControl == null) throw new Exception("No Record control found");
    bos = new ByteArrayOutputStream();
    rControl.setRecordStream(bos);
    rControl.startRecord();
    recording = true;
    }
    catch (Exception ioe) { }
    //catch (MediaException me) { }
    }

    else if (c == stopRecord)
    {
    try
    {
    rControl.stopRecord();
    rControl.commit();
    recording = false;
    }
    catch (IOException ioe) { }
    //catch (MediaException me) { }
    }

    }



    public void showCamera()
    {
    try
    {
    //Form mcanvas = new Form("camera");
    player = Manager.createPlayer("capture://video");
    player.realize();

    VideoControl vc = (VideoControl)player.getControl("VideoControl");
    Canvas canvas = new VideoCanvas(this, videoControl);


    //mcanvas.addCommand(back);
    canvas.addCommand(capture);
    //mcanvas.addCommand(Record);
    //mcanvas.addCommand(stopRecord);
    canvas.setCommandListener(this);
    display.setCurrent(canvas);
    player.start();

    }

    catch (IOException ioe) { }
    catch (MediaException me) { }
    }

    private boolean recording = false;
    class Video extends Thread
    {
    VideoMIDlet midlet;
    public Video(VideoMIDlet midlet)
    {
    this.midlet = midlet;
    }

    public void run()
    {
    captureVideo();

    }
    }


    public void captureVideo()
    {
    try
    {
    byte[] raw = videoControl.getSnapshot(null);
    Image image = Image.createImage(raw, 0, raw.length);
    form.append(image);
    display.setCurrent(form);

    player.close();
    player = null;
    videoControl = null;
    }

    catch (MediaException me) { }
    }

    }

    ****************************************************************

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

    public class VideoCanvas extends Canvas {
    private VideoMIDlet midlet;

    public VideoCanvas(VideoMIDlet 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);
    }
    }
    Last edited by vin7805; 2008-03-17 at 15:22.

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Video Capturing and Recording

    What happens? Exceptions? The program does not start?

    You need to provide more information as we do not have time to build and debug your MIDlet on our devices...

    Hartti

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    53

    Re: Video Capturing and Recording

    Hello Hartti

    I am not getting any exceptions or errors but even than the program is not executing. Its just showing a blank page.

    Kindly check it once..

    Thanks
    Vineet

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Video Capturing and Recording

    You do not even get the Camera command in there?

    Hartti

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Video Capturing and Recording

    Hi,

    Check and go through your code.It is due that your camera is not start yet.Or your camera is not ready to start.Check and debug the code.You can do so by your own.No one have so much time that he /she will make a project ,will compile and then testing.


    make some system.out.println() or put break point out.

    enjoyee
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    53

    Re: Video Capturing and Recording

    Hi Everyone...

    No i am not getting any camera command in my phone.

    I tried to do every thing so far up to my knowledge in j2me But could not get it thats why i need your help and suggestions.

    Can some please tell what i need to change in the following code..

    Sorry for any trouble.


    Thanks

    vineet
    Last edited by vin7805; 2008-03-25 at 09:39.

Similar Threads

  1. Video playback with sound but nothing on Screen
    By abdullah829 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-11-30, 14:04
  2. Video capturing and streaming to a server
    By xarling in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-07-20, 07:42
  3. BUGS?! Identified Video/Audio recording problems on N93
    By arikr7 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-03-19, 19:55
  4. Issues whie video recording in Nokia 7610...
    By Adeesh in forum Series 40 & S60 Platform Feedback Archive
    Replies: 2
    Last Post: 2006-10-25, 06:46
  5. 6600 video recording
    By thiyagups in forum Symbian
    Replies: 0
    Last Post: 2004-09-25, 07:16

Posting Permissions

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