private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { openMedia(); } catch (IOException ex) { //Logger.getLogger(SoundBytePlaying.class.getName()).log(Level.SEVERE, null, ex); } } public void openMedia() throws IOException{ JFileChooser fileChooser = new JFileChooser(); int result = fileChooser.showOpenDialog(jButton5); if(result == JFileChooser.APPROVE_OPTION) { URL mediaURL = null; try{ mediaURL = fileChooser.getSelectedFile().toURL(); }catch(MalformedURLException malformedURLException){ JOptionPane.showMessageDialog(null, "Could not create URL for the file"); } if(mediaURL != null){ showVideo(mediaURL); //some error here** System.out.println("camera displaying.."); } } } public void showVideo(URL mediaURL){ Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true ); try{ //create a player to play the media specified in the URL Player mediaPlayer = Manager.createRealizedPlayer( mediaURL ); //get the components for the video and the playback controls Component video = mediaPlayer.getVisualComponent(); Component controls = mediaPlayer.getControlPanelComponent(); if ( video != null ) add( video, BorderLayout.CENTER ); //add video component if ( controls != null ) add( controls, BorderLayout.SOUTH ); //add controls mediaPlayer.start(); //start playing the media clip } //end try catch ( NoPlayerException noPlayerException ){ JOptionPane.showMessageDialog(null, "No media player found"); } //end catch catch (CannotRealizeException ex){ JOptionPane.showMessageDialog(null, "Could not realize media player."); } //end catch catch (IOException iOException ){ JOptionPane.showMessageDialog(null, "Error reading from the source."); } //end catch }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)