Hello all,
here is a problem that does not let me sleep at nights...!!!!!!!!!
I have video object to which I attached netstraem object .. I have to click a button and gram a snapshot .. with web cam all work fine , but no luck with netstream.. what to do , please suggest something ... I've got anxious to surf the web here is my code
as3
private function snapshotHandler(event:MouseEvent):void{
var bitmapData:BitmapData=new BitmapData(SNAPSHOT_WIDTH, SNAPSHOT_HEIGHT);
var bitmap:Bitmap=new Bitmap(bitmapData);
bitmapData.draw(incoming.getDisplay());
var jpegEncoder:JPGEncoder=new JPGEncoder(75);
jpegBytes=jpegEncoder.encode(bitmapData);
//this is excact byte amount of empty video display
if(jpegBytes.length==11951){
Alert.show("You have no access to take a snapshot");
return;
}
Alert.show("Shnapshot has been grabbed");
red5Conn.call("createFile", responder,jpegBytes);
}
and here is my red5/java code
public String createFile(ByteArray jpegByteArray){
byte [] byteArray=new byte[jpegByteArray.length()];
jpegByteArray.readBytes(byteArray);
if(jpegByteArray.length()==0){
return "jpegByteArray is empty";
}if(byteArray.length==0){
return "byteArray is empty";
}else{
try{
ByteArrayInputStream byteArrayInputStream=new ByteArrayInputStream(byteArray);
BufferedImage bufferedImage=ImageIO.read(byteArrayInputStream);
String fileName="popoloz.jpg";
if(bufferedImage!=null){
ImageIO.write(bufferedImage,"JPEG",new File(fileName));
}else{
return "bufferedImage is null";
}
}catch (Exception e) {
return "ecxeption occured";
}
}
return "default return";
}