无法实现媒体播放器
我正在使用此代码使用 jmf 运行 avi 文件 但出现类似“无法实现媒体播放器”的错误
以及如何使用 jmf 打开所有视频格式
import javax.media.*;
import javax.media.format.*;
import java.io.*;
import java.util.*;
public class Test{
public static void main(String a[]) throws Exception{
CaptureDeviceInfo di = null;
Player p = null;
Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat("linear", 44100, 16, 2));
if (deviceList.size() > 0){
di = (CaptureDeviceInfo)deviceList.firstElement();
System.out.println((di.getLocator()).toExternalForm());
}else{
System.out.println("Exiting");
System.exit(-1);
}
try{
p = Manager.createPlayer(di.getLocator());
}catch (IOException e){
System.out.println(e);
}catch (NoPlayerException e) {
System.out.println(e);
}
System.out.println("Playing Started");
p.start();
}
}
I am using this code to run avi file using jmf
but the error come like "Could not realize media player"
and how to open all video format using jmf
import javax.media.*;
import javax.media.format.*;
import java.io.*;
import java.util.*;
public class Test{
public static void main(String a[]) throws Exception{
CaptureDeviceInfo di = null;
Player p = null;
Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat("linear", 44100, 16, 2));
if (deviceList.size() > 0){
di = (CaptureDeviceInfo)deviceList.firstElement();
System.out.println((di.getLocator()).toExternalForm());
}else{
System.out.println("Exiting");
System.exit(-1);
}
try{
p = Manager.createPlayer(di.getLocator());
}catch (IOException e){
System.out.println(e);
}catch (NoPlayerException e) {
System.out.println(e);
}
System.out.println("Playing Started");
p.start();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是它与您的 JMF 安装有关。您运行的是 Windows 吗?如果是这样,我已经修改了你的代码。试一试。它会告诉您视频播放所需的 dll 是否位于正确的位置。
My guess is that it has something to do with your JMF install. Are you running Windows? If so, I have reworked your code. Give it a shot. It will tell you if the dlls needed for video playback are in their correct locations.
假设您正确安装了 JMF 并且您能够使用 JMStudio 查看和捕获视频,那么您就可以开始了。
请检查您的 CaptureDeviceManager 代码片段。搜索的依据是什么?您要播放哪个 AVI 文件?
尝试这个代码片段...
Assuming you installed JMF correctly and you are able to use JMStudio to view and capture videos then you are okay to go.
Please check your CaptureDeviceManager code snippet. What is the basis for search and which AVI file do you want to play?
Try this code snippet...
下载
jmf-2_1_1e-alljava
JAR 文件后,像提取任何 zip 文件夹一样提取文件,具体取决于您的操作系统。在那里你会看到看起来像一堆罐子的东西。单击其中之一将其打开。它将出现在您眼前的大面板中。
你必须对每个罐子都这样做;你听到我了吗:他们每个人。
完成后,单击“确定”,然后单击“Bam”,您应该可以开始了。
玩得开心!
After you download the
jmf-2_1_1e-alljava
JAR file, extract the files like you would do any zip folder depending on you operating system.There you will see what looks like a bunch of jars. Click on one of them to open it. It will appear in the large panel before your eyes.
You have to do this for each and every jar; did you hear me: each and everyone of them.
When you're done click OK, and "Bam", you should be good to go.
Have fun!