Jump to content
Sign in to follow this  
blitzkrg

does anyone here know java?

Recommended Posts

I have this MP3 player that has a company specific file format for it's playlist.

it's not a simple text file like a .m3u file.. but has a binary format.

i found this german guy who wrote a program to parse the playlist files.

but it's in java.. i'd like to do something in autoit so i can work with it..but i dont understand java.

my goal is to be able to write a autoit program that i can drag and drop my mp3 files to,and it would upload them and output the correct playlist file to the mp3 player.. i can do the gui, drag and drop, upload and all that, it's just writing that binary playlist that i have no clue about..

here is the source, if you can help it would be apprechiated.

/**
* Reads a SPL Playlist and parses the contents
* @param filename
* @return PlayList
*/
public PlayList_old readPlayList(String filename) {
File f = new File(filename); 
PlayList_old pl = new PlayList_old(f.getName(),f.getParent());
try {
RandomAccessFile ram = new RandomAccessFile(filename, "r");
log.fine("Read nr of entries:"); //Seek to number of entries in Playlist
byte[] playlist_entry_nr = new byte[4];
ram.seek(6);
ram.read(playlist_entry_nr); //must be long because of missing unsigned int types in java
long entries = byteTolong(playlist_entry_nr);

for (long i = 0; i < entries; i++) {
log.fine("Read init block:");
//reading init block
byte start = ram.readByte();
byte start1 = ram.readByte();
if (start != 2 || start1 != 0) {
log.severe("Something is wrong with the parser (assuming 02):" + start + " " + start1);
} else {
log.fine("done");
}
log.fine("Read position:");
byte[] entry_nr = new byte[4]; //reading number of entry
ram.read(entry_nr);
long position = byteTolong(entry_nr);
log.fine("Read Filesize:");
byte[] filesize = new byte[8];
ram.read(filesize); //may be wrong in case of big files , because of the signed long :-((
long size = byteTolong(filesize);
log.fine("Read playtime:"); //reading number of entry
byte[] playtime = new byte[4];
ram.read(playtime);
long time = byteTolong(playtime);
byte[] bsize = new byte[4]; //size bytes for reuse
log.fine("Read size of title:");
ram.read(bsize);
long lsize = byteTolong(bsize);
log.fine("Read Title:");
byte[] title = new byte[(int) lsize];
ram.read(title);
String s_title = new String(title);
log.fine("Read size of artist:");
ram.read(bsize);
lsize = byteTolong(bsize);
log.fine("Read Artist:");
title = new byte[(int) lsize];
ram.read(title);
String s_artist = new String(title);
log.fine("Read size of album:");
ram.read(bsize);
lsize = byteTolong(bsize);
log.fine("Read Album:");
title = new byte[(int) lsize];
ram.read(title);
String s_album = new String(title);
log.fine("Read size of genre:");
ram.read(bsize);
lsize = byteTolong(bsize);
log.fine("Read Genre:");
title = new byte[(int) lsize];
ram.read(title);
String s_genre = new String(title);
log.fine("Read size of path:");
ram.read(bsize);
lsize = byteTolong(bsize);
log.fine("Read Path:");
title = new byte[(int) lsize];
ram.read(title);
String s_path = new String(title);
log.fine("Reading Track Number:");
byte tracknummer = ram.readByte();
byte end = ram.readByte();
if (end != 0) {
log.severe("Something wrong with parsing (assuming 00):" + end);
} else {
int idx = s_path.lastIndexOf("\\");
String filen = s_path.substring(idx + 1);
pl.addEntry(pl.new Entry(size, time, tracknummer, s_title, s_artist, s_album, s_genre, 

position, filen));
}}
ram.close();
} catch (IOException e) {
log.warning("Read Playlist failed: Exception is " + e.getMessage());
log.throwing("SPLParser", "readPlayList(String)", e);
}
return pl;
}
Edited by blitzkrg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...