JMF environment Configuration

Source: Internet
Author: User

I. JMF installation and environment Configuration:
Build a JMF running platform (eclipse)

If you want to use the JMF function, you must install Sun's JDK and JMF (java media framework). The download and installation sections are described in detail below. For personal reasons, I prefer to use eclipse as a development platform, so here I only write the method for configuring JMF in eclipse. For other environments, such as JBuilder and jcreator, netbeans can be used to develop JMF. You only need to add the jar package to the library of the integrated development environment.
1. install and configure JDK
Go to Sun's official website to download JDK. For more information, see http://java.sun.com/j2se/. select version (jdk1.5.0 is used in this system ).
(1) run the downloaded jdk exe Installation File.
(2) In the displayed dialog box, select the I accept the terms in the license agreement option, agree to the agreement content, and click Next to continue the next step.
(3) by default, all JDK components are installed without being changed. Change the default installation path to "C: \ jdk1.5.0", and click Next to continue the next step.
(4) The "Microsoft Internet Explorer" option has been selected by default. You do not need to change it. Click the next button to start JDK installation.
(5) After the installation is complete, set the environment variables. Select "Control Panel-> system-> advanced-> environment variables", and create a java_home variable. The variable value is c: \ jdk1.5.0, and add C: \ jdk1.5.0 \ bin, and then c: \ jdk1.5.0 \ Lib \ DT after the classpath variable. jar; C: \ jdk1.5.0 \ Lib \ tools. jar.

2. Install JMF
JMF (java media framework) is an API provided by Sun for developing and supporting Java multimedia applications. It is used to process extended video and audio media application packages, it integrates video and audio collection, encoding, transmission, and playback.
JMF can be downloaded from Sun's http://www.sun.com/products/java-media/jmf. JMF is a self-resolving EXE file applied to Windows operating systems. Execute this file directly in Windows operating systems, that is, enter the JMF Installation Wizard to complete JMF installation according to the wizard prompts.
When installing JMF, you should select the installation path (C: \ jdk1.5.0 \), because the development and running environment of JMF is implemented with JDK support. During JMF installation, it is best to install the development and running environment of JMF In the JDK path so that the running and development environment of JMF can be integrated with JDK, this removes the need to set environment variables for developing and running Java multimedia applications in computer operating systems. That is to say, add jar packages such as javax. Meida and javax. Sound to c: \ jdk1.5.0 \ bin, thus saving the environment variable for JMF setup.
After the installation is complete, JMF will automatically find the audio and video devices on the installed host, which may take some time. After the search is complete, this write information will be added to the JMF registry. You can use the JMF registry to adjust and manage detailed instructions to go To the sun website, which is very detailed, it's just e-text.

3. install and configure eclipse

Go to the eclipse website (www.eclipse.org) to download the eclipse software package. Eclipse3.1 is used in this system. For details, visit http://download.eclipse.org/downloads /.
Eclipse installation is very simple. It is the installation method of green software: you do not need to run the installation program, you do not need to write information to the Windows registry, you can run eclipse by unzipping the downloaded eclipse package. Decompress the package and copy it to drive C.
Add the JMF package to the build path. The procedure is as follows:

1) Go to the eclipse main menu and click the "window" option in the toolbar.
(2) In the pop-up window, select "Java-> installed JRE-> Add ".
(3) Enter JMF website _ home in the JRE name,
(4) Select Browse In the JRE home directory, find the JDK location, and confirm that the setting is complete.

4. Install SWT designer
SWT designer is: http://www.swt-designer.com/. different regions use the corresponding SWT designer. This system uses the SWT designer version v2.1.0ga.
To install SWT designer, follow these steps:
(1) decompress the downloaded Installation File.
(2) copy the two subdirectories under the decompressed directory plugins to the Plugins directory of Eclipse.
You only need to use the above two steps to complete the installation. Then, check whether the installation is successful. Open the eclipse main menu and select "file-> New-> Other". If a "designer" item is added in the pop-up new project dialog box, the SWT designer is successful.
You do not need to use the above method to introduce external packages.

A simple JMF MP3 player detection program:
Import java. Applet .*;
Import java. AWT .*;
Import java. AWT. event .*;
Import java.net .*;

Import javax. Swing .*;
Import java. Io. file;
Import java. Io. ioexception;

Import javax. Media .*;

Public class test3
{

Public static void main (string [] ARGs)
{
Frame myframe = new frame ();
Myframe. setsize (500,500 );
Myframe. setvisible (true );
Myframe. setdefaclocloseoperation (jframe. exit_on_close );
Myframe. setlocation (500,500 );

}

}

Class frame extends jframe implements controllerlistener {

Player myplayer = NULL;
URL url = NULL;
File file = new file ("F: \ 04.mp3 ");
Component VC, CC;
Panel mypanel = new Panel ();

Public frame ()
{
Try {
Url = file. touri (). tourl ();
} Catch (malformedurlexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
Try {
Myplayer = manager. createplayer (URL );
} Catch (noplayerexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}

This. Add (mypanel );
Myplayer. addcontrollerlistener (this );
Myplayer. prefetch ();

}
Public void controllerupdate (controllerevent E)
{
// If player is in the prefect status, start
If (E instanceof prefetchcompleteevent)
{
Myplayer. Start ();
Return;
}
// If the instance has been completed, add the control panel and video panel
If (E instanceof realizecompleteevent)
{
VC = myplayer. getvisualcomponent ();
If (VC! = NULL)
Add (VC );
Cc = myplayer. getcontrolpanelcomponent ();
If (CC! = NULL)
Add (CC, borderlayout. South );
Pack ();
}
}

}

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.