Question

I am importing mp3transform into my java game. It is vital that I use mp3, and mp3transform works perfectly except for the fact it runs on the main thread, and therefore freezes the program. The already is a PlayerThread in the src, but it gives me a null pointer. I am new to the whole Java scene, and there seems to be no mp3transform help/docs D:

Any help would be appreciated. Thanks.

Was it helpful?

Solution

            Thread t1 = new Thread(new Runnable() {
                public void run()
                {
                    try{
                        Decoder decoder = new Decoder();
                            File file = new File("C:" + File.separator + "as.mp3");
                            FileInputStream in = new FileInputStream(file);
                            BufferedInputStream bin = new BufferedInputStream(in, 128 * 1024);
                            decoder.play(file.getName(), bin);
                            in.close();

                        decoder.stop();
                    }
                    catch(Exception exc){
                        exc.printStackTrace();
                        System.out.println("Failed to play the file.");
                    }
                }});  
                t1.start();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top