Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   General Computer Support (http://www.velocityreviews.com/forums/f44-general-computer-support.html)
-   -   videoControl return null while trying to record video (http://www.velocityreviews.com/forums/t598398-videocontrol-return-null-while-trying-to-record-video.html)

aaozgull 03-13-2008 09:42 AM

RecordControl return null while trying to record video
 
can any body help me in my problem.I m trying to capture the video and wanna record it. it capture well but when i try for record. RecordControl returns null.


private void showCamera() {

try {

releaseResources();
player = Manager.createPlayer("capture://video");
player.addPlayerListener(this);
player.realize();

videoControl = (VideoControl)player.getControl("VideoControl");

aVideoCanvas = new VideoCanvas();
videoControl.setVisible(true);
aVideoCanvas.initControls(videoControl, player);


aVideoCanvas.addCommand(CMD_BACK);
aVideoCanvas.addCommand(CMD_EXIT);
aVideoCanvas.setCommandListener(this);
parentMidlet.getDisplay().setCurrent(aVideoCanvas) ;

player.start();
contentType = player.getContentType();




}catch(Exception e) {
e.printStackTrace();

}
}

private void releaseResources() {
if ( player != null ) {
try {
player.stop();
player.close();
}catch(Exception e){}
}
}

class CameraThread extends Thread {

public CameraThread() {
}

public void run() {
showCamera();
}
}

class VideoRecordingThread extends Thread {

public VideoRecordingThread() {
}

public void run() {
recordVideo();
}

public void recordVideo(){
try {

rc = (RecordControl)(player.getControl("RecordControl") );

if ( rc == null ) {
System.out.println("NULL RECORD CONTROL");
return;
}
output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();

}
catch (Exception e) {
}
}


thanx in advance

Anna nguyen 04-28-2011 01:17 PM

Quote:

Originally Posted by aaozgull (Post 3478257)
can any body help me in my problem.I m trying to capture the video and wanna record it. it capture well but when i try for record. RecordControl returns null.


private void showCamera() {

try {

releaseResources();
player = Manager.createPlayer("capture://video");
player.addPlayerListener(this);
player.realize();

videoControl = (VideoControl)player.getControl("VideoControl");

aVideoCanvas = new VideoCanvas();
videoControl.setVisible(true);
aVideoCanvas.initControls(videoControl, player);


aVideoCanvas.addCommand(CMD_BACK);
aVideoCanvas.addCommand(CMD_EXIT);
aVideoCanvas.setCommandListener(this);
parentMidlet.getDisplay().setCurrent(aVideoCanvas) ;

player.start();
contentType = player.getContentType();




}catch(Exception e) {
e.printStackTrace();

}
}

private void releaseResources() {
if ( player != null ) {
try {
player.stop();
player.close();
}catch(Exception e){}
}
}

class CameraThread extends Thread {

public CameraThread() {
}

public void run() {
showCamera();
}
}

class VideoRecordingThread extends Thread {

public VideoRecordingThread() {
}

public void run() {
recordVideo();
}

public void recordVideo(){
try {

rc = (RecordControl)(player.getControl("RecordControl") );

if ( rc == null ) {
System.out.println("NULL RECORD CONTROL");
return;
}
output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();

}
catch (Exception e) {
}
}


thanx in advance

HI aaozgull
I m trying a Videorecoder code, but it also returns null as you.i don't know why? if you have answering, please to send email for me, thanks
email:ngoc.coltech@gmail.com

public void startRecording() {
videoPath = PATH + getFileName();
System.err.println(videoPath);
try {
player = Manager.createPlayer("capture://video");
player.addPlayerListener(this);
player.realize();

//setup recording
record = (RecordControl)player.getControl("RecordControl");
record.setRecordSizeLimit(300000);
conn = (FileConnection)Connector.open(videoPath,Connector .READ_WRITE);
if(!conn.exists()) conn.create();
stream = conn.openOutputStream();
record.setRecordStream(stream);

// Grab the video control and set it to the current display.
control = (VideoControl)player.getControl("VideoControl");
if (control != null) {
control.initDisplayMode(VideoControl.USE_DIRECT_VI DEO,this);
control.setDisplaySize(getWidth(),getHeight());
control.setVisible(true);
}

player.start();
record.startRecord();
}
catch(Exception e) {
Alert erro = new Alert("Erro",e.toString(),null,AlertType.ERROR);
Display.getDisplay(midlet).setCurrent(erro);
e.printStackTrace();
}
}


All times are GMT. The time now is 01:21 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.