我正在努力使我的活动正常进行,但方法出现问题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(); }}
1 回答
慕斯王
TA贡献1864条经验 获得超2个赞
你的方法playorPauseMusic(View view)
有一个参数View view
。这意味着无论何时调用该方法,都必须提供一个 View 实例作为参数。nextSong()
在你调用的方法的最后一行playorPauseMusic()
没有视图参数,导致你的错误
虽然看起来您实际上并没有使用该参数,但您可以将方法更改playorPauseMusic(View view)
为playorPauseMusic()
添加回答
举报
0/150
提交
取消