如何使用java.io.FilenameFilter从目录中检索.mp3文件名列表?

时间:2015-05-22 00:13:02

标签: java javafx fxml

我正在尝试创建一个由我的媒体播放器播放的歌曲播放列表:

我想找到一种收集文件数组的方法 - 来自src文件中名为'Songs'的文件夹............

然后将文件作为播放列表发送到:

//mp3 player
String bob = getClass().getResource("Songs/Sing.m4a").toExternalForm();
Media lol = new Media(bob);
MediaPlayer myMedia = new MediaPlayer(lol);



//play button for mp3 player - in My Library scene

public void audioPlayerButtons(ActionEvent actionEvent) {

    if (actionEvent.getSource() == playbtn) {
        myMedia.play();

        nowPlaying.setText("Now Playing...");
        songPlayingName.setText("Sing - Ed Sheeran");


    } else if (actionEvent.getSource() == stopbtn) {
        myMedia.stop();

        nowPlaying.setText("Stopped");
        songPlayingName.setText("-");

    } else if (actionEvent.getSource() == pausebtn) {
        myMedia.pause();

        nowPlaying.setText("Paused");
    }
}

public void forwardAudio(ActionEvent actionEvent) {

    if (actionEvent.getSource() == forwardbtn) {
        //mp3 player
        nowPlaying.setText("Now Playing...");
        songPlayingName.setText("No Better - Lorde");


        if (actionEvent.getSource() == forwardbtn) {

            myMedia.pause();

            if (actionEvent.getSource() == stopbtn) {
                myMedia.stop();
            }

        }
    }
}

public void backAudio(ActionEvent actionEvent) {

    if (actionEvent.getSource() == backwardbtn) {
        //mp3 player

        nowPlaying.setText("Now Playing...");
        songPlayingName.setText("Dark Horse - Kate Perry");


    }

}

0 个答案:

没有答案