List of usage examples for android.support.v4.media.session MediaControllerCompat getPlaybackState
public PlaybackStateCompat getPlaybackState()
From source file:com.murati.oszk.audiobook.ui.MediaBrowserFragment.java
private void checkForUserVisibleErrors(boolean forceError) { boolean showError = forceError; // If offline, message is about the lack of connectivity: if (!NetworkHelper.isOnline(getActivity())) { mErrorMessage.setText(R.string.notification_offline); showError = true;/*from w w w .j a va2 s. c o m*/ } else { // otherwise, if state is ERROR and metadata!=null, use playback state error message: MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity()); if (controller != null && controller.getMetadata() != null && controller.getPlaybackState() != null && controller.getPlaybackState().getState() == PlaybackStateCompat.STATE_ERROR && controller.getPlaybackState().getErrorMessage() != null) { mErrorMessage.setText(controller.getPlaybackState().getErrorMessage()); showError = true; } else if (forceError) { // Finally, if the caller requested to show error, show a generic message: mErrorMessage.setText(R.string.error_loading_media); showError = true; } } mErrorView.setVisibility(showError ? View.VISIBLE : View.GONE); LogHelper.d(TAG, "checkForUserVisibleErrors. forceError=", forceError, " showError=", showError, " isOnline=", NetworkHelper.isOnline(getActivity())); }
From source file:com.torrenttunes.android.ui.MediaBrowserFragment.java
private void checkForUserVisibleErrors(boolean forceError) { boolean showError = forceError; // If offline, message is about the lack of connectivity: if (!NetworkHelper.isOnline(getActivity())) { mErrorMessage.setText(R.string.error_no_connection); showError = true;//w w w . j a v a 2 s . c o m } else { // otherwise, if state is ERROR and metadata!=null, use playback state error message: MediaControllerCompat controller = mMediaControllerProvider.getSupportMediaController(); if (controller != null && controller.getMetadata() != null && controller.getPlaybackState().getState() == PlaybackState.STATE_ERROR && controller.getPlaybackState().getErrorMessage() != null) { mErrorMessage.setText(controller.getPlaybackState().getErrorMessage()); showError = true; } else if (forceError) { // Finally, if the caller requested to show error, show a generic message: mErrorMessage.setText(R.string.error_loading_media); showError = true; } } mErrorView.setVisibility(showError ? View.VISIBLE : View.GONE); LogHelper.d(TAG, "checkForUserVisibleErrors. forceError=", forceError, " showError=", showError, " isOnline=", NetworkHelper.isOnline(getActivity())); }
From source file:com.murati.oszk.audiobook.ui.PlaybackControlsFragment.java
public void onConnected() { MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity()); LogHelper.d(TAG, "onConnected, mediaController==null? ", controller == null); if (controller != null) { onMetadataChanged(controller.getMetadata()); onPlaybackStateChanged(controller.getPlaybackState()); controller.registerCallback(mCallback); }/*from w w w. j av a 2 s . c om*/ }
From source file:com.torrenttunes.android.ui.PlaybackControlsFragment.java
public void onConnected() { MediaControllerCompat controller = mMediaControllerProvider.getSupportMediaController(); LogHelper.d(TAG, "onConnected, mediaController==null? ", controller == null); if (controller != null) { onMetadataChanged(controller.getMetadata()); onPlaybackStateChanged(controller.getPlaybackState()); controller.registerCallback(mCallback); }/*from w w w. j a va2 s.com*/ }
From source file:com.appdevper.mediaplayer.ui.PlaybackControlsFragment.java
public void onConnected() { MediaControllerCompat controller = ((FragmentActivity) getActivity()).getSupportMediaController(); LogHelper.d(TAG, "onConnected, mediaController==null? ", controller == null); if (controller != null) { onMetadataChanged(controller.getMetadata()); onPlaybackStateChanged(controller.getPlaybackState()); controller.registerCallback(mCallback); }//from w ww.j av a2s . c om }
From source file:com.classiqo.nativeandroid_32bitz.ui.PlaybackControlsFragment.java
public void onConnected() { MediaControllerCompat controller = ((FragmentActivity) getActivity()).getSupportMediaController(); LogHelper.d(TAG, "onConnected, mediaController == null ? ", controller == null); if (controller != null) { onMetadataChanged(controller.getMetadata()); onPlaybackStateChanged(controller.getPlaybackState()); controller.registerCallback(mCallback); }/*from ww w . j av a2 s .com*/ }
From source file:com.example.android.AudioArchive.ui.FullScreenPlayerActivity.java
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException { MediaControllerCompat mediaController = new MediaControllerCompat(FullScreenPlayerActivity.this, token); if (mediaController.getMetadata() == null) { finish();/*from www .j a v a 2 s. co m*/ return; } setSupportMediaController(mediaController); mediaController.registerCallback(mCallback); PlaybackStateCompat state = mediaController.getPlaybackState(); updatePlaybackState(state); MediaMetadataCompat metadata = mediaController.getMetadata(); if (metadata != null) { updateMediaDescription(metadata.getDescription()); updateDuration(metadata); } }
From source file:com.bayapps.android.robophish.ui.MediaBrowserFragment.java
private void checkForUserVisibleErrors(boolean forceError) { boolean showError = forceError; // If offline, message is about the lack of connectivity: if (!NetworkHelper.isOnline(getActivity())) { mErrorMessage.setText(R.string.error_no_connection); showError = true;/*from w w w . j av a 2 s. c o m*/ } else { // otherwise, if state is ERROR and metadata!=null, use playback state error message: MediaControllerCompat controller = ((FragmentActivity) getActivity()).getSupportMediaController(); if (controller != null && controller.getMetadata() != null && controller.getPlaybackState() != null && controller.getPlaybackState().getState() == PlaybackStateCompat.STATE_ERROR && controller.getPlaybackState().getErrorMessage() != null) { mErrorMessage.setText(controller.getPlaybackState().getErrorMessage()); showError = true; } else if (forceError) { // Finally, if the caller requested to show error, show a generic message: mErrorMessage.setText(R.string.error_loading_media); showError = true; } } mErrorView.setVisibility(showError ? View.VISIBLE : View.GONE); LogHelper.d(TAG, "checkForUserVisibleErrors. forceError=", forceError, " showError=", showError, " isOnline=", NetworkHelper.isOnline(getActivity())); }
From source file:cat.terrones.devops.radiofx.ui.FullScreenPlayerActivity.java
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException { MediaControllerCompat mediaController = new MediaControllerCompat(FullScreenPlayerActivity.this, token); if (mediaController.getMetadata() == null) { finish();/*ww w. j av a2 s . c o m*/ return; } setSupportMediaController(mediaController); mediaController.registerCallback(mCallback); PlaybackStateCompat state = mediaController.getPlaybackState(); updatePlaybackState(state); MediaMetadataCompat metadata = mediaController.getMetadata(); if (metadata != null) { updateMediaDescription(metadata.getDescription()); updateDuration(metadata); } updateProgress(); if (state != null && (state.getState() == PlaybackStateCompat.STATE_PLAYING || state.getState() == PlaybackStateCompat.STATE_BUFFERING)) { scheduleSeekbarUpdate(); } }
From source file:com.appdevper.mediaplayer.activity.FullScreenPlayerActivity.java
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException { MediaControllerCompat mediaController = new MediaControllerCompat(FullScreenPlayerActivity.this, token); if (mediaController.getMetadata() == null) { finish();/*from w ww . java 2 s .c om*/ return; } setSupportMediaController(mediaController); mediaController.registerCallback(mCallback); PlaybackStateCompat state = mediaController.getPlaybackState(); updatePlaybackState(state); MediaMetadataCompat metadata = mediaController.getMetadata(); if (metadata != null) { updateMediaDescription(metadata.getDescription()); updateDuration(metadata); } updateProgress(); if (state != null && (state.getState() == PlaybackState.STATE_PLAYING || state.getState() == PlaybackState.STATE_BUFFERING)) { scheduleSeekbarUpdate(); } }