This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Accessing mp3 properties (128 bytes at the end) dirty hack...How to make this more efficient? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Accessing mp3 properties (128 bytes at the end) dirty hack...How to make this more efficient?" Watch "Accessing mp3 properties (128 bytes at the end) dirty hack...How to make this more efficient?" New topic
Author

Accessing mp3 properties (128 bytes at the end) dirty hack...How to make this more efficient?

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I looked at the I/O API and came up with a dirty hack. I know that the last 128 bytes for mp3 files are the properties for these files. I tested my code (below) on some real life mp3 files (the 3 that came with my computer). It works fine, but I know this is just a cheap hack. Is there a better way to do this? I am doing it twice. There has to be a way to do it once...

Thanks,
cc11rocks


EDIT: Made the code just send off an error if it doesn't have ID3 in the beginning (which I believe is the format of the mp3 that I am doing).


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

You may re-write as follows.



S.D. MADHAN
Not many get the right opportunity !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing mp3 properties (128 bytes at the end) dirty hack...How to make this more efficient?