List of usage examples for android.media RemoteControlClient PLAYSTATE_PLAYING
int PLAYSTATE_PLAYING
To view the source code for android.media RemoteControlClient PLAYSTATE_PLAYING.
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;/*from www. j a va2 s . co m*/ }
From source file:com.bullmobi.message.services.media.MediaController2KitKat.java
/** * {@inheritDoc}//from www.j a va 2 s .com */ 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:org.amahi.anywhere.service.AudioService.java
private void setUpAudioPlayerRemote() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName audioReceiver = new ComponentName(getPackageName(), AudioReceiver.class.getName()); Intent audioIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); audioIntent.setComponent(audioReceiver); PendingIntent audioPendingIntent = PendingIntent.getBroadcast(this, 0, audioIntent, 0); audioPlayerRemote = new RemoteControlClient(audioPendingIntent); audioPlayerRemote.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS); audioPlayerRemote.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); audioManager.registerMediaButtonEventReceiver(audioReceiver); audioManager.registerRemoteControlClient(audioPlayerRemote); }
From source file:github.popeen.dsub.util.compat.RemoteControlClientLP.java
@Override public void setPlaybackState(int state, int index, int queueSize) { PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder(); int newState = PlaybackStateCompat.STATE_NONE; switch (state) { case RemoteControlClient.PLAYSTATE_PLAYING: newState = PlaybackStateCompat.STATE_PLAYING; break;/*w w w .ja v a2 s. c o m*/ case RemoteControlClient.PLAYSTATE_STOPPED: newState = PlaybackStateCompat.STATE_STOPPED; break; case RemoteControlClient.PLAYSTATE_PAUSED: newState = PlaybackStateCompat.STATE_PAUSED; break; case RemoteControlClient.PLAYSTATE_BUFFERING: newState = PlaybackStateCompat.STATE_BUFFERING; break; } long position = -1; if (state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) { position = downloadService.getPlayerPosition(); } builder.setState(newState, position, 1.0f); DownloadFile downloadFile = downloadService.getCurrentPlaying(); Entry entry = null; boolean isSong = true; if (downloadFile != null) { entry = downloadFile.getSong(); isSong = entry.isSong(); } builder.setActions(getPlaybackActions(isSong, index, queueSize)); if (entry != null) { addCustomActions(entry, builder); builder.setActiveQueueItemId(entry.getId().hashCode()); } PlaybackStateCompat playbackState = builder.build(); mediaSession.setPlaybackState(playbackState); previousState = state; }
From source file:be.ugent.zeus.hydra.util.audiostream.MusicService.java
void processPlayRequest() { tryToGetAudioFocus();/*from www .jav a 2s. c o m*/ // actually play the song if (mState == State.Stopped) { // If we're stopped, just go ahead to the next song and start playing playStream(); } else if (mState == State.Paused) { // If we're paused, just continue playback and restore the 'foreground service' state. mState = State.Playing; setUpAsForeground(mSongTitle + " (playing)"); configAndStartMediaPlayer(); } // Tell any remote controls that our playback state is 'playing'. if (mRemoteControlClientCompat != null) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } }
From source file:org.amahi.anywhere.service.AudioService.java
public void playAudio() { audioPlayer.start(); audioPlayerRemote.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); }
From source file:com.yamin.kk.service.AudioService.java
/** * A function to control the Remote Control Client. It is needed for * compatibility with devices below Ice Cream Sandwich (4.0). * * @param p Playback state/*from w w w.j av a 2 s .c om*/ */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setRemoteControlClientPlaybackState(int state) { if (!Util.isICSOrLater() || mRemoteControlClient == null) return; switch (state) { case EventHandler.MediaPlayerPlaying: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); break; case EventHandler.MediaPlayerPaused: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); break; case EventHandler.MediaPlayerStopped: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); break; } }
From source file:com.dzt.musicplay.player.AudioService.java
/** * A function to control the Remote Control Client. It is needed for * compatibility with devices below Ice Cream Sandwich (4.0). * /* w w w. j a va2 s . c om*/ * @param p * Playback state */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setRemoteControlClientPlaybackState(int state) { if (!LibVlcUtil.isICSOrLater() || mRemoteControlClient == null) return; switch (state) { case EventHandler.MediaPlayerPlaying: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); break; case EventHandler.MediaPlayerPaused: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); break; case EventHandler.MediaPlayerStopped: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); break; } }
From source file:org.videolan.vlc.PlaybackService.java
/** * A function to control the Remote Control Client. It is needed for * compatibility with devices below Ice Cream Sandwich (4.0). * * @param state Playback state//from w ww .ja v a2s .c o m */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setRemoteControlClientPlaybackState(int state) { if (!AndroidUtil.isICSOrLater() || mRemoteControlClient == null) return; switch (state) { case EventHandler.MediaPlayerPlaying: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); break; case EventHandler.MediaPlayerPaused: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); break; case EventHandler.MediaPlayerStopped: mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); break; } }
From source file:com.iamplus.musicplayer.MusicService.java
void processTogglePlaybackRequest() { //If no audio focus return if (mAudioFocus != AudioFocus.Focused) { tryToGetAudioFocus();//from w ww . jav a 2 s .c o m if (mAudioFocus != AudioFocus.Focused) { Toast.makeText(getApplicationContext(), R.string.audio_focus_unavailable, Toast.LENGTH_SHORT) .show(); return; } } if (mState == State.Paused) { // If we're paused, just continue playback and restore the 'foreground service' state. mState = State.Playing; //setUpAsForeground(mSongTitle + " (playing)"); configAndStartMediaPlayer(); // Tell any remote controls that our playback state is 'playing'. if (mRemoteControlClientCompat != null) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } } else if (mState == State.Stopped) { processPlayRequest(); } else { processPauseRequest(); } if (mPlayerEventListener != null) { mPlayerEventListener.onPlayPauseStateChanged(); } }