我正在努力使我的活动正常进行,但方法出现问题nextSong()。它的最后一行playorPauseMusic()有一个错误:-
playoyPauseMusic (View) in PlaySongActivity cannot be applied to ()
我不太确定问题是什么,但认为是关于(View view). 我是 Java 的新手,所以如果您能详细说明这个问题,那将有很大帮助。谢谢;)
public void playorPauseMusic(View view)
{
if (player == null) {
preparePlayer();
}
if (!player.isPlaying()) {
if (musicPosition > 0) {
player.seekTo(musicPosition);
}
player.start();
getSeekBarStatus();
btnPlayPause.setText("PAUSE");
setTitle("Now Playing: " + title + " = " + artist);
gracefullyStopWhenMusicEnds();
} else {
pauseMusic();
}
}
private void gracefullyStopWhenMusicEnds()
{
player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
nextSong();
}
});
}
public void stopActivities() {
btnPlayPause.setText("PLAY");
musicPosition = 0;
setTitle("");
player.stop();
player.release();
player = null;
}
private void nextSong()
{
Song nextSong = songCollection.getNextSong(songId);
if (nextSong !=null)
{
songId = nextSong.getId();
title = nextSong.getTitle();
artist = nextSong.getartist();
fileLink = nextSong.getFileLink();
coverArt = nextSong.getCoverArt();
url = BASE_URL + fileLink;
displaySong(title, artist, coverArt);
stopActivities();
playorPauseMusic();
}
}
慕斯王
相关分类