private void showNotification(int audioPath) { if (currentTrackInfo == null) return; int playState = PLAY_STATE_PAUSED; if (player != null && !player.isPlaying()) { playState = PLAY_STATE_PLAYING; } String artist = currentTrackInfo.getArtistName(); String album = currentTrackInfo.getAlbumName(); String title = currentTrackInfo.getTitle(); Bitmap artwork = currentTrackInfo.getArtwork(); showNotification(playState, audioPath, title, artist, album, artwork); }
private void pauseTrack() { if (player.isPlaying()) { abandonAudioFocus(); player.pause(); eventBus.postSticky( new PlayStateChangedEvent(PlayStateChangedEvent.STATE_PAUSED, currentIndex)); showNotification( PLAY_STATE_PLAYING, getCurrentAudioPath(), currentTrackInfo.getTitle(), currentTrackInfo.getArtistName(), currentTrackInfo.getAlbumName(), currentTrackInfo.getArtwork()); } }
public void onEventMainThread(NotificationPreparedEvent event) { Log.d(TAG, "onEventMainThread: NotificationPreparedEvent"); long trackId = event.getTrackId(); String title = event.getTitle(); String artist = event.getArtist(); String album = event.getAlbum(); Bitmap artwork = event.getArtwork(); currentTrackInfo.setTitle(title); currentTrackInfo.setAlbumName(album); currentTrackInfo.setArtistName(artist); currentTrackInfo.setArtwork(artwork); showNotification(PLAY_STATE_PAUSED, getCurrentAudioPath(), title, artist, album, artwork); sendMetaInfoChanged(trackId, artist, album, title); sendPlayStateChanged(trackId, artist, album, title); }