如何在JavaFX MediaPlayer中创建播放列表以播放歌曲列表?

时间:2015-05-21 19:44:06

标签: java javafx

我正在尝试制作音乐播放器。我的目标是让用户选择播放按钮,然后播放音乐,暂停然后暂停,按下一个 //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"); } } 按钮,它应该转到下一首歌曲,然后按上一个public class playList { ArrayList<String> titles = new ArrayList<String>(); public String playList() throws IOException { FileReader fr = new FileReader("Songs"); BufferedReader br = new BufferedReader(fr); String s; while ((s = br.readLine()) != null) { titles.add(s); } fr.close(); } } 按钮它应该回到上一首歌。

这是我播放音乐时的代码:*这只播放文件夹名称中的一首歌曲&#34;歌曲&#34;

10

我制作了一个导入音乐文件,以便它读取所有音乐文件所在的文件夹并在播放列表中播放:

00000000000000000000000000001010

关于如何使其发挥作用的任何想法?我尝试了几种组合,但所有这些都是错误的!

0 个答案:

没有答案