我正在努力使我的活動正常進(jìn)行,但方法出現(xiàn)問題nextSong()。它的最后一行playorPauseMusic()有一個錯誤:-playoyPauseMusic (View) in PlaySongActivity cannot be applied to ()我不太確定問題是什么,但認(rèn)為是關(guān)于(View view). 我是 Java 的新手,所以如果您能詳細(xì)說明這個問題,那將有很大幫助。謝謝;)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(); }}
查看活動中的視圖
慕的地8271018
2023-05-10 17:46:44