List of usage examples for android.media RemoteControlClient FLAG_KEY_MEDIA_PAUSE
int FLAG_KEY_MEDIA_PAUSE
To view the source code for android.media RemoteControlClient FLAG_KEY_MEDIA_PAUSE.
Click Source Link
From source file:com.wojtechnology.sunami.MediaSessionCompatHelper.java
private static void ensureTransportControls(MediaSessionCompat session, PlaybackStateCompat playbackState) { long actions = playbackState.getActions(); Object remoteObj = session.getRemoteControlClient(); if (actions != 0 && remoteObj != null) { int transportControls = 0; if ((actions & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS; }/*from w w w .jav a 2 s . co m*/ if ((actions & PlaybackStateCompat.ACTION_REWIND) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_REWIND; } if ((actions & PlaybackStateCompat.ACTION_PLAY) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PLAY; } if ((actions & PlaybackStateCompat.ACTION_PLAY_PAUSE) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE; } if ((actions & PlaybackStateCompat.ACTION_PAUSE) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_PAUSE; } if ((actions & PlaybackStateCompat.ACTION_STOP) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_STOP; } if ((actions & PlaybackStateCompat.ACTION_FAST_FORWARD) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD; } if ((actions & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_NEXT; } if ((actions & PlaybackStateCompat.ACTION_SEEK_TO) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE; } if ((actions & PlaybackStateCompat.ACTION_SET_RATING) != 0) { transportControls |= RemoteControlClient.FLAG_KEY_MEDIA_RATING; } ((RemoteControlClient) remoteObj).setTransportControlFlags(transportControls); } }
From source file:com.ferdi2005.secondgram.MusicPlayerService.java
@SuppressLint("NewApi") @Override//from w w w . j av a 2s .co m public int onStartCommand(Intent intent, int flags, int startId) { try { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { FileLog.e(e); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.b44t.messenger.MusicPlayerService.java
@SuppressLint("NewApi") @Override/*from w w w. j a v a 2 s . co m*/ public int onStartCommand(Intent intent, int flags, int startId) { try { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { FileLog.e("messenger", e); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.dmplayer.manager.MusicPlayerService.java
@SuppressLint("NewApi") @Override// w w w . ja v a2s. c om public int onStartCommand(Intent intent, int flags, int startId) { try { SongDetail messageObject = MediaController.getInstance().getPlayingSongDetail(); if (messageObject == null) { DMPlayerUtility.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { Log.e("tmessages", e.toString()); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:in.risysnetworks.shplayer.mediacontroller.MusicPlayerService.java
@SuppressLint("NewApi") @Override/*from w w w .ja v a 2s .c o m*/ public int onStartCommand(Intent intent, int flags, int startId) { try { SongDetail messageObject = MediaController.getInstance().getPlayingSongDetail(); if (messageObject == null) { SHPlayerUtility.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { Log.e("tmessages", e.toString()); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.goftagram.telegram.messenger.MusicPlayerService.java
@SuppressLint("NewApi") @Override/* w w w . j av a2 s.c o m*/ public int onStartCommand(Intent intent, int flags, int startId) { try { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { FileLog.e("tmessages", e); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:co.codecrunch.musicplayerlite.manager.MusicPlayerService.java
@SuppressLint("NewApi") @Override//w w w . j av a 2 s . c o m public int onStartCommand(Intent intent, int flags, int startId) { try { SongDetail messageObject = MediaController.getInstance().getPlayingSongDetail(); if (messageObject == null) { MusicPlayerUtility.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { Log.e("tmessages", e.toString()); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.namelessdev.mpdroid.NotificationService.java
/** * This registers some media buttons via the RemoteControlReceiver.class which will take * action by intent to this onStartCommand(). *//*from w w w. j a v a 2s.co m*/ private void registerMediaButtons() { mMediaButtonReceiverComponent = new ComponentName(this, RemoteControlReceiver.class); mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent); final Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.setComponent(mMediaButtonReceiverComponent); mRemoteControlClient = new RemoteControlClient(PendingIntent.getBroadcast(this /*context*/, 0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/)); final int controlFlags = RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP; mRemoteControlClient.setTransportControlFlags(controlFlags); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { enableSeeking(controlFlags); } mAudioManager.registerRemoteControlClient(mRemoteControlClient); }
From source file:org.videolan.vlc.AudioService.java
/** * Set up the remote control and tell the system we want to be the default receiver for the MEDIA buttons * @see http://android-developers.blogspot.fr/2010/06/allowing-applications-to-play-nicer.html *//* w w w . j a v a 2 s . c o m*/ @TargetApi(14) public void setUpRemoteControlClient() { Context context = VLCApplication.getAppContext(); AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE); if (Util.isICSOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); if (mRemoteControlClient == null) { Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mRemoteControlClientReceiverComponent); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0, mediaButtonIntent, 0); // create and register the remote control client mRemoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(mRemoteControlClient); } mRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP); } else if (Util.isFroyoOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); } }
From source file:com.yamin.kk.service.AudioService.java
/** * Set up the remote control and tell the system we want to be the default receiver for the MEDIA buttons * @see http://android-developers.blogspot.fr/2010/06/allowing-applications-to-play-nicer.html *///from w w w. j a v a 2 s .c o m @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setUpRemoteControlClient() { Context context = VLCApplication.getAppContext(); AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE); if (Util.isICSOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); if (mRemoteControlClient == null) { Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mRemoteControlClientReceiverComponent); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0, mediaButtonIntent, 0); // create and register the remote control client mRemoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(mRemoteControlClient); } mRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP); } else if (Util.isFroyoOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); } }