Chapter 22 (Web site developers) Java Media Framework and Java Sound
Chapter 22 Java Media Framework and Java Sound (on CD) 1241 95 String addressName = getMediaLocation(); 96 97 if ( addressName != null ) 98 makePlayer( addressName ); 99 } 100 101 } // end ActionListener 102 103 ); // end call to method addActionListener 104 105 // turn on lightweight rendering on players to enable 106 // better compatibility with lightweight GUI components 107 Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, 108 Boolean.TRUE ); 109 110 } // end SimplePlayer constructor 111 112 // utility method for pop-up error messages 113 public void showErrorMessage( String error ) 114 { 115 JOptionPane.showMessageDialog( this, error, “Error”, 116 JOptionPane.ERROR_MESSAGE ); 117 } 118 119 // get file from computer 120 public File getFile() 121 { 122 JFileChooser fileChooser = new JFileChooser(); 123 124 fileChooser.setFileSelectionMode( 125 JFileChooser.FILES_ONLY ); 126 127 int result = fileChooser.showOpenDialog( this ); 128 129 if ( result == JFileChooser.CANCEL_OPTION ) 130 return null; 131 132 else 133 return fileChooser.getSelectedFile(); 134 } 135 136 // get media location from user input 137 public String getMediaLocation() 138 { 139 String input = JOptionPane.showInputDialog( 140 this, “Enter URL” ); 141 142 // if user presses OK with no input 143 if ( input != null && input.length() == 0 ) 144 return null; 145 146 return input; 147 } Fig. 22.1 Playing media with interface Player(part 3 of
.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.