JavaZOOM播放后移动文件

时间:2017-11-22 04:02:39

标签: java audio javasound javax

我试图在播放文件后移动文件。 我正在使用javazoom的基本播放器播放我的文件,我试过

player.close();
controler.close();
and DSP.close();

并且没有工作

以下是我用来播放文件的代码

public void play(File sound) {
    if (sound.exists()) {

        new Thread("Sound player") {

            public void run() {

                currentSelectedSound = sound;

                try {
                    control.open(currentSelectedSound);
                    control.play();

                    setVolume(currentAudioVolume);
                    setPan(currentAudioPan);
                } catch (BasicPlayerException e) {
                    e.printStackTrace();
                    System.err.println("Error!");
                }

            }
        }.start();

    } else {
        Logger.logError(TAG, "File doesn't exist!");
    }
}

1 个答案:

答案 0 :(得分:0)

我很高兴它最终有效,这是任何人的答案:

            stop();

            try {
                //The thread used to play() the sound
                soundPlayThread.join();
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }


            //Manually run the garbage collection and yield threads
            System.gc();
            Thread.yield();

我希望没有人像我刚才那样浪费6个小时

非常感谢wuppi

https://stackoverflow.com/a/14123384/3224295