List of usage examples for android.support.v4.media.session MediaButtonReceiver handleIntent
public static KeyEvent handleIntent(MediaSessionCompat mediaSessionCompat, Intent intent)
From source file:net.simno.klingar.playback.MusicService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { if (ACTION_STOP_CASTING.equals(startIntent.getAction())) { CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true); } else {/*from w ww.j av a2s. c o m*/ // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(session, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if nothing is playing delayedStopHandler.removeCallbacksAndMessages(null); delayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.phearom.um.MusicService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); }/* w w w . j av a 2s . co m*/ } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.classiqo.nativeandroid_32bitz.MusicService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true); }/* ww w. j a v a2 s.c o m*/ } else { MediaButtonReceiver.handleIntent(mSession, startIntent); } } mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.example.android.supportv4.media.MediaBrowserServiceSupport.java
/** * (non-Javadoc)//from w w w .j av a 2 s .c om * * @see android.app.Service#onStartCommand(android.content.Intent, int, int) */ @Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); if (Intent.ACTION_MEDIA_BUTTON.equals(action)) { MediaButtonReceiver.handleIntent(mSession, startIntent); } else if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(startIntent.getStringExtra(CMD_NAME))) { if (mPlayback != null && mPlayback.isPlaying()) { handlePauseRequest(); } } } } return START_STICKY; }
From source file:nuclei.media.MediaService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { VideoCastManager.getInstance().disconnect(); }//from www. j a v a2 s.c o m } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.appdevper.mediaplayer.app.MusicService.java
/** * (non-Javadoc)/* w w w .j av a2 s . c om*/ * * @see android.app.Service#onStartCommand(Intent, int, int) */ @Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { VideoCastManager.getInstance().disconnect(); } } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.example.lzhang.stockchartt.media.MusicService.java
/** * (non-Javadoc)//w w w . j av a 2 s . c o m * @see android.app.Service#onStartCommand(android.content.Intent, int, int) */ @Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { // CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true); } } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.example.android.uamp.MusicService.java
/** * (non-Javadoc)/*from w w w. j a v a 2s. co m*/ * @see android.app.Service#onStartCommand(android.content.Intent, int, int) */ @Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true); } } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:rocks.stalin.android.app.MusicService.java
/** * (non-Javadoc)/*from ww w .ja v a 2 s .com*/ * @see android.app.Service#onStartCommand(android.content.Intent, int, int) */ @Override public int onStartCommand(Intent startIntent, int flags, int startId) { if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { mPlaybackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true); } } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. mDelayedStopHandler.removeCallbacksAndMessages(null); mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }
From source file:com.scooter1556.sms.android.service.MediaService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { Log.d(TAG, "onStartCommand()"); if (startIntent != null) { String action = startIntent.getAction(); String command = startIntent.getStringExtra(CMD_NAME); if (ACTION_CMD.equals(action)) { if (CMD_PAUSE.equals(command)) { playbackManager.handlePauseRequest(); } else if (CMD_STOP_CASTING.equals(command)) { CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true); }//from w ww .j a va 2 s.co m } else { // Try to handle the intent as a media button event wrapped by MediaButtonReceiver MediaButtonReceiver.handleIntent(mediaSession, startIntent); } } // Reset the delay handler to enqueue a message to stop the service if // nothing is playing. delayedStopHandler.removeCallbacksAndMessages(null); delayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY); return START_STICKY; }