Search in sources :

Example 16 with Media

use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.

the class SingleRowAppWidgetProvider method bindViews.

private void bindViews(@NonNull final Context context, @NonNull final AppWidgetManager appWidgetManager, @NonNull final int[] appWidgetIds, @PlaybackState final int state) {
    final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_single_row);
    final Media media = currentMediaProvider.getCurrentMedia();
    final boolean hasMedia = media != null;
    views.setImageViewResource(R.id.appwidget_btn_play_pause, state == PlaybackState.STATE_PLAYING ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp);
    if (hasMedia) {
        setPlayPauseButtonAction(context, views);
        setPrevButtonAction(context, views);
        setNextButtonAction(context, views);
    } else {
        final PendingIntent playAnything = generatePlayAnythingIntent(context);
        setButtonAction(views, R.id.appwidget_btn_play_pause, playAnything);
        setButtonAction(views, R.id.appwidget_btn_prev, playAnything);
        setButtonAction(views, R.id.appwidget_btn_next, playAnything);
    }
    setCoverClickAction(context, views, hasMedia);
    CharSequence artist = media != null ? media.getArtist() : null;
    CharSequence title = media != null ? media.getTitle() : null;
    if (TextUtils.isEmpty(artist)) {
        artist = context.getText(R.string.Unknown_artist);
    }
    if (TextUtils.isEmpty(title)) {
        title = context.getText(R.string.Untitled);
    }
    views.setTextViewText(R.id.appwidget_text_artist, artist);
    views.setTextViewText(R.id.appwidget_text_title, title);
    final Bitmap thumb = albumThumbHolder.getAlbumThumb();
    if (thumb != null) {
        views.setImageViewBitmap(R.id.appwidget_img_albumart, thumb);
    } else {
        views.setImageViewResource(R.id.appwidget_img_albumart, R.drawable.album_art_placeholder);
    }
    appWidgetManager.updateAppWidget(appWidgetIds, views);
}
Also used : RemoteViews(android.widget.RemoteViews) Bitmap(android.graphics.Bitmap) Media(com.doctoror.fuckoffmusicplayer.domain.queue.Media) PendingIntent(android.app.PendingIntent)

Example 17 with Media

use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.

the class PlaybackAndroidService method onActionSeek.

private void onActionSeek(final float positionPercent) {
    final Media media = currentMediaProvider.getCurrentMedia();
    if (media != null) {
        final long duration = media.getDuration();
        if (duration > 0) {
            final int position = (int) ((float) duration * positionPercent);
            playbackData.setMediaPosition(position);
            service.seek(position);
        }
    }
}
Also used : Media(com.doctoror.fuckoffmusicplayer.domain.queue.Media)

Example 18 with Media

use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.

the class QueueActivity method onPlayClick.

private void onPlayClick(@NonNull final View clickedView, final int queuePosition) {
    mPlaybackInitializer.setQueueAndPlay(queue, queuePosition);
    final Media media = CollectionUtils.getItemSafe(queue, queuePosition);
    final boolean shouldPassCoverView = mAppbarOffset == 0 && TextUtils.equals(mCoverUri, media != null ? media.getAlbumArt() : null);
    if (shouldPassCoverView) {
        prepareViewsAndExit(() -> startNowPlayingActivity(albumArt, null));
    } else {
        mFabAnchorParams = CoordinatorLayoutUtil.getAnchorParams(fab);
        CoordinatorLayoutUtil.clearAnchorGravityAndApplyMargins(fab);
        startNowPlayingActivity(null, clickedView);
    }
}
Also used : Media(com.doctoror.fuckoffmusicplayer.domain.queue.Media)

Example 19 with Media

use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.

the class QueueActivity method onPlaybackStateChanged.

@WorkerThread
private void onPlaybackStateChanged(@PlaybackState final int state) {
    final Media media = state == PlaybackState.STATE_PLAYING ? currentMediaProvider.getCurrentMedia() : null;
    // noinspection WrongThread
    runOnUiThread(() -> onNowPlayingMediaChanged(media));
}
Also used : Media(com.doctoror.fuckoffmusicplayer.domain.queue.Media) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

Media (com.doctoror.fuckoffmusicplayer.domain.queue.Media)19 NonNull (android.support.annotation.NonNull)6 WorkerThread (android.support.annotation.WorkerThread)6 Cursor (android.database.Cursor)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Bitmap (android.graphics.Bitmap)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 PopupMenu (android.widget.PopupMenu)1 RemoteViews (android.widget.RemoteViews)1 PlaybackReporter (com.doctoror.fuckoffmusicplayer.domain.reporter.PlaybackReporter)1 File (java.io.File)1 LinkedHashSet (java.util.LinkedHashSet)1