在 netbeans 上找不到与 JMF 一起使用的 javax.media 数据包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22374115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.media packet not found working with JMF on netbeans
提问by Priteesh
I am currently using netbeans and i have downloaded the JMF plug in using its own plug in finder.I found one of the codes for video streaming using JMF from the net .The 'import javax.media.player' shows an error that package javax.media does not exists. Please help me in this matter as soon as possible.I am a beginner so a possible coding would be appreciated.
我目前正在使用 netbeans 并且我已经使用它自己的插件查找器下载了 JMF 插件。我从网上找到了使用 JMF 进行视频流传输的代码之一。“导入 javax.media.player”显示包 javax的错误.media 不存在。请尽快帮助我解决这个问题。我是初学者,因此可能的编码将不胜感激。
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.URL;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.swing.JPanel;
import javax.management.*;
public class MediaPlayer extends JPanel {
public MediaPlayer() {
setLayout( new BorderLayout() ); // use a BorderLayout
// Use lightweight components for Swing compatibility
Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );
try
{
// create a player to play the media specified in the URL
Player mediaPlayer = Manager.createRealizedPlayer("E:\FFOutput\Bollywood");
// get the components for the video and the playback controls
Component video = mediaPlayer.getVisualComponent();
Component controls = mediaPlayer.getControlPanelComponent();
if ( video != null )
add( video, BorderLayout.CENTER ); // add video component
if ( controls != null )
add( controls, BorderLayout.SOUTH ); // add controls
mediaPlayer.start(); // start playing the media clip
} // end try
catch ( NoPlayerException noPlayerException )
{
System.err.println( "No media player found" );
} // end catch
}
}
采纳答案by Anmol Mahatpurkar
It seems that you have not added the required jar libraries to your project.
您似乎还没有将所需的 jar 库添加到您的项目中。
If you are on windows, try installing the JMF windows performance pack from this link:http://www.oracle.com/technetwork/java/javase/download-142937.html
如果您使用的是 Windows,请尝试从此链接安装 JMF Windows 性能包:http: //www.oracle.com/technetwork/java/javase/download-142937.html
- Install this exe file on your PC.
- Restart your computer.
- Open your project in netbeans.
- Right click on your project name in the project explorer window and open project properties.
- Go to the Libraries section. Under the Compile tab, select add jar/folder.
- Select and add all the jar files from the path where your JMF was installed. The default is C:\Program Files\JMF\lib. There should be 5 jar files.
- 在您的 PC 上安装此 exe 文件。
- 重启你的电脑。
- 在 netbeans 中打开您的项目。
- 在项目资源管理器窗口中右键单击您的项目名称并打开项目属性。
- 转到库部分。在编译选项卡下,选择添加 jar/文件夹。
- 从安装 JMF 的路径中选择并添加所有 jar 文件。默认为 C:\Program Files\JMF\lib。应该有 5 个 jar 文件。
This should resolve your error.
这应该可以解决您的错误。
If you are on a different OS, follow the steps on the above mentioned link.
如果您使用不同的操作系统,请按照上述链接中的步骤操作。
回答by Dead Hand Signal
If your on Mac you need to do this:
如果您使用的是 Mac,则需要执行以下操作:
In OSX, you can set the classpath from scratch like this:
在 OSX 中,您可以像这样从头开始设置类路径:
export CLASSPATH=/path/to/some.jar:/path/to/some/other.jar
Or you can add to the existing classpath like this:
或者您可以像这样添加到现有的类路径中:
export CLASSPATH=$CLASSPATH:/path/to/some.jar:/path/to/some/other.jar
This is answering your exact question, I'm not saying it's the right or wrong thing to do; I'll leave that for others to comment upon.
这是在回答您的确切问题,我并不是说这是对还是错;我会把它留给其他人评论。