mRemoteControlClient.setPlaybackState(playState);
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) void updateRemoteControlState(int state) { remoteControlClient.setPlaybackState(state); }
public void refreshState(boolean playing, long position, int transportControls) { if (mRemoteControl != null) { mRemoteControl.setPlaybackState(playing ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_STOPPED, position, playing ? 1 : 0); mRemoteControl.setTransportControlFlags(transportControls); } }
public void startPlaying() { if (mPlayState != RemoteControlClient.PLAYSTATE_PLAYING) { mPlayState = RemoteControlClient.PLAYSTATE_PLAYING; mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } if (mFocused) { takeAudioFocus(); } }
public void pausePlaying() { if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) { mPlayState = RemoteControlClient.PLAYSTATE_PAUSED; mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); } dropAudioFocus(); }
public void stopPlaying() { if (mPlayState != RemoteControlClient.PLAYSTATE_STOPPED) { mPlayState = RemoteControlClient.PLAYSTATE_STOPPED; mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); } dropAudioFocus(); }
| RemoteControlClient.FLAG_KEY_MEDIA_REWIND; mRemoteControlClient.setTransportControlFlags(flags); mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); Bitmap AlbumArt=BitmapFactory.decodeResource(getResources(), R.drawable.alislahthumbmain); mIslahReceiverComponent=new ComponentName(this,AlIslahReceiver.class.getName()); audioManager.registerMediaButtonEventReceiver(mIslahReceiverComponent); Intent mediaButtonIntent=new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mIslahReceiverComponent); PendingIntent mediaPendingIntent=PendingIntent.getBroadcast(getApplicationContext(), 0,mediaButtonIntent,0); RemoteControlClient mRemoteControlClient=new RemoteControlClient(mediaPendingIntent); mRemoteControlClient.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE,AlIslahApplication.getStreamTitle()) .putBitmap(100,AlbumArt) .apply(); mRemoteControlClient.setPlaybackState( RemoteControlClient.PLAYSTATE_PLAYING); mRemoteControlClient.setTransportControlFlags( RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE| RemoteControlClient.FLAG_KEY_MEDIA_STOP); audioManager.registerRemoteControlClient(mRemoteControlClient);
remote.setPlaybackState(isPlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED); RemoteControlClient.MetadataEditor editor = remote.editMetadata(true); if (song != null && song.artist != null && song.album != null) {
private void updateButtons() { MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(); // show pause or resume icon depending on current state mPauseResumeButton.setImageResource( mPaused ? R.drawable.ic_action_play : R.drawable.ic_action_pause); // disable pause/resume/stop if no session mPauseResumeButton.setEnabled(mSessionManager.hasSession()); mStopButton.setEnabled(mSessionManager.hasSession()); // only enable seek bar when duration is known PlaylistItem item = getCheckedPlaylistItem(); mSeekBar.setEnabled(item != null && item.getDuration() > 0); if (mRemoteControlClient != null) { mRemoteControlClient.setPlaybackState(mPaused ? RemoteControlClient.PLAYSTATE_PAUSED : RemoteControlClient.PLAYSTATE_PLAYING); } }
private void registerRemoteControlClient() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // Create the RCC and register with AudioManager and MediaRouter mAudioManager.requestAudioFocus(mAfChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); mAudioManager.registerMediaButtonEventReceiver(mEventReceiver); mRemoteControlClient = new RemoteControlClient(mMediaPendingIntent); mAudioManager.registerRemoteControlClient(mRemoteControlClient); mMediaRouter.addRemoteControlClient(mRemoteControlClient); SampleMediaButtonReceiver.setActivity(MainActivity.this); mRemoteControlClient.setTransportControlFlags(RemoteControlClient .FLAG_KEY_MEDIA_PLAY_PAUSE); mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } }
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); } else { if(isPlaying()) { remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } else { remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);