• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMF from JAR  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a game that I built, it is done. I just want to play a simple video for cut scenes and such, that's all. I used the JMF for this, as it seemed simple. I was able to build a video player pretty quickly with some basic internet tutorials about JMF, and it works beautifully... from Netbeans. However, when I build my project into an executable JAR file, anything related to the JMF refuses to work. Yes, I did add 'jmf.jar' to the project's classpath, and Java seems to recognize it, but it just doesn't work! It's always blank. If I run it from the command prompt and print the error, I get this...



All I want to know is why I am able to play this exact same video from JMStudio perfectly fine, but when I try to use it in my project it will not work. I have been looking around the web 24/7 it seems just to get it to work and I feel as if I've tried everything short of asking on the Ranch. I have had this project done for 3 months now and haven't released it simply cause I can't get the darned videos to play from a JAR. If JMF isn't the answer, is there another way to play videos in Java easily? I looked into FMJ already but it does not seem to like 64 bit operating systems, and is also suffering from lack of updates like JMF. I honestly just want the simplest way to get a video to play from an executable JAR file, nothing more.

Here is the code for the VideoPlayer just in case..



Thanks for reading.
 
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is JMF a separate jar which is part of your classpath? If so, how did you run your jar so as to include that JMF jar in its classpath?
 
Ike Gentz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Is JMF a separate jar which is part of your classpath? If so, how did you run your jar so as to include that JMF jar in its classpath?


What I did was create a 'lib' folder in the project's main folder, on the same level as 'dist,', 'build', etc... and placed the jmf.jar in there. Then in Netbeans, I went to the libraries node and added the jmf.jar located in the lib folder I just created, for all five categories. (processor, run, etc...) I assumed that this was all I had to do, as once I had rebuilt the project my manifest folder then would show a new 'lib' folder being created under the 'dist' folder, with the jmf.jar in there. I knew that it was reading from that JAR because I was able to still continue coding on another machine that didn't have JMF installed. However, when I would run from a JAR I still got just a blank screen and the command prompt telling me "NoPlayerException. Could not find a player for... //video file"

I then looked into it a bit further and found that there was a command line argument you could pass in to specify a custom manifest file. I created a custom one that was exactly the same as the one Netbeans auto-generated, including "lib/jmf.jar" on the classpath. Here is the command line argument I used...



However, this seemed to have no effect and the project still did the same thing.

I feel like I am just missing some other small file or something, like a .dll for Windows? (I am using the Windows Performance Pack of JMF), because if I open the videos I'm trying to use (which I looked up and converted to MPEG so they would work w/ JMF) through JMStudio, they play just fine.

Thanks for reading. :)
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have a manifest, then. That's a good first step.

Presumably you aren't using Netbeans to run this jar file, though. So anything you wrote there about Netbeans could be considered irrelevant or even misleading. You need to look at what is actually in the jar now. Your command line argument, which I assume was the arguments for the "jar" command, doesn't appear to include your code in the jar. So have you looked in the jar? Are your compiled classes in there? And does it contain a manifest with a line which says "Class-Path: lib/jmf.jar"?
 
Ike Gentz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably you aren't using Netbeans to run this jar file, though. So anything you wrote there about Netbeans could be considered irrelevant or even misleading


Ooh, sorry about that, I wasn't very specific. What I use Netbeans for is writing the actual code, and from within Netbeans is where I added jmf.jar to the project's libraries. Then I clean and build from Netbeans to create the executable JAR. When I run the project from Netbeans (Shift + F6), that is when everything works. When I run the executable JAR that is generated from 'clean and build' I use both the methods of simply double clicking, as well as running it from the command prompt to ensure that I get the same results, and this is when anything relating to the JMF doesn't work, but the rest of the entire game goes off without a hitch still.

You need to look at what is actually in the jar now. Your command line argument, which I assume was the arguments for the "jar" command, doesn't appear to include your code in the jar. So have you looked in the jar? Are your compiled classes in there? And does it contain a manifest with a line which says "Class-Path: lib/jmf.jar"?


I actually ditched using that command line argument a while ago, as it seemed to do nothing different than manually adding jmf.jar into the libraries in the first place from Netbeans. Also, I actually am able to run the entire game from the executable JAR that is generated, it just won't play the videos form the JAR. If I extract the JAR that is generated, I have all the packages with my compiled .class files in there. The manifest file is also located under "META-INF" and does contain the line "Class-Path: lib/jmf.jar"

You did bring up an interesting point I am a little confused on however. So, when I look in the 'dist' folder for the project after 'clean and build', in there I have my JAR (which is the one I exctracted for the above example). There is also the "lib" folder in there, which contains jmf.jar, that seems to be automatically generated when I clean and build. On the autogenerated README for the project it says that you can zip up the 'dist' folder for distribution, so I was assuming that the 'lib' folder being added at this level meant it was working, but does it need to be put in the JAR itself somehow? I'm still 17 and all this is a little new to me. Been learning from the internet until I can get into college. :-/

Thanks.
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you want to end up with is a jar which contains your application code and the correct manifest. It sounds like you have that, if some things are running properly. And when you run your jar, you have to make sure that the jmf.jar is in a lib folder relative to where your executable jar is located. In other words if your executable jar's path is /X/Y/Z/your.jar (where /X/Y/Z is the full path) then the jmf.jar should be at /X/Y/Z/lib/jmf.jar.

And yes, that does mean that the jmf.jar should be in the file system at that location. Putting it inside your executable jar isn't going to work.

So is that how you have things set up now? If not, then fix your setup and try it again.

Searching the web a bit, I found out that there's a jmf.properties file involved. Did your Netbeans project have one of those? Apparently you need to put it in the same folder as your executable jar. And I found other posts on this forum which say that jmf.jar isn't the only external jar you need, there's sound.jar and mediaplayer.jar and so on. Check for JMF documentation which might tell you about what you need.
 
Ike Gentz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have everything set up according to that description. This is what the filepath looks like...

X/Y/Z/dist/(Sonic Game.jar as well as lib), then inside lib I have jmf.jar.

I as well read about the other jar's as well, such as mediaplayer and sound. I tried adding these (as well as every other JAR that comes w/ JMF) in the same way as jmf.jar, but it did not change anything.
The only thing that seems different is the JMF.properties file.

I went and found this article... Jmf Properties. I did these instructions from that article...

I was able to successfully get Clean and Build to automatically add in the jmf.properties file at the same level as my JAR within the dist folder. (I added jmf.properties to my lib folder and then did what the instructions in the link said, using the one located there). Now each time I build the project I am able to see the properties file in there along with the JAR, however when I run the project from the JAR, I still get the same results.
 
Ike Gentz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After trying literally everything I could think of I ended up giving up on the JMF. However, I am actually glad that I did it now because I was instead able to write (well, smush a couple examples together. ) a video player in JavaFX that runs through Swing instead! It is much better than JMF too... better formates, resolution, you name it! However, I did run in to one slight little problem I was hoping for some help on. This problem is not nearly as strange though I don't think.

So here is the code for the video player, and it includes a main method in there for a test example.



Now, when I was working on this on my laptop, it worked perfectly fine! I even built it into a JAR and distributed it to some friends, who all reported it worked for them as well. However, when I came home for the weekend and put it on my main rig, it wouldn't run. I keep getting this error...



Now, I can hear the audio from the video play, but it seems to be something with the graphics. I have never used JavaFX so I am looking for a bit of help figuring out why it runs for everyone except me. :-/

Also, on my laptop I have the most up to date versi nof Java. I use the 32 bit version on there. On my main desktop that is having issues, it is the exact same OS (Windows 7 64 bit) and I also have the 32 bit version of Java. I even checked Oracle and made sure everything was up to date, both my JDK and JRE. I feel like it's not anything related to the OS, as this error seems code related to me, but I just need some help because I have never used JavaFX, and this is the last part of my big Swing project I need to get working. It's just wierd it works on practically every machine I try, except my nice desktop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!