public Mp3Loader( String filePath ){


        in = null;
        valid = true;

        try {
            in = new FileInputStream( filePath );
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        int maxFrameCount = Integer.MAX_VALUE;

        // int testing;
        // maxFrameCount = 100;

        //
        stream = new Bitstream( in );
        int error = 0;
        int frame;
        for (frame = 1; frame < maxFrameCount; frame++) {
//            if (pause) {
//                line.stop();
//                while (pause && !stop) {
//                    try {
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        // ignore
//                    }
//                }
//                line.flush();
//                line.start();
//            }
            try {
                Header header = stream.readFrame();
                if (header == null) {
                    break;
                }
                //if (decoder.channels == 0) {
                    int channels = (header.mode() == Header.MODE_SINGLE_CHANNEL) ? 1 : 2;
                    float sampleRate = header.frequency();
                    int sampleSize = 16;
                    audioFormat = new AudioFormat(
                            AudioFormat.Encoding.PCM_SIGNED, sampleRate,
                            sampleSize, channels, channels * (sampleSize / 8),
                            sampleRate, true);
//                    // big endian
//                    SourceDataLine.Info info = new DataLine.Info(
//                            SourceDataLine.class, format);
//                    line = (SourceDataLine) AudioSystem.getLine(info);
//                    if (BENCHMARK) {
//                        decoder.initOutputBuffer(null, channels);
//                    } else {
//                        decoder.initOutputBuffer(line, channels);
//                    }
//                    // TODO sometimes the line can not be opened (maybe not enough system resources?): display error message
//                    // System.out.println(line.getFormat().toString());
//                    line.open(format);
//                    line.start();
                //}
//                while (line.available() < 100) {
//                    Thread.yield();
//                    Thread.sleep(200);
//                }
//                decoder.decodeFrame(header, stream);
            } catch (Exception e) {
                System.out.println( e.toString() );
                if (error++ > 1000) {
                    break;
                }
                // TODO should not write directly
                System.out.println("Error at: " + " Frame: " + frame + " Error: " + e.toString());
                // e.printStackTrace();
            } finally {
                stream.closeFrame();
            }
        }

        frameCount = frame;

        decoder = new Decoder();
        stream = new Bitstream( in );

        if (error > 0) {
            System.out.println("errors: " + error);
        }
    }