List of usage examples for android.media RemoteControlClient FLAG_KEY_MEDIA_PREVIOUS
int FLAG_KEY_MEDIA_PREVIOUS
To view the source code for android.media RemoteControlClient FLAG_KEY_MEDIA_PREVIOUS.
Click Source Link
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 *///from 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 ww .j av a2 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); } }
From source file:org.videolan.myvlc.core.mediaController.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 *///www . j ava 2 s . com @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setUpRemoteControlClient() { Context context = MyVLCApp.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:org.videolan.vlc.audio.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 ww w .j a va 2 s . c om @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setUpRemoteControlClient() { Context context = VLCApplication.getAppContext(); AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE); if (LibVlcUtil.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 (LibVlcUtil.isFroyoOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); } }
From source file:com.dzt.musicplay.player.AudioService.java
/** * Set up the remote control and tell the system we want to be the default * receiver for the MEDIA buttons//from w ww .j av a2 s . c o m * * @see http * ://android-developers.blogspot.fr/2010/06/allowing-applications-to * -play-nicer.html */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setUpRemoteControlClient() { Context context = getApplicationContext(); AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE); if (LibVlcUtil.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 (LibVlcUtil.isFroyoOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); } }
From source file:org.videolan.vlc.PlaybackService.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 www . j av a 2s . c o m @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setUpRemoteControlClient() { Context context = VLCApplication.getAppContext(); AudioManager audioManager = (AudioManager) VLCApplication.getAppContext().getSystemService(AUDIO_SERVICE); if (AndroidUtil.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 (AndroidUtil.isFroyoOrLater()) { audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent); } }
From source file:com.Duo.music.player.Services.AudioPlaybackService.java
/** * Initializes remote control clients for this service session. * Currently used for lockscreen controls. *///from w w w . ja v a 2 s .c om public void initRemoteControlClient() { if (mRemoteControlClientCompat == null) { Intent remoteControlIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); remoteControlIntent.setComponent(mMediaButtonReceiverComponent); mRemoteControlClientCompat = new RemoteControlClientCompat( PendingIntent.getBroadcast(mContext, 0, remoteControlIntent, 0)); RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat); } mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); mRemoteControlClientCompat.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS); }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MediaPlaybackService.java
@Override public void onCreate() { super.onCreate(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName rec = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(rec); Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON); i.setComponent(rec);/*from ww w . j a v a2 s . c o m*/ PendingIntent pi = PendingIntent.getBroadcast(this /*context*/, 0 /*requestCode, ignored*/, i /*intent*/, 0 /*flags*/); mRemoteControlClient = new RemoteControlClient(pi); mAudioManager.registerRemoteControlClient(mRemoteControlClient); int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP; mRemoteControlClient.setTransportControlFlags(flags); mPreferences = getSharedPreferences("Music", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE); mCardId = MusicUtils.getCardId(this); registerExternalStorageListener(); // Needs to be done in this thread, since otherwise ApplicationContext.getPowerManager() crashes. mPlayer = new MultiPlayer(); mPlayer.setHandler(mMediaplayerHandler); reloadQueue(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); IntentFilter commandFilter = new IntentFilter(); commandFilter.addAction(SERVICECMD); commandFilter.addAction(TOGGLEPAUSE_ACTION); commandFilter.addAction(PAUSE_ACTION); commandFilter.addAction(NEXT_ACTION); commandFilter.addAction(PREVIOUS_ACTION); registerReceiver(mIntentReceiver, commandFilter); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); mWakeLock.setReferenceCounted(false); // If the service was idle, but got killed before it stopped itself, the // system will relaunch it. Make sure it gets stopped again in that case. Message msg = mDelayedStopHandler.obtainMessage(); mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY); }
From source file:de.qspool.clementineremote.backend.ClementinePlayerConnection.java
/** * Register the RemoteControlClient// w ww .ja v a2 s . c om */ private void registerRemoteControlClient() { // Request AudioFocus, so the widget is shown on the lock-screen mAudioManager.requestAudioFocus(mOnAudioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); mAudioManager.registerMediaButtonEventReceiver(mClementineMediaButtonEventReceiver); // Create the intent Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mClementineMediaButtonEventReceiver); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(App.mApp.getApplicationContext(), 0, mediaButtonIntent, 0); // Create the client mRcClient = new RemoteControlClient(mediaPendingIntent); if (App.mClementine.getState() == Clementine.State.PLAY) { mRcClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } else { mRcClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); } mRcClient.setTransportControlFlags( RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE); mAudioManager.registerRemoteControlClient(mRcClient); }
From source file:com.andrew.apolloMod.service.ApolloService.java
@SuppressLint({ "WorldWriteableFiles", "WorldReadableFiles" }) @Override//from w ww . j a v a2 s . c om public void onCreate() { super.onCreate(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName rec = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(rec); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(rec); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (Constants.isApi14Supported()) { mRemoteControlClient = new RemoteControlClient(mediaPendingIntent); mAudioManager.registerRemoteControlClient(mRemoteControlClient); int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP; mRemoteControlClient.setTransportControlFlags(flags); } mPreferences = getSharedPreferences(APOLLO_PREFERENCES, MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE); mCardId = MusicUtils.getCardId(this); registerExternalStorageListener(); // Needs to be done in this thread, since otherwise // ApplicationContext.getPowerManager() crashes. mPlayer = new MultiPlayer(); mPlayer.setHandler(mMediaplayerHandler); reloadQueue(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); IntentFilter commandFilter = new IntentFilter(); commandFilter.addAction(SERVICECMD); commandFilter.addAction(TOGGLEPAUSE_ACTION); commandFilter.addAction(PAUSE_ACTION); commandFilter.addAction(NEXT_ACTION); commandFilter.addAction(PREVIOUS_ACTION); commandFilter.addAction(CYCLEREPEAT_ACTION); commandFilter.addAction(TOGGLESHUFFLE_ACTION); registerReceiver(mIntentReceiver, commandFilter); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); mWakeLock.setReferenceCounted(false); // If the service was idle, but got killed before it stopped itself, the // system will relaunch it. Make sure it gets stopped again in that // case. Message msg = mDelayedStopHandler.obtainMessage(); mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY); }