@Override public void onUpdate() { Song nowPlaying = PlayerController.getNowPlaying(); if (nowPlaying != null) { songTitle.setText(nowPlaying.getSongName()); songArtist.setText(nowPlaying.getArtistName()); songAlbum.setText(nowPlaying.getAlbumName()); int duration = PlayerController.getDuration(); timeDuration.setTime(duration); seekBar.setMax(duration); if (!observer.isRunning()) { observerThread = new Thread(observer); observerThread.start(); } } else { songTitle.setText(R.string.nothing_playing); songArtist.setText(R.string.unknown_artist); songAlbum.setText(R.string.unknown_album); } seekBar.setEnabled(nowPlaying != null); if (PlayerController.isPlaying()) { playPauseButton.setImageResource(R.drawable.ic_pause_36dp); } else { playPauseButton.setImageResource(R.drawable.ic_play_arrow_36dp); } }
@Override public void onUpdate() { final boolean wasRunning = run; run = PlayerController.isPlaying(); if (!wasRunning && run) { parent.observerThread.run(); } }