1242 Java Media Framework and Java Sound (on (Domain and web hosting)

1242 Java Media Framework and Java Sound (on CD) Chapter 22 148 149 // create player using media’s location 150 public void makePlayer( String mediaLocation ) 151 { 152 // reset player and window if previous player exists 153 if ( player != null ) 154 removePlayerComponents(); 155 156 // location of media source 157 MediaLocator mediaLocator = 158 new MediaLocator( mediaLocation ); 159 160 if ( mediaLocator == null ) { 161 showErrorMessage( “Error opening file” ); 162 return; 163 } 164 165 // create a player from MediaLocator 166 try { 167 player = Manager.createPlayer( mediaLocator ); 168 169 // register ControllerListener to handle Player events 170 player.addControllerListener( 171 new PlayerEventHandler() ); 172 173 // call realize to enable rendering of player’s media 174 player.realize(); 175 } 176 177 // no player exists or format is unsupported 178 catch ( NoPlayerException noPlayerException ) { 179 noPlayerException.printStackTrace(); 180 } 181 182 // file input error 183 catch ( IOException ioException ) { 184 ioException.printStackTrace(); 185 } 186 187 } // end makePlayer method 188 189 // return player to system resources and 190 // reset media and controls 19 public void removePlayerComponents() 19 { 19 // remove previous video component if there is one 19 if ( visualMedia != null ) 19 container.remove( visualMedia ); 19 19 // remove previous media control if there is one 19 if ( mediaControl != null ) 19 container.remove( mediaControl ); 200 Fig. 22.1 Playing media with interface Player(part 4 of 8) .
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Leave a Reply