I. Overview
First, let's look at what it takes to construct the media player and determine the target as well as the complexity of the code and the program. The media player in this article has to achieve the following goals:
The media Player is a menu-driven simple AWT application.
The media Player contains a File menu that contains three menu items:
Open to open the media file.
Loop, is played once (the default), or repeatedly played.
Exit, exit the program.
Media players can be run on a variety of platforms.
The core features of the media Player are implemented through the JMF (Java media Framework) API. JMF expands the multimedia capabilities of the J2SE platform, allowing Java applications and applets to intercept, replay, and transform multiple media, including audio and video. JMF supports multiple media formats, see supported Media Formats and Capture Devices.
Second, preliminary design
We have divided the design of this media player into two parts: GUI design, pseudo code design. In GUI design, we want to understand the various GUI parts that make up a program. In pseudo code design, we use natural language to write the principle of program operation.
2.1 GUI Design
The media Player's user interface contains a main window, a menu, and a dialog box that opens the file. First, let's look at the design of the main window. The main window should display the window title as "Media Player 1.0", displaying the "File" menu, which displays "Welcome" information for a colored background. Figure one shows the main window when the program is just started.
Figure I: The main window of the media player
The File menu contains three items. The Open menu displays a dialog box to select the location of the media file. The Loop menu determines whether the media file is played only once (the default) or repeatedly (when the menu is selected). Finally, the Exit menu closes the program. Also, click the Close button in the upper-right corner of the main window to close the program. See figure Two.
Figure II: "File" menu
When you click the file/Open menu, the Open Media File dialog box appears. After selecting the media file, click on the "Open" button to open the media file, click the "Cancel" button to abort the file open operation. As shown in Figure three.
Figure Three: Open Media file dialog box
In addition to the parts mentioned above, the media Player also contains a visual part, a control panel part. The visual part order plays each frame image contained in the media file; The Control Panel widget allows users to pause, start playback of media files, or perform other control actions, such as viewing media file information.