List of usage examples for android.media.session MediaSession setMediaButtonReceiver
public void setMediaButtonReceiver(@Nullable PendingIntent mbr)
From source file:org.opensilk.video.playback.PlaybackService.java
private MediaSession newMediaSession() { final MediaSession mediaSession = new MediaSession(mContext, "SilkVideoPlayer"); mediaSession// www. j a v a2 s. co m .setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); final ComponentName mediaButtonComponent = new ComponentName(mContext, MediaButtonReceiver.class); final PendingIntent mediaButtonIntent = PendingIntent.getBroadcast(mContext, 1, new Intent().setComponent(mediaButtonComponent), PendingIntent.FLAG_UPDATE_CURRENT); mediaSession.setMediaButtonReceiver(mediaButtonIntent); mediaSession.setSessionActivity(makeActivityIntent(null)); return mediaSession; }