getting .mp3 Duration of a JMF

using JMF to play .mp3's and need to get a song duration

Page 1 of 1

6 Replies - 11492 Views - Last Post: 06 June 2011 - 01:14 AM Rate Topic: -----

#1 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 15
  • View blog
  • Posts: 281
  • Joined: 27-February 08

getting .mp3 Duration of a JMF

Posted 26 June 2009 - 09:39 PM

so far the following code will play the song i want. but wont give me an accurate time in minutes. Any help is greatly appreciated and yes i am very new to the JMF platform!
Player player = Manager.createPlayer(new MediaLocator(new File(con[found+1]).toURL().toExternalForm()));
Time t = player.getDuration();
Double time = t.getSeconds() / 60;
System.out.println(time);



Is This A Good Question/Topic? 0
  • +

Replies To: getting .mp3 Duration of a JMF

#2 pbl  Icon User is offline

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

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

Re: getting .mp3 Duration of a JMF

Posted 26 June 2009 - 09:47 PM

View Postpainkiller102, on 26 Jun, 2009 - 08:39 PM, said:

so far the following code will play the song i want. but wont give me an accurate time in minutes. Any help is greatly appreciated and yes i am very new to the JMF platform!
Player player = Manager.createPlayer(new MediaLocator(new File(con[found+1]).toURL().toExternalForm()));
Time t = player.getDuration();
Double time = t.getSeconds() / 60;
System.out.println(time);


Never heard of the classes Player abd Manager where did you get them from ?
Was This Post Helpful? 0
  • +
  • -

#3 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 15
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Re: getting .mp3 Duration of a JMF

Posted 26 June 2009 - 09:51 PM

View Postpbl, on 26 Jun, 2009 - 08:47 PM, said:

View Postpainkiller102, on 26 Jun, 2009 - 08:39 PM, said:

so far the following code will play the song i want. but wont give me an accurate time in minutes. Any help is greatly appreciated and yes i am very new to the JMF platform!
Player player = Manager.createPlayer(new MediaLocator(new File(con[found+1]).toURL().toExternalForm()));
Time t = player.getDuration();
Double time = t.getSeconds() / 60;
System.out.println(time);


Never heard of the classes Player abd Manager where did you get them from ?


they are an import from the JMF (Java Media Framework) package that you download from sun. Basically it is a big package full of media tools for playing animations, mp3's, movies etc. The import i used for the player and what not are:
import javax.media.*;


Was This Post Helpful? 0
  • +
  • -

#4 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: getting .mp3 Duration of a JMF

Posted 26 June 2009 - 10:57 PM

Hello painkiller102, I suggest you check out this link as the tutorial there includes how you can get the playback duration in microseconds and the you will have to convert it to minutes on your own, furthermore is shows you some nifty methods that could be used such the rate, audio type, name of the song/artist etc... : http://www.onjava.co...mp3.html?page=2

Hope this helps, good luck ;)
Was This Post Helpful? 1
  • +
  • -

#5 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 15
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Re: getting .mp3 Duration of a JMF

Posted 27 June 2009 - 07:59 AM

View Postayman_mastermind, on 26 Jun, 2009 - 09:57 PM, said:

Hello painkiller102, I suggest you check out this link as the tutorial there includes how you can get the playback duration in microseconds and the you will have to convert it to minutes on your own, furthermore is shows you some nifty methods that could be used such the rate, audio type, name of the song/artist etc... : http://www.onjava.co...mp3.html?page=2

Hope this helps, good luck ;)


This tutorial uses a different package, however it does have the solution to my problem! Thanks a bunch this was very helpful!
Was This Post Helpful? 0
  • +
  • -

#6 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: getting .mp3 Duration of a JMF

Posted 27 June 2009 - 08:03 AM

Quote

This tutorial uses a different package, however it does have the solution to my problem! Thanks a bunch this was very helpful!


Your welcome :)
Was This Post Helpful? 0
  • +
  • -

#7 hyeumine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-June 11

Re: getting .mp3 Duration of a JMF

Posted 06 June 2011 - 01:14 AM

View Postpainkiller102, on 26 June 2009 - 09:39 PM, said:

so far the following code will play the song i want. but wont give me an accurate time in minutes. Any help is greatly appreciated and yes i am very new to the JMF platform!
Player player = Manager.createPlayer(new MediaLocator(new File(con[found+1]).toURL().toExternalForm()));
Time t = player.getDuration();
Double time = t.getSeconds() / 60;
System.out.println(time);




though this thread is so old,i like to share my experience with this prob!!
I used createRealizedPlayer method of Manager class instead..
Player player = Manager.createRealizedPlayer(new MediaLocator(new File(con[found+1]).toURL().toExternalForm()));


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1