Java Code Examples for android.support.v4.media.session.PlaybackStateCompat#STATE_SKIPPING_TO_NEXT

The following examples show how to use android.support.v4.media.session.PlaybackStateCompat#STATE_SKIPPING_TO_NEXT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerView.java    From Bop with Apache License 2.0 5 votes vote down vote up
private void updatePlaybackState(PlaybackStateCompat state) {
    if (state == null) {
        return;
    }

    switch (state.getState()) {
        case PlaybackStateCompat.STATE_PLAYING:
            mFabView.setImageDrawable((ExtraUtils.getThemedIcon(getApplicationContext(), ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_pause))));
            break;
        case PlaybackStateCompat.STATE_PAUSED:
            mFabView.setImageDrawable((ExtraUtils.getThemedIcon(getApplicationContext(), ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_play))));
            break;
        case PlaybackStateCompat.STATE_NONE:
            break;
        case PlaybackStateCompat.STATE_STOPPED:
            finish();
            break;
        default:
        case PlaybackStateCompat.STATE_BUFFERING:
            break;
        case PlaybackStateCompat.STATE_CONNECTING:
            break;
        case PlaybackStateCompat.STATE_ERROR:
            break;
        case PlaybackStateCompat.STATE_FAST_FORWARDING:
            break;
        case PlaybackStateCompat.STATE_REWINDING:
            break;
        case PlaybackStateCompat.STATE_SKIPPING_TO_NEXT:
            break;
        case PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS:
            break;
        case PlaybackStateCompat.STATE_SKIPPING_TO_QUEUE_ITEM:
            break;
    }

}
 
Example 2
Source File: RemoteControlCompat.java    From Noyze with Apache License 2.0 5 votes vote down vote up
public static boolean isPlaying(PlaybackStateCompat state) {
    if (null == state) return false;
    switch (state.getState()) {
        case PlaybackStateCompat.STATE_PLAYING:
        case PlaybackStateCompat.STATE_FAST_FORWARDING:
        case PlaybackStateCompat.STATE_REWINDING:
        case PlaybackStateCompat.STATE_SKIPPING_TO_NEXT:
        case PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS:
            return true;
    }
    return false;
}
 
Example 3
Source File: RemoteControlCompat.java    From Noyze with Apache License 2.0 5 votes vote down vote up
public static boolean isPlaying(PlaybackStateCompat state) {
    if (null == state) return false;
    switch (state.getState()) {
        case PlaybackStateCompat.STATE_PLAYING:
        case PlaybackStateCompat.STATE_FAST_FORWARDING:
        case PlaybackStateCompat.STATE_REWINDING:
        case PlaybackStateCompat.STATE_SKIPPING_TO_NEXT:
        case PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS:
            return true;
    }
    return false;
}
 
Example 4
Source File: MediaNotificationManager.java    From YouTube-In-Background with MIT License 4 votes vote down vote up
/**
 * This may look strange, but the documentation for [Service.startForeground]
 * notes that "calling this method does *not* put the service in the started
 * state itself, even though the name sounds like it."
 *
 * @param state current playback state
 */
private void updateNotification(PlaybackStateCompat state)
{
    int updatedState = state.getState();

    // Skip building a notification when state is "none" and metadata is null.
    Notification notification = skipBuildNotification(updatedState) ? buildNotification(sessionToken) : null;

    if (notification != null && !hasRegisterReceiver) {
        mediaController.registerCallback(callback);
        IntentFilter filter = new IntentFilter();
        filter.addAction(CUSTOM_ACTION_NEXT);
        filter.addAction(CUSTOM_ACTION_PAUSE);
        filter.addAction(CUSTOM_ACTION_PLAY);
        filter.addAction(CUSTOM_ACTION_PREV);
        filter.addAction(CUSTOM_ACTION_STOP);
        exoAudioService.registerReceiver(this, filter);
        hasRegisterReceiver = true;
    }

    switch (updatedState) {
        case STATE_BUFFERING:
        case STATE_PLAYING:
            if (notification != null) {
                notificationManager.notify(NOTIFICATION_ID, notification);
            }

            if (!isForegroundService) {
                Intent intent = new Intent(context, BackgroundExoAudioService.class);
                ContextCompat.startForegroundService(context, intent);
                exoAudioService.startForeground(NOTIFICATION_ID, notification);
                isForegroundService = true;
            }

            break;
        case PlaybackStateCompat.STATE_CONNECTING:
        case PlaybackStateCompat.STATE_ERROR:
        case PlaybackStateCompat.STATE_FAST_FORWARDING:
        case PlaybackStateCompat.STATE_NONE:
        case PlaybackStateCompat.STATE_PAUSED:
        case PlaybackStateCompat.STATE_REWINDING:
        case PlaybackStateCompat.STATE_SKIPPING_TO_NEXT:
        case PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS:
        case PlaybackStateCompat.STATE_SKIPPING_TO_QUEUE_ITEM:
        case PlaybackStateCompat.STATE_STOPPED:
            if (isForegroundService) {
                exoAudioService.stopForeground(false);
                isForegroundService = false;

                // If playback has ended, also stop the service.
                if (updatedState == PlaybackStateCompat.STATE_NONE) {
                    exoAudioService.stopSelf();
                }

                if (notification != null) {
                    notificationManager.notify(NOTIFICATION_ID, notification);
                } else {
                    removeNowPlayingNotification();
                }
            }

            break;
    }
}