List of usage examples for android.support.v4.media.session PlaybackStateCompat STATE_NONE
int STATE_NONE
To view the source code for android.support.v4.media.session PlaybackStateCompat STATE_NONE.
Click Source Link
From source file:com.murati.oszk.audiobook.ui.FullScreenPlayerActivity.java
private void updatePlaybackState(PlaybackStateCompat state) { if (state == null) { return;/* w ww. ja v a 2 s. c om*/ } //TODO: Fix Time for current state mLastPlaybackState = state; MediaControllerCompat controllerCompat = MediaControllerCompat .getMediaController(FullScreenPlayerActivity.this); if (controllerCompat != null && controllerCompat.getExtras() != null) { String castName = controllerCompat.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); String line3Text = castName == null ? "" : getResources().getString(R.string.casting_to_device, castName); mLine3.setText(line3Text); } switch (state.getState()) { case PlaybackStateCompat.STATE_PLAYING: mLoading.setVisibility(INVISIBLE); mPlayPause.setVisibility(VISIBLE); mPlayPause.setImageDrawable(mPauseDrawable); mControllers.setVisibility(VISIBLE); scheduleSeekbarUpdate(); break; case PlaybackStateCompat.STATE_PAUSED: mControllers.setVisibility(VISIBLE); mLoading.setVisibility(INVISIBLE); mPlayPause.setVisibility(VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); stopSeekbarUpdate(); break; case PlaybackStateCompat.STATE_NONE: case PlaybackStateCompat.STATE_STOPPED: mLoading.setVisibility(INVISIBLE); mPlayPause.setVisibility(VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); stopSeekbarUpdate(); break; case PlaybackStateCompat.STATE_BUFFERING: mPlayPause.setVisibility(INVISIBLE); mLoading.setVisibility(VISIBLE); mLine3.setText(R.string.loading); stopSeekbarUpdate(); break; default: LogHelper.d(TAG, "Unhandled state ", state.getState()); } mSkipNext.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) == 0 ? INVISIBLE : VISIBLE); mSkipPrev.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) == 0 ? INVISIBLE : VISIBLE); }
From source file:com.scooter1556.sms.android.activity.FullScreenPlayerActivity.java
private void updatePlaybackState(PlaybackStateCompat state) { if (state == null) { return;/*from w ww. ja v a 2 s.c om*/ } lastPlaybackState = state; if (mediaController != null && mediaController.getExtras() != null) { String castName = mediaController.getExtras().getString(MediaService.EXTRA_CONNECTED_CAST); String extraInfo = castName == null ? "" : getResources().getString(R.string.cast_to_device, castName); extra.setText(extraInfo); } switch (state.getState()) { case PlaybackStateCompat.STATE_PLAYING: loading.setVisibility(INVISIBLE); playPause.setVisibility(VISIBLE); playPause.setImageDrawable(pauseDrawable); controllers.setVisibility(VISIBLE); scheduleSeekbarUpdate(); break; case PlaybackStateCompat.STATE_PAUSED: controllers.setVisibility(VISIBLE); loading.setVisibility(INVISIBLE); playPause.setVisibility(VISIBLE); playPause.setImageDrawable(playDrawable); stopSeekbarUpdate(); break; case PlaybackStateCompat.STATE_NONE: case PlaybackStateCompat.STATE_STOPPED: loading.setVisibility(INVISIBLE); playPause.setVisibility(VISIBLE); playPause.setImageDrawable(playDrawable); stopSeekbarUpdate(); break; case PlaybackStateCompat.STATE_BUFFERING: playPause.setVisibility(INVISIBLE); loading.setVisibility(VISIBLE); extra.setText(R.string.state_loading); stopSeekbarUpdate(); break; default: Log.d(TAG, "Unhandled state: " + state.getState()); } skipNext.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) == 0 ? INVISIBLE : VISIBLE); skipPrev.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) == 0 ? INVISIBLE : VISIBLE); shuffle.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE) == 0 ? INVISIBLE : VISIBLE); repeat.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SET_REPEAT_MODE) == 0 ? INVISIBLE : VISIBLE); // Custom Actions for (PlaybackStateCompat.CustomAction action : state.getCustomActions()) { switch (action.getAction()) { case MediaService.STATE_SHUFFLE_ON: shuffle.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.accent)); break; case MediaService.STATE_SHUFFLE_OFF: shuffle.clearColorFilter(); break; case MediaService.STATE_REPEAT_NONE: repeat.setImageResource(R.drawable.ic_repeat_white_24dp); repeat.clearColorFilter(); break; case MediaService.STATE_REPEAT_ALL: repeat.setImageResource(R.drawable.ic_repeat_white_24dp); repeat.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.accent)); break; case MediaService.STATE_REPEAT_ONE: repeat.setImageResource(R.drawable.ic_repeat_one_white_24dp); repeat.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.accent)); break; } } }
From source file:nuclei.media.playback.CastPlayback.java
void updatePlaybackState() { final int status = VideoCastManager.getInstance().getPlaybackStatus(); // Convert the remote playback states to media playback states. switch (status) { case MediaStatus.PLAYER_STATE_IDLE: final int idleReason = VideoCastManager.getInstance().getIdleReason(); switch (idleReason) { case MediaStatus.IDLE_REASON_ERROR: if (mCallback != null) mCallback.onError(new Exception("Error: " + idleReason), true); break; case MediaStatus.IDLE_REASON_INTERRUPTED: case MediaStatus.IDLE_REASON_CANCELED: // TODO: What should happen here? mState = PlaybackStateCompat.STATE_NONE; if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); break; case MediaStatus.IDLE_REASON_FINISHED: if (mCallback != null) mCallback.onCompletion(); break; default://from ww w. j a v a 2 s . co m setMetadataFromRemote(); if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); break; } break; case MediaStatus.PLAYER_STATE_BUFFERING: mState = PlaybackStateCompat.STATE_BUFFERING; setMetadataFromRemote(); if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); break; case MediaStatus.PLAYER_STATE_PLAYING: mState = PlaybackStateCompat.STATE_PLAYING; setMetadataFromRemote(); if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); break; case MediaStatus.PLAYER_STATE_PAUSED: mState = PlaybackStateCompat.STATE_PAUSED; setMetadataFromRemote(); if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); break; default: // case unknown setMetadataFromRemote(); if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); break; } }
From source file:rocks.stalin.android.app.playback.RemotePlayback.java
public void addClient(MessageConnection connection) { if (mState != PlaybackStateCompat.STATE_STOPPED && mState != PlaybackStateCompat.STATE_NONE) throw new RuntimeException("You can't add a client while playing... yet, You were in state: " + mState); RemotePlayerBackend remoteBackend = new RemotePlayerBackend(connection, timeProvider, scheduler); createMediaPlayerIfNeeded();/*from w w w . j a v a 2 s . c om*/ mediaPlayer.connectBackend(remoteBackend); }
From source file:com.scooter1556.sms.android.fragment.tv.TvAudioPlayerFragment.java
private void updatePlaybackState(PlaybackStateCompat state) { if (state == null || playbackControlsRow == null) { return;/*from ww w . j a v a2 s . c o m*/ } lastPlaybackState = state; switch (state.getState()) { case PlaybackStateCompat.STATE_PLAYING: scheduleSeekbarUpdate(); playPauseAction.setIndex(PlayPauseAction.PAUSE); break; case PlaybackStateCompat.STATE_PAUSED: stopSeekbarUpdate(); playPauseAction.setIndex(PlayPauseAction.PLAY); break; case PlaybackStateCompat.STATE_NONE: stopSeekbarUpdate(); playPauseAction.setIndex(PlayPauseAction.PLAY); resetPlaybackRow(); updatePlayListRow(); break; case PlaybackStateCompat.STATE_STOPPED: stopSeekbarUpdate(); playPauseAction.setIndex(PlayPauseAction.PLAY); playbackControlsRow.setCurrentTime(0); break; case PlaybackStateCompat.STATE_BUFFERING: stopSeekbarUpdate(); break; default: Log.d(TAG, "Unhandled state: " + state.getState()); } // Custom Actions for (PlaybackStateCompat.CustomAction action : state.getCustomActions()) { switch (action.getAction()) { case MediaService.STATE_SHUFFLE_ON: shuffleAction.setIcon( ContextCompat.getDrawable(getActivity(), R.drawable.ic_shuffle_enabled_white_48dp)); // Update interface if necessary if (shuffleMode == null || !shuffleMode.equals(MediaService.STATE_SHUFFLE_ON)) { shuffleMode = MediaService.STATE_SHUFFLE_ON; updatePlayListRow(); } break; case MediaService.STATE_SHUFFLE_OFF: shuffleAction.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_shuffle_white_48dp)); // Update interface if necessary if (shuffleMode == null || !shuffleMode.equals(MediaService.STATE_SHUFFLE_OFF)) { shuffleMode = MediaService.STATE_SHUFFLE_OFF; updatePlayListRow(); } break; case MediaService.STATE_REPEAT_NONE: repeatAction.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_repeat_white_48dp)); break; case MediaService.STATE_REPEAT_ALL: repeatAction .setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_repeat_enable_white_48dp)); break; case MediaService.STATE_REPEAT_ONE: repeatAction.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_repeat_one_white_48dp)); break; } } rowsAdapter.notifyArrayItemRangeChanged(rowsAdapter.indexOf(playbackControlsRow), 1); }
From source file:org.runbuddy.tomahawk.activities.TomahawkMainActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); PipeLine.get();/* w w w. j ava2s.c o m*/ CollectionManager.get().getUserCollection().loadMediaItems(false); setContentView(R.layout.tomahawk_main_activity); mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, PlaybackService.class), mConnectionCallback, null); setVolumeControlStream(AudioManager.STREAM_MUSIC); mSmoothProgressBar = (SmoothProgressBar) findViewById(R.id.smoothprogressbar); mTitle = mDrawerTitle = getTitle().toString().toUpperCase(); getSupportActionBar().setTitle(""); mPlaybackPanel = (PlaybackPanel) findViewById(R.id.playback_panel); mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); FragmentUtils.addPlaybackFragment(this); mPanelSlideListener = new TomahawkPanelSlideListener(this, mSlidingUpPanelLayout, mPlaybackPanel); mSlidingUpPanelLayout.setPanelSlideListener(mPanelSlideListener); if (mPlaybackState != PlaybackStateCompat.STATE_NONE) { showPanel(); } else { hidePanel(); } mActionBarBg = findViewById(R.id.action_bar_background); mMenuDrawer = (MenuDrawer) findViewById(R.id.drawer_layout); if (mMenuDrawer != null) { mDrawerToggle = new ActionBarDrawerToggle(this, mMenuDrawer, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(mDrawerTitle); if (mSearchItem != null) { MenuItemCompat.collapseActionView(mSearchItem); } } }; // Set the drawer toggle as the DrawerListener mMenuDrawer.addDrawerListener(mDrawerToggle); } // set customization variables on the ActionBar final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowCustomEnabled(true); //Setup UserVoice Config config = new Config("tomahawk.uservoice.com"); config.setForumId(224204); config.setTopicId(62613); UserVoice.init(config, TomahawkMainActivity.this); //Resolve currently logged-in user User.getSelf().done(new DoneCallback<User>() { @Override public void onDone(User user) { String requestId = InfoSystem.get().resolve(user); if (requestId != null) { mCorrespondingRequestIds.add(requestId); } } }); //Ask for notification service access if hatchet user logged in PreferenceUtils.attemptAskAccess(this); User.getSelf().done(new DoneCallback<User>() { @Override public void onDone(final User user) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (!mDestroyed) { FragmentUtils.addRootFragment(TomahawkMainActivity.this, user); if (!PreferenceUtils.getBoolean(PreferenceUtils.COACHMARK_WELCOMEFRAGMENT_DISABLED)) { FragmentUtils.replace(TomahawkMainActivity.this, WelcomeFragment.class, null); } } } }); } }); handleIntent(getIntent()); /********************2016.08.10**********************/ /* public void loadMultipleRootFragment(int containerId, int showPosition, SupportFragment... toFragments) { mFragmentation.loadMultipleRootTransaction(getSupportFragmentManager(), containerId, showPosition, toFragments);//?public,? }*/ //initView(); }
From source file:com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.java
private void updateMediaSessionPlaybackState() { PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder(); if (player == null) { builder.setActions(buildPlaybackActions()).setState(PlaybackStateCompat.STATE_NONE, 0, 0, 0); mediaSession.setPlaybackState(builder.build()); return;/*from w w w .j av a 2 s . c om*/ } Map<String, CustomActionProvider> currentActions = new HashMap<>(); for (CustomActionProvider customActionProvider : customActionProviders) { PlaybackStateCompat.CustomAction customAction = customActionProvider.getCustomAction(); if (customAction != null) { currentActions.put(customAction.getAction(), customActionProvider); builder.addCustomAction(customAction); } } customActionMap = Collections.unmodifiableMap(currentActions); int sessionPlaybackState = playbackException != null ? PlaybackStateCompat.STATE_ERROR : mapPlaybackState(player.getPlaybackState(), player.getPlayWhenReady()); if (playbackException != null) { if (errorMessageProvider != null) { Pair<Integer, String> message = errorMessageProvider.getErrorMessage(playbackException); builder.setErrorMessage(message.first, message.second); } if (player.getPlaybackState() != Player.STATE_IDLE) { playbackException = null; } } long activeQueueItemId = queueNavigator != null ? queueNavigator.getActiveQueueItemId(player) : MediaSessionCompat.QueueItem.UNKNOWN_ID; Bundle extras = new Bundle(); extras.putFloat(EXTRAS_PITCH, player.getPlaybackParameters().pitch); builder.setActions(buildPlaybackActions()).setActiveQueueItemId(activeQueueItemId) .setBufferedPosition(player.getBufferedPosition()) .setState(sessionPlaybackState, player.getCurrentPosition(), player.getPlaybackParameters().speed, SystemClock.elapsedRealtime()) .setExtras(extras); mediaSession.setPlaybackState(builder.build()); }
From source file:nuclei.media.playback.ExoPlayerPlayback.java
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (LOG.isLoggable(Log.DEBUG)) LOG.d("onStateChanged=" + playbackState + ", " + playWhenReady); if (!mPrepared && playbackState == ExoPlayer.STATE_READY && mMediaPlayer != null) { mPrepared = true;//from ww w .j a v a 2 s.c o m if (!mWakeLock.isHeld()) mWakeLock.acquire(); if (!mWifiLock.isHeld()) mWifiLock.acquire(); configMediaPlayerState(true, false); setSurface(mSurfaceId, mSurface); mMediaPlayer.seekTo(mCurrentPosition); mMediaPlayer.setPlayWhenReady(mPlayWhenReady); } else if (mMediaPlayer != null && mState != PlaybackStateCompat.STATE_ERROR && mState != PlaybackStateCompat.STATE_BUFFERING) mCurrentPosition = mMediaPlayer.getCurrentPosition(); if (mMediaPlayer != null && mMediaMetadata != null) { final long duration = getDuration(); if (mMediaMetadata.getLong(MediaMetadataCompat.METADATA_KEY_DURATION) != duration) mMediaMetadata.setDuration(duration); } switch (playbackState) { case ExoPlayer.STATE_BUFFERING: mState = PlaybackStateCompat.STATE_BUFFERING; mIllegalStateRetries = 0; break; case ExoPlayer.STATE_ENDED: mState = PlaybackStateCompat.STATE_NONE; mIllegalStateRetries = 0; break; case ExoPlayer.STATE_IDLE: if (mState != PlaybackStateCompat.STATE_ERROR) mState = PlaybackStateCompat.STATE_NONE; break; case ExoPlayer.STATE_READY: mIllegalStateRetries = 0; if (isMediaPlayerPlaying()) { mState = PlaybackStateCompat.STATE_PLAYING; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (mPlaybackParams != null) mMediaPlayer.setPlaybackParameters(mPlaybackParams); } } else mState = PlaybackStateCompat.STATE_PAUSED; break; default: mState = PlaybackStateCompat.STATE_NONE; break; } if (mCallback != null) mCallback.onPlaybackStatusChanged(mState); if (playbackState == ExoPlayer.STATE_ENDED) { mRestart = true; if (mCallback != null) mCallback.onCompletion(); } }
From source file:com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.java
private int mapPlaybackState(int exoPlayerPlaybackState, boolean playWhenReady) { switch (exoPlayerPlaybackState) { case Player.STATE_BUFFERING: return PlaybackStateCompat.STATE_BUFFERING; case Player.STATE_READY: return playWhenReady ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; case Player.STATE_ENDED: return PlaybackStateCompat.STATE_PAUSED; default:/*from w ww .j ava 2s . c o m*/ return PlaybackStateCompat.STATE_NONE; } }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
@Override public void onPlaybackStateChanged(int state) { switch (state) { case PlaybackStateCompat.STATE_PLAYING: mHandler.removeMessages(MSG_HIDE_MEDIA_WIDGET); makeMediaWidgetActive();/*from ww w .jav a 2s . c o m*/ break; default: if (mMediaWidgetActive) { int delay = 6000; // 6 sec. if (state == PlaybackStateCompat.STATE_NONE) delay = 500; mHandler.sendEmptyMessageDelayed(MSG_HIDE_MEDIA_WIDGET, delay); } break; } }