当我通过 javafx 写入任何数字时如何播放音频

how i can play the audio when i write any number by javafx

我在 window 文本字段的中间有一个小项目,当我输入我需要通过音频呼叫的号码时,我在 texfield 上写了多少号码,例如我写了号码:1 输入,音频正在工作有一次是当我写了相同的数字或另一个数字并停止它等时玩agian...

我已经搜索了这个项目负责什么的代码,但我只是找到了播放音频

//this the text field what i have to write the number on it 
//(numberscreen)
//screen1,screen2...etc it's for passing the old number from number 
//screen 

@FXML
private TextField numberscreen;

@FXML
public void screeninsert() {
    play();
    String enteredText = numberscreen.getText();
    String enteredText1 = screen1.getText();
    String enteredText2 = screen2.getText();
    String enteredText3 = screen3.getText();
    String enteredText4 = screen4.getText();
    String enteredText5 = screen5.getText();
    String enteredText6 = screen6.getText();
    numberscreen.clear();
    screen1.setText(enteredText);
    screen2.setText(enteredText1);
    screen3.setText(enteredText2);
    screen4.setText(enteredText3);
    screen5.setText(enteredText4);
    screen6.setText(enteredText5);
    screen7.setText(enteredText6);

 }

public void AudioPlay(){
URL url = 
this.getClass().getClassLoader().getResource("audio/1.wav");
AudioInputStream ais = AudioSystem.getAudioInputStream(url); 
AudioFormat littleEndianFormat = getAudioFormat();
AudioInputStream converted = 
AudioSystem.getAudioInputStream(littleEndianFormat, ais);
}

请提供任何解决方案,将我写入的数字传递给音频文件以播放音频名称,谢谢

@FXML
    private TextField numberscreen;

public void AudioPlay() {
        filestring = new File("src\audio\" + numberscreen.getText().trim() + ".wav");
        Media file = new Media(filestring.toURI().toString());

        mp = new MediaPlayer(file);

        mp.setOnReady(new Runnable() {
            @Override
            public void run() {
                System.out.println("Duration: " + file.getDuration().toMinutes());
                // display media's metadata
                file.getMetadata().entrySet().forEach((entry) -> {
                    System.out.println(entry.getKey() + ": " + entry.getValue());
                    mp.seek(Duration.millis(200));
                });
                mp.setOnEndOfMedia(new Runnable() {
                    @Override
                    public void run() {
                        mp.stop();
                        if (mp.isAutoPlay()) {
                            //Plays the subsequent files
                        }
                        return;
                    }
                });
                // play if you want
                mp.play();

            }
        });

    }

这是我需要的解决方案 我解决了我自己找到的问题