Chapter 22 (Web hosting domain) Java Media Framework and Java Sound

Chapter 22 Java Media Framework and Java Sound (on CD) 1247 is one) using lightweight renderers so that the media player will look like other GUIs with Swing components. By default, Player s video components are heavyweight components, which may not display correctly when mixed with lightweight Swing GUI components. Before playing the media, SimplePlayer displays an initial GUI consisting of two buttons, Open File and Open Locator, that enable users to specify the media location. The event handlers for these two buttons (lines 52 78 and lines 90 101) perform similar functions. Each button prompts users for a media resource such as an audio or video clip, then creates a Player for the specified media. When the user clicks Open File, line 57 calls method getFile (lines 120 134) to prompt users to select a media file from the local computer. Line 63 calls the File method toURL to obtain a URL representation of the selected file s name and location. Line 72 calls SimplePlayer method makePlayer (lines 150 187) to create a Playerfor the user-selected media. When users click Open Locator, line 95 invokes method getMediaLocation (lines 137 147), prompting users to input a String giving the media location. Line 98 calls SimplePlayer method makePlayer to create a Player for the media at the specified location. Method makePlayer (lines 150 187) makes the necessary preparations to create a Player of media clips. The String argument indicates the media s location. Lines 153 154 invoke SimplePlayer method removePlayerComponents (lines 191 203) to remove the previous Player s visual component and GUI controls from the frame before creating a new Player. Line 202 invokes Player method close to stop all player activity and to release system resources held by the previous Player. Method makePlayer requires a pointer to the source from which the media is retrieved, which is accomplished by instantiating a new MediaLocator for the value given by the String argument (lines 157 158). A MediaLocator specifies the location of a media source, much like a URL typically specifies the location of a Web page. A MediaLocator can access media from capture devices and RTP sessions as well as from file locations. The MediaLocator constructor requires the media s location as a String, so all URLs must be converted to Strings as in line 72. Method makePlayer instantiates a new Player with a call to Manager method createPlayer. Class Manager provides static methods that enable programs to access most JMF resources. Method createPlayer opens the specified media source and determines the appropriate Player for the media source. Method createPlayer throws a NoPlayerException if an appropriate Player cannot be found for the media clip. An IOException is thrown if there are problems connecting to the media source. ControllerListeners listen for the ControllerEvents that Players generate to track the progress of a Player in the media-handling process. Lines 170 171 register an instance of inner class PlayerEventHandler (lines 225 255) to listen for certain events that player generates. Class PlayerEventHandler extends class ControllerAdapter, which provides empty implementations of methods from interface ControllerListener. Class ControllerAdapter facilitates implementing ControllerListener for classes that need to handle only a few Controller- Event types. Players confirm their progress while the processing media based on their state transitions. Line 174 invokes Player method realize to confirm all resources necessary to play media are available. Method realize places the Player in the Realizing state to indicate that it is connecting to and interacting with its media sources. When a Player
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Leave a Reply