UniFM/other/modules/playlist/M3UModule.java

55 lines
1.2 KiB
Java
Raw Permalink Normal View History

2018-11-14 19:08:50 +02:00
package modules.playlist;
import com.one.Application;
import com.one.IniFile;
import com.one.file.Connector;
import com.one.file.FileConnection;
import com.vmx.InputStreamDecoder;
import com.one.PlayList;
import filemanager.main;
import java.io.IOException;
import java.util.Vector;
public class M3UModule implements Application
{
public void openFile(String filename, PlayList filelist) throws IOException
{
FileConnection fc = (FileConnection)Connector.open("file:///" + filename);
InputStreamDecoder isd = InputStreamDecoder.getFileDecoder(fc);
String disk = filename.substring(0, filename.indexOf('/'));
String path = filename.substring(0, filename.lastIndexOf('/') + 1);
Vector files = new Vector();
String s;
while((s = IniFile.readIniLine(isd)) != null)
{
if(s.startsWith("#"))
{
continue;
}
s = s.replace('\\', '/');
if(s.indexOf(':') >= 0)
{
files.addElement(s);
}
else if(s.startsWith("/"))
{
files.addElement(disk + s);
}
else
{
files.addElement(path + s);
}
}
isd.close();
fc.close();
main.FileSelect.executeFile(new PlayList(files.elements()), null, main.manager.currentPanel());
}
}