Building your own media player with Java

Source: Internet
Author: User
Tags exit

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.