Android RemoteControlClient - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android RemoteControlClient class.

This code example shows how to use the following methods:setPlaybackState, setTransportControlFlags
		Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
		mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
		PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);
 
		// create and register the remote control client 
		mRemoteControl = new RemoteControlClient(mediaPendingIntent);
		audioManager.registerRemoteControlClient(mRemoteControl);
 
		mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
 
		mRemoteControl.setTransportControlFlags(
				RemoteControlClient.FLAG_KEY_MEDIA_PLAY | 
				RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | 
				RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
				RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
				RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
				RemoteControlClient.FLAG_KEY_MEDIA_STOP);
		 
		imageLoader = SubsonicTabActivity.getStaticImageLoader(context);
	} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setTransportControlFlags
This code example shows how to use the following methods:setPlaybackState
	} 
 
	@TargetApi(14) 
	public void removeLockscreenControls() { 
		if (_remoteControlClient != null)
			_remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
	} 
 
	@TargetApi(14) 
	public void setLockscreenPaused() { 
		if (_remoteControlClient == null)
			return; 
		_remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
	} 
 
	@TargetApi(14) 
	public void setLockscreenPlaying() { 
		if (_remoteControlClient == null)
			return; 
		_remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:unregisterRemoteControlClient
		getAudioManager().registerRemoteControlClient(getRemoteControlClient());
	} 
 
	@Override 
	public void onPlaybackStopped() { 
		getAudioManager().unregisterRemoteControlClient(
				getRemoteControlClient()); 
	} 
 
	@Override 
	public void onTitleChanged(String title) {
		getRemoteControlClient().editMetadata(false)
				.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title)
				.apply();
	} 
 
	@Override 
	public void onArtistChanged(String artist) {
		getRemoteControlClient().editMetadata(false)
				.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist)

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setPlaybackState, setTransportControlFlags
		// build the PendingIntent for the remote control client 
		Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
		mediaButtonIntent.setComponent(myEventReceiver);
		PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
		// create and register the remote control client 
		myRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
		myAudioManager.registerRemoteControlClient(myRemoteControlClient);
 
		myRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
		myRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP);
		 
		dialog = ProgressDialog.show(this, null, "曲を探しています...", true, false);
		final ContentResolver cr = this.getContentResolver();
		new Thread(new Runnable() {
			private String getWhereClause() {
				StringBuilder s = new StringBuilder();
				 
				s.append(MediaStore.Files.FileColumns.MEDIA_TYPE).append("=").append(MediaStore.Files.FileColumns.MEDIA_TYPE_NONE);
				s.append(" AND (");
				s.append("LOWER(").append(MediaStore.Files.FileColumns.DATA).append(") LIKE '%.s98'");
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setTransportControlFlags
      Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
      mediaButtonIntent.setComponent(myEventReceiver);
      // create and register the remote control client 
      PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0,
          mediaButtonIntent, 0);
      remoteControlClient = new RemoteControlClient(mediaPendingIntent);
      remoteControlClient
          .setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
              | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
              | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS);
      audioManager.registerRemoteControlClient(remoteControlClient);
    } 
  } 
 
  /** 
   * Update the state of the remote control. 
   */ 
  public void updateState(boolean isPlaying) {
    if (remoteControlClient != null) {
      if (isPlaying) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:setTransportControlFlags
		ComponentName rec = new ComponentName(m_helios.getPackageName(), RemoteControlReceiver.class.getName());
		m_audioManager.registerMediaButtonEventReceiver(rec);
		Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
		mediaButtonIntent.setComponent(rec);
		PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(m_helios.getApplicationContext(), 0, mediaButtonIntent, 0);
		m_client = new RemoteControlClient(mediaPendingIntent);
		m_audioManager.registerRemoteControlClient(m_client);
		m_client.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS);
	} 
	 
	public void play() { 
		if (m_audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN) == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { 
			m_client.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
			if (hasSong()) { 
				m_currentSong.start();
				ImageButton i = (ImageButton) m_helios.findViewById(R.id.play_button);
				i.setImageResource(R.drawable.pause_selector);
			} else if (!m_nowPlaying.isEmpty() && addNextSong()) playNextSong();
		} 
	} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:editMetadata
            setImage(remoteControl, drawable);
            return; 
        } 
 
        setUnknownImage(remoteControl);
        queue.offer(new Task(context, null, remoteControl, entry, imageSizeDefault, false, false, false));
    } 
 
    private String getKey(String coverArtId, int size) {
        return coverArtId + size;
    } 
 
    private void setImage(View view, Drawable drawable, boolean crossfade) {
        if (view instanceof TextView) {
            // Cross-fading is not implemented for TextView since it's not in use.  It would be easy to add it, though. 
            TextView textView = (TextView) view;
            textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
        } else if (view instanceof ImageView) {
            ImageView imageView = (ImageView) view;
            if (crossfade) {

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:editMetadata
        } 
    } 
     
	private void setImage(RemoteControlClient remoteControl, Drawable drawable) {
    	Bitmap origBitmap = ((BitmapDrawable)drawable).getBitmap();
    	remoteControl.editMetadata(false)
    	.putBitmap(
    			RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK,
    			origBitmap.copy(origBitmap.getConfig(), true))
    	.apply();
    } 
 
    private void setUnknownImage(View view, boolean large) {
        if (large) {
            setImage(view, largeUnknownImage, false);
        } else { 
            if (view instanceof TextView) {
                ((TextView) view).setCompoundDrawablesWithIntrinsicBounds(R.drawable.unknown_album, 0, 0, 0);
            } else if (view instanceof ImageView) {
                ((ImageView) view).setImageResource(R.drawable.unknown_album);
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android RemoteControlClient Questions & Answers:

See Code Examples for Android RemoteControlClient Methods: