【发布时间】:2017-08-26 02:18:08
【问题描述】:
所以我正在用 java 制作一个 MP3 播放器,除了一首歌结束时,一切正常。我没有得到当前正在播放的歌曲的标题。现在我有它是用户必须跟踪,所以他们需要知道歌曲何时结束,以便他们可以跳过并显示标题。我正在使用 jaco mp3player api,但如果有其他类似的 java api 可能会更好,请建议。到目前为止,这是我唯一喜欢的 api,但我不介意重新开始我的项目。
这是我的播放和暂停的工作方式,正如您所见,我通过查看存储歌曲的数组列表来获取歌曲名称。
// Check if ppTracker is 1 and allow the user to pause
if (ppTracker == 1) {
// Change the image icon
btnPlaynPause.setIcon(unpressPause);
//songName = musicAccess.getSongName();
//displaySong.setText(songName);
displaySong.setText(music.get(mTracker).getSongName());
player.play();
System.out.println("Size "+player);
// Check if ppTracker is 2 and allow the user to resume or play
} else if (ppTracker == 2) {
// Change the image icon
btnPlaynPause.setIcon(unpressPlay);
player.pause();
// Reset the tracker back to 0
ppTracker = 0;
}
【问题讨论】: