Estou com o seguinte problema. Tenho um applet que roda no windows XP e quando trocaram o PC aqui do trabalho para o Windows 7 64 bits a mesma parou de funcionar. A imagem da webcam não carrega.
Ocorre o seguinte erro:
Exception on commit = java.lang.SecurityException: commit: Permission denied
java.lang.RuntimeException: No permission to capture from applets
java.lang.RuntimeException: No permission to capture from applets
Estou com o Java Media Framework 2.1.1e e jdk-6u22 instalados.
protectedJLabelstatusBar=null;protectedJPanelvisualContainer=null;publicComponentvisualComponent=null;protectedJToolBartoolbar=null;protectedMyToolBarActionformatButton=null;protectedMyToolBarActioncaptureButton=null;publicPlayerplayer=null;protectedCaptureDeviceInfowebCamDeviceInfo=null;protectedMediaLocatorml=null;protectedDimensionimageSize=null;protectedFormatControlformatControl=null;protectedVideoFormatcurrentFormat=null;protectedFormat[]videoFormats=null;protectedMyVideoFormat[]myFormatList=null;protectedbooleaninitialised=false;publicStringtipo_foto=null;publicStringaction_php=null;publicJAppletmeuap=null;publicJWebCam(StringframeTitle){statusBar=newJLabel("");statusBar.setBorder(newEtchedBorder());}publicbooleaninitialise()throwsException{return(initialise(autoDetect()));}publicbooleaninitialise(CaptureDeviceInfo_deviceInfo)throwsException{statusBar.setText("Initialising...");webCamDeviceInfo=_deviceInfo;if(webCamDeviceInfo!=null){statusBar.setText("Connecting to : "+webCamDeviceInfo.getName());try{setUpToolBar();ml=webCamDeviceInfo.getLocator();if(ml!=null){player=Manager.createRealizedPlayer(ml);if(player!=null){Stringcam=webCamDeviceInfo.getName();videoFormats=webCamDeviceInfo.getFormats();intnum_player=0;for(intcont=0;cont<videoFormats.length;cont++){if(videoFormats[cont].toString().indexOf("640x480")!=-1){num_player=cont;}}formatControl=(FormatControl)player.getControl("javax.media.control.FormatControl");formatControl.setFormat(webCamDeviceInfo.getFormats()[num_player]);player.start();visualComponent=player.getVisualComponent();if(visualComponent!=null){visualComponent.setSize(640,480);myFormatList=newMyVideoFormat[videoFormats.length];for(inti=0;i<videoFormats.length;i++){myFormatList[i]=newMyVideoFormat((VideoFormat)videoFormats[i]);}FormatcurrFormat=formatControl.getFormat();if(currFormatinstanceofVideoFormat){currentFormat=(VideoFormat)currFormat;imageSize=currentFormat.getSize();}return(true);}else{return(false);}}else{statusBar.setText("Cannot create player");return(false);}}else{statusBar.setText("No Media Locator for : "+webCamDeviceInfo.getName());return(false);}}catch(IOExceptionioEx){statusBar.setText("Connecting to : "+webCamDeviceInfo.getName());return(false);}catch(NoPlayerExceptionnpex){statusBar.setText("Cannot create player");playerClose();return(false);}catch(CannotRealizeExceptionnre){statusBar.setText("Cannot realize player");playerClose();return(false);}}else{return(false);}}publicvoidsetFormat(VideoFormatselectedFormat){if(formatControl!=null){player.stop();imageSize=selectedFormat.getSize();formatControl.setFormat(selectedFormat);player.start();statusBar.setText("Format : "+selectedFormat);currentFormat=selectedFormat;visualContainer.setPreferredSize(currentFormat.getSize());setSize(imageSize.width,imageSize.height+statusBar.getHeight()+toolbar.getHeight());}else{statusBar.setText("Visual component cannot change format");}}publicVideoFormatgetFormat(){return(currentFormat);}protectedvoidsetUpToolBar(){toolbar=newJToolBar();formatButton=newMyToolBarAction("Resolution","BtnFormat.jpg");captureButton=newMyToolBarAction("Capture","BtnCapture.jpg");toolbar.add(formatButton);toolbar.add(captureButton);}publicvoidcaptura(){Imagephoto=grabFrameImage();if(photo!=null){MySnapshotsnapshot=newMySnapshot(photo,newDimension(imageSize));}}protectedvoidtoolbarHandler(MyToolBarActionactionBtn){if(actionBtn==formatButton){Objectselected=JOptionPane.showInputDialog(this,"Select Video format","Capture format selection",JOptionPane.INFORMATION_MESSAGE,null,// Icon icon,myFormatList,// videoFormats,currentFormat);if(selected!=null){setFormat(((MyVideoFormat)selected).format);}}elseif(actionBtn==captureButton){Imagephoto=grabFrameImage();if(photo!=null){MySnapshotsnapshot=newMySnapshot(photo,newDimension(imageSize));}}}publicCaptureDeviceInfoautoDetect(){Vectorlist=CaptureDeviceManager.getDeviceList(null);CaptureDeviceInfodevInfo=null;if(list!=null){Stringname;for(inti=0;i<list.size();i++){devInfo=(CaptureDeviceInfo)list.elementAt(i);name=devInfo.getName();if(name.startsWith("vfw:")){break;}}if(devInfo!=null&&devInfo.getName().startsWith("vfw:")){return(devInfo);}else{for(inti=0;i<10;i++){try{name=VFWCapture.capGetDriverDescriptionName(i);if(name!=null&&name.length()>1){devInfo=com.sun.media.protocol.vfw.VFWSourceStream.autoDetect(i);if(devInfo!=null){return(devInfo);}}}catch(ExceptionioEx){statusBar.setText("AutoDetect failed : "+ioEx.getMessage());}}return(null);}}else{return(null);}}publicvoiddeviceInfo(){if(webCamDeviceInfo!=null){Format[]formats=webCamDeviceInfo.getFormats();for(inti=0;i<formats.length;i++){FormataFormat=formats[i];if(aFormatinstanceofVideoFormat){Dimensiondim=((VideoFormat)aFormat).getSize();}}}}publicBuffergrabFrameBuffer(){if(player!=null){FrameGrabbingControlfgc=(FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");if(fgc!=null){return(fgc.grabFrame());}else{return(null);}}else{return(null);}}publicImagegrabFrameImage(){Bufferbuffer=grabFrameBuffer();if(buffer!=null){BufferToImagebtoi=newBufferToImage((VideoFormat)buffer.getFormat());if(btoi!=null){Imageimage=btoi.createImage(buffer);if(image!=null){return(image);}else{return(null);}}else{return(null);}}else{return(null);}}publicvoidplayerClose(){if(player!=null){player.close();}}publicvoidwindowClosing(WindowEvente){System.exit(1);}publicvoidcomponentResized(ComponentEvente){Dimensiondim=getSize();booleanmustResize=false;if(dim.width<MIN_WIDTH){dim.width=MIN_WIDTH;mustResize=true;}if(dim.height<MIN_HEIGHT){dim.height=MIN_HEIGHT;mustResize=true;}if(mustResize)setSize(dim);}publicvoidwindowActivated(WindowEvente){}publicvoidwindowClosed(WindowEvente){}publicvoidwindowDeactivated(WindowEvente){}publicvoidwindowDeiconified(WindowEvente){}publicvoidwindowIconified(WindowEvente){}publicvoidwindowOpened(WindowEvente){}publicvoidcomponentHidden(ComponentEvente){}publicvoidcomponentMoved(ComponentEvente){}publicvoidcomponentShown(ComponentEvente){}protectedvoidfinalize()throwsThrowable{}classMyToolBarActionextendsAbstractAction{publicMyToolBarAction(Stringname,Stringimagefile){super(name);}publicvoidactionPerformed(ActionEventevent){toolbarHandler(this);}};classMyVideoFormat{publicVideoFormatformat;publicMyVideoFormat(VideoFormat_format){format=_format;}publicStringtoString(){Dimensiondim=format.getSize();return(format.getEncoding()+" [ "+dim.width+" x "+dim.height+" ]");}};classMySnapshotextendsJFrame{protectedImagephoto=null;protectedintshotNumber;publicMySnapshot(ImagegrabbedFrame,DimensionimageSize){shotNumber=shotCounter++;photo=grabbedFrame;intimageHeight=photo.getWidth(this);intimageWidth=photo.getHeight(this);setSize(imageSize.width,imageSize.height);finalFileDialogsaveDialog=newFileDialog(this,"Save JPEG",FileDialog.SAVE);finalJFramethisCopy=this;saveDialog.setFile("Photo"+shotNumber);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){}});setVisible(true);inti=JOptionPane.showConfirmDialog(null,"Deseja salvar a foto?","Salvar Foto",2);if(i==0){try{httpConncon=newhttpConn();con.SendImage(photo,action_php);AppletContextbrowser=meuap.getAppletContext();browser.showDocument(newURL("javascript:rodarAjax();"));this.setVisible(false);}catch(MalformedURLExceptionex){Logger.getLogger(JWebCam.class.getName()).log(Level.SEVERE,null,ex);}}elseif(i==2){this.setVisible(false);}}publicvoidpaint(Graphicsg){g.drawImage(photo,0,0,getWidth(),getHeight(),this);}publicbooleansaveJPEG(Stringfilename){booleansaved=false;BufferedImagebi=newBufferedImage(photo.getWidth(null),photo.getHeight(null),BufferedImage.TYPE_INT_RGB);Graphics2Dg2=bi.createGraphics();g2.drawImage(photo,null,null);FileOutputStreamout=null;try{out=newFileOutputStream(filename);JPEGImageEncoderencoder=JPEGCodec.createJPEGEncoder(out);JPEGEncodeParamparam=encoder.getDefaultJPEGEncodeParam(bi);param.setQuality(1.0f,false);// 100% high quality setting, no compressionencoder.setJPEGEncodeParam(param);encoder.encode(bi);out.close();saved=true;}catch(Exceptionex){}return(saved);}}// of MySnapshot
}
V
vitoreal
Flex é a parada !!! Resolvido.
L
leopoldof
Também estou tentando rodar uma câmera pelo windows 7 com jmf e não tem jeito…