List of usage examples for android.support.v4.media.session PlaybackStateCompat STATE_ERROR
int STATE_ERROR
To view the source code for android.support.v4.media.session PlaybackStateCompat STATE_ERROR.
Click Source Link
From source file:com.achep.acdisplay.services.media.MediaController2KitKat.java
@NonNull static SparseIntArray generatePlaybackCompatSparse() { SparseIntArray sia = new SparseIntArray(); sia.put(RemoteControlClient.PLAYSTATE_BUFFERING, PlaybackStateCompat.STATE_BUFFERING); sia.put(RemoteControlClient.PLAYSTATE_PLAYING, PlaybackStateCompat.STATE_PLAYING); sia.put(RemoteControlClient.PLAYSTATE_PAUSED, PlaybackStateCompat.STATE_PAUSED); sia.put(RemoteControlClient.PLAYSTATE_ERROR, PlaybackStateCompat.STATE_ERROR); sia.put(RemoteControlClient.PLAYSTATE_REWINDING, PlaybackStateCompat.STATE_REWINDING); sia.put(RemoteControlClient.PLAYSTATE_FAST_FORWARDING, PlaybackStateCompat.STATE_FAST_FORWARDING); sia.put(RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_NEXT); sia.put(RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS); return sia;/* ww w. j a v a2 s . c om*/ }
From source file:com.classiqo.nativeandroid_32bitz.playback.PlaybackManager.java
public void updatePlaybackState(String error) { LogHelper.d(TAG, "updatePlaybackState, playback state = " + mPlayback.getState()); long position = PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN; if (mPlayback != null && mPlayback.isConnected()) { position = mPlayback.getCurrentStreamPosition(); }//from w w w .j av a2 s . c o m //noinspection ResourceType PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder() .setActions(getAvailableActions()); setCustomAction(stateBuilder); int state = mPlayback.getState(); if (error != null) { stateBuilder.setErrorMessage(error); state = PlaybackStateCompat.STATE_ERROR; } //noinspection ResourceType stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime()); MediaSessionCompat.QueueItem currentMusic = mQueueManager.getCurrentMusic(); if (currentMusic != null) { stateBuilder.setActiveQueueItemId(currentMusic.getQueueId()); } mServiceCallback.onPlaybackStateUpdated(stateBuilder.build()); if (state == PlaybackStateCompat.STATE_PLAYING || state == PlaybackStateCompat.STATE_PAUSED) { mServiceCallback.onNotificationRequired(); } }
From source file:com.bullmobi.message.services.media.MediaController2KitKat.java
/** * {@inheritDoc}/*from ww w . j a v a 2 s . c o m*/ */ protected MediaController2KitKat(@NonNull Activity activity) { super(activity); SparseIntArray cachedStateSparse = sStateSparse.get(); if (cachedStateSparse == null) { mStateSparse = new SparseIntArray(); mStateSparse.put(RemoteControlClient.PLAYSTATE_BUFFERING, PlaybackStateCompat.STATE_BUFFERING); mStateSparse.put(RemoteControlClient.PLAYSTATE_PLAYING, PlaybackStateCompat.STATE_PLAYING); mStateSparse.put(RemoteControlClient.PLAYSTATE_PAUSED, PlaybackStateCompat.STATE_PAUSED); mStateSparse.put(RemoteControlClient.PLAYSTATE_ERROR, PlaybackStateCompat.STATE_ERROR); mStateSparse.put(RemoteControlClient.PLAYSTATE_REWINDING, PlaybackStateCompat.STATE_REWINDING); mStateSparse.put(RemoteControlClient.PLAYSTATE_FAST_FORWARDING, PlaybackStateCompat.STATE_FAST_FORWARDING); mStateSparse.put(RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_NEXT); mStateSparse.put(RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS); // Cache sparse array sStateSparse = new WeakReference<>(mStateSparse); } else { mStateSparse = cachedStateSparse; } }
From source file:com.classiqo.nativeandroid_32bitz.ui.BaseActivity.java
protected boolean shouldShowControls() { MediaControllerCompat mediaController = getSupportMediaController(); if (mediaController == null || mediaController.getMetadata() == null || mediaController.getPlaybackState() == null) { return false; }/*from ww w . j a v a 2 s.c om*/ switch (mediaController.getPlaybackState().getState()) { case PlaybackStateCompat.STATE_ERROR: case PlaybackStateCompat.STATE_NONE: case PlaybackStateCompat.STATE_STOPPED: return false; default: return true; } }
From source file:com.classiqo.nativeandroid_32bitz.ui.MediaItemViewHolder.java
public static int getStateFromController(Context context) { MediaControllerCompat controller = ((FragmentActivity) context).getSupportMediaController(); PlaybackStateCompat pbState = controller.getPlaybackState(); if (pbState == null || pbState.getState() == PlaybackStateCompat.STATE_ERROR) { return MediaItemViewHolder.STATE_NONE; } else if (pbState.getState() == PlaybackStateCompat.STATE_PLAYING) { return MediaItemViewHolder.STATE_PLAYING; } else {/*from ww w.j a va 2 s. c o m*/ return MediaItemViewHolder.STATE_PAUSED; } }
From source file:cat.terrones.devops.radiofx.ui.MediaItemViewHolder.java
public static int getStateFromController(Context context) { MediaControllerCompat controller = ((FragmentActivity) context).getSupportMediaController(); PlaybackStateCompat pbState = controller.getPlaybackState(); if (pbState == null || pbState.getState() == PlaybackStateCompat.STATE_ERROR) { return MediaItemViewHolder.STATE_NONE; } else if (pbState.getState() == PlaybackStateCompat.STATE_PLAYING) { return MediaItemViewHolder.STATE_PLAYING; } else {// ww w.j a v a2s.co m return MediaItemViewHolder.STATE_PAUSED; } }
From source file:com.appdevper.mediaplayer.app.PlaybackManager.java
/** * Update the current media player state, optionally showing an error message. * * @param error if not null, error message to present to the user. *//*from w w w . j a v a 2 s . co m*/ public void updatePlaybackState(String error) { LogHelper.d(TAG, "updatePlaybackState, playback state=" + mPlayback.getState()); long position = PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN; if (mPlayback != null && mPlayback.isConnected()) { position = mPlayback.getCurrentStreamPosition(); } //noinspection ResourceType PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder() .setActions(getAvailableActions()); setCustomAction(stateBuilder); int state = mPlayback.getState(); // If there is an error message, send it to the playback state: if (error != null) { // Error states are really only supposed to be used for errors that cause playback to // stop unexpectedly and persist until the user takes action to fix it. stateBuilder.setErrorMessage(error); state = PlaybackStateCompat.STATE_ERROR; } //noinspection ResourceType stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime()); // Set the activeQueueItemId if the current index is valid. MediaSessionCompat.QueueItem currentMusic = mQueueManager.getCurrentMusic(); if (currentMusic != null) { stateBuilder.setActiveQueueItemId(currentMusic.getQueueId()); } mServiceCallback.onPlaybackStateUpdated(stateBuilder.build()); if (state == PlaybackStateCompat.STATE_PLAYING || state == PlaybackStateCompat.STATE_PAUSED) { mServiceCallback.onNotificationRequired(); } }
From source file:rocks.stalin.android.app.playback.PlaybackManager.java
/** * Update the current media player state, optionally showing an error message. * * @param error if not null, error message to present to the user. *///from w w w . j a v a 2 s . com public void updatePlaybackState(String error) { LogHelper.d(TAG, "updatePlaybackState, playback state=" + mPlayback.getState()); long position = PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN; if (mPlayback != null && mPlayback.isConnected()) { position = mPlayback.getCurrentStreamPosition(); } //noinspection ResourceType PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder() .setActions(getAvailableActions()); setCustomAction(stateBuilder); int state = mPlayback.getState(); // If there is an error message, send it to the playback state: if (error != null) { // Error states are really only supposed to be used for errors that cause playback to // stop unexpectedly and persist until the user takes action to fix it. stateBuilder.setErrorMessage(PlaybackStateCompat.ERROR_CODE_UNKNOWN_ERROR, error); state = PlaybackStateCompat.STATE_ERROR; } //noinspection ResourceType stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime()); // Set the activeQueueItemId if the current index is valid. MediaSessionCompat.QueueItem currentMusic = mQueueManager.getCurrentMusic(); if (currentMusic != null) { stateBuilder.setActiveQueueItemId(currentMusic.getQueueId()); } mServiceCallback.onPlaybackStateUpdated(stateBuilder.build()); if (state == PlaybackStateCompat.STATE_PLAYING || state == PlaybackStateCompat.STATE_PAUSED) { mServiceCallback.onNotificationRequired(); } }
From source file:com.murati.oszk.audiobook.playback.PlaybackManager.java
/** * Update the current media player state, optionally showing an error message. * * @param error if not null, error message to present to the user. *//*from w w w. j a va 2s. com*/ public void updatePlaybackState(String error) { LogHelper.d(TAG, "updatePlaybackState, playback state=" + mPlayback.getState()); long position = PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN; if (mPlayback != null && mPlayback.isConnected()) { position = mPlayback.getCurrentStreamPosition(); } //noinspection ResourceType PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder() .setActions(getAvailableActions()); setCustomAction(stateBuilder); int state = mPlayback.getState(); // If there is an error message, send it to the playback state: if (error != null) { // Error states are really only supposed to be used for errors that cause playback to // stop unexpectedly and persist until the user takes action to fix it. stateBuilder.setErrorMessage(error); state = PlaybackStateCompat.STATE_ERROR; } //noinspection ResourceType stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime()); // Set the activeQueueItemId if the current index is valid. MediaSessionCompat.QueueItem currentMusic = mQueueManager.getCurrentTrack(); if (currentMusic != null) { stateBuilder.setActiveQueueItemId(currentMusic.getQueueId()); } mServiceCallback.onPlaybackStateUpdated(stateBuilder.build()); if (state == PlaybackStateCompat.STATE_PLAYING || state == PlaybackStateCompat.STATE_PAUSED) { mServiceCallback.onNotificationRequired(); } }
From source file:rocks.stalin.android.app.ui.MediaItemViewHolder.java
public static int getStateFromController(Context context) { MediaControllerCompat controller = MediaControllerCompat.getMediaController((FragmentActivity) context); PlaybackStateCompat pbState = controller.getPlaybackState(); if (pbState == null || pbState.getState() == PlaybackStateCompat.STATE_ERROR) { return MediaItemViewHolder.STATE_NONE; } else if (pbState.getState() == PlaybackStateCompat.STATE_PLAYING) { return MediaItemViewHolder.STATE_PLAYING; } else {//from w ww. j a va 2 s .co m return MediaItemViewHolder.STATE_PAUSED; } }