Playing mp3 Files

...How to? (More specifically)

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 6287 Views - Last Post: 10 October 2008 - 03:00 PM Rate Topic: -----

#1 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Playing mp3 Files

Posted 09 October 2008 - 02:09 PM

Ok, so I've done my part. I searched Google for god knows how long, and only came up with SourceForge-like projects that just are basically Windows Media Player(s), only different.

I want to add mp3 capability to my program, just mp3, nothing more. I just want the ability to play mp3 files with a written class.

I figured since I don't have any clue on how to do this...you guys could help me out. :)

(No, this isn't a homework assignment. I'm not enrolled in any Java classes. Only C++ :))

I don't have any code at the moment, but I will be researching this as much as I can, hopefully to get this answered myself.

:)

This post has been edited by Locke37: 09 October 2008 - 02:10 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Playing mp3 Files

#2 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,410
  • Joined: 05-June 08

Re: Playing mp3 Files

Posted 09 October 2008 - 03:27 PM

http://forums.sun.co...sageID=10175588
Was This Post Helpful? 1
  • +
  • -

#3 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 05:36 PM

View Postabgorn, on 9 Oct, 2008 - 03:27 PM, said:



...Didn't come across that one. :unsure:
Was This Post Helpful? 0
  • +
  • -

#4 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Playing mp3 Files

Posted 09 October 2008 - 05:43 PM

I don't believe that the javax.media packages are standard in the JDK. wav files can be done with the JDK (and without the bad applet package). It should be possible to play mp3s in a similar fashion, but I'm too sick at the moment to think logically to work out how my code works :P

If you don't have a good solution, I'll take a stab at it in a few days.

This post has been edited by William_Wilson: 09 October 2008 - 05:43 PM

Was This Post Helpful? 0
  • +
  • -

#5 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 05:54 PM

I have the JMF packages.

I just don't know if any standard JRE on another system will accept JMF.
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 05:58 PM

View PostLocke37, on 9 Oct, 2008 - 05:54 PM, said:

I have the JMF packages.

I just don't know if any standard JRE on another system will accept JMF.


If it is in your .jar no problem
Was This Post Helpful? 0
  • +
  • -

#7 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 06:38 PM

View Postpbl, on 9 Oct, 2008 - 05:58 PM, said:

View PostLocke37, on 9 Oct, 2008 - 05:54 PM, said:

I have the JMF packages.

I just don't know if any standard JRE on another system will accept JMF.


If it is in your .jar no problem


So, if I were porting this application around to different systems, there'd be no problem at all? Or would I have to include the jmf.jar in the directory with my application in it?
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 06:59 PM

View PostLocke37, on 9 Oct, 2008 - 06:38 PM, said:

So, if I were porting this application around to different systems, there'd be no problem at all? Or would I have to include the jmf.jar in the directory with my application in it?


The eaisest way is to put both your application and the files contained into jmf.jar into your own .jar
The user will just have to double click on the .jar
Was This Post Helpful? 0
  • +
  • -

#9 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 07:05 PM

View Postpbl, on 9 Oct, 2008 - 06:59 PM, said:

View PostLocke37, on 9 Oct, 2008 - 06:38 PM, said:

So, if I were porting this application around to different systems, there'd be no problem at all? Or would I have to include the jmf.jar in the directory with my application in it?


The eaisest way is to put both your application and the files contained into jmf.jar into your own .jar
The user will just have to double click on the .jar


Interesting...now how would I go about that? (I don't have experience in making jar files, I usually just let NetBeans do it for me :))
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 07:14 PM

View PostLocke37, on 9 Oct, 2008 - 07:05 PM, said:

Interesting...now how would I go about that? (I don't have experience in making jar files, I usually just let NetBeans do it for me :))


You are on Windows or Linux or VMS or Unix ?
Was This Post Helpful? 0
  • +
  • -

#11 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 07:22 PM

Windows Vista.
Was This Post Helpful? 0
  • +
  • -

#12 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 07:28 PM

View PostLocke37, on 9 Oct, 2008 - 07:22 PM, said:

Windows Vista.


OK give me 15 minutes... I'll have to cut & paste some .bat file and add explation to it... I start to edit the answer right away but will take a few minutes...
Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 07:58 PM

I use Eclipse...
I usually put a subdir deployment in my directories structure...

Here is one of my project called Eurostyle and it belongs to ca.pblinc so the package name is ca.pblinc.eurostyle

On my PC I have that directory structure

c:\Eurostyle
c:\Eurostyle\Eurostyle								<--- that is the Eclipse project
c:\Eurostyle\Eurostyle\ca\pblinc\eurostyle   <--- the actual Java package
c:\Eurostyle\deployment							<--- the directory that we will study in detail



Now my package ca.pblinc.eurostyle uses HSQLDB and JEXELAPI that are in .jar files... in your case it will be: jmf.jar

So \Eurostyle\deployment constains jexel.jar and hsqldb.jar


OK, first you need a manifest file. The manifest file is part of the .jar and contains the name of the main class. The class that should be executed when double clicking on the .jar icone

Manifest files usually have a .mf extension

so in \Eurostyle\deployment I have the manifestEuroStyle.mf file that contains

Main-Class: ca/pblinc/eurostyle/Eurostyle



ca.pblinc.eurostyle.Eurostyle.class being the Java class that contains the public static void main() method

OK now I have a makeEurostyle.bat file that contains...

OK first a parenthesis.... I have Googled and Googled and Googled trying to find a way to extract files from a .jar and put them in another .jar file without succes... so I extract the files from the .jar first and then put them back in a new .jar
So here is my makeEurostyle.bat

rem 
rem my code will go to ca\pblinc\eurostyle.....
rem hsqldb use org\hsqldb\....
rem jexcel goes into to jxl\....  and common\....
rem 
rem so we empty these directory first
RMDIR /S/Q ca
RMDIR /S/Q org
RMDIR /S/Q jxl
RMDIR /S/Q common
rem
rem Now extract from the .jar Hsqldb and jxl
rem they will create the directories org....  common... and jxl....
rem
jar xf hsqldb.jar
jar xf jxl.jar
rem
rem now create ca
mkdir ca
rem copy all the files for my application
xcopy /q/s/y c:\EuroStyle\EuroStyle\ca ca
rem remove the source code
del ca\pblinc\eurostyle\*.java
del ca\pblinc\eurostyle\*\*.java
rem
rem now jar all the folks together
rem first the manifest file  (switch -m of the jar command)
rem then the 4 directories ca, org, common, jxl
rem
jar -cmf0 manifestEuroStyle.mf EuroStyle.jar ca org common jxl



Now if you put EuroStyle.jar on a system double clicking on EuroStyle.jar will run the main() method of ca.pblinc.eurostyle.Eurostyle.class
and anymember of the package can call jxl or hsqldb

Hope this help
Was This Post Helpful? 0
  • +
  • -

#14 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 08:05 PM

:blink:

Gimme a few minutes while I try and decipher this...

I kinda get it. I've just never read batch before.

This post has been edited by Locke37: 09 October 2008 - 08:17 PM

Was This Post Helpful? 0
  • +
  • -

#15 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Playing mp3 Files

Posted 09 October 2008 - 08:20 PM

View PostLocke37, on 9 Oct, 2008 - 08:05 PM, said:

:blink:

Gimme a few minutes while I try and decipher this...

I kinda get it. I've just never read batch before.


If you have questions about the switch following the jar command here is my Bible

http://java.sun.com/...deployment/jar/
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2