android.media.RemoteController Java Examples
The following examples show how to use
android.media.RemoteController.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MusicTile.java From GravityBox with Apache License 2.0 | 6 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor data) { mMetadata.trackTitle = data.getString(MediaMetadataRetriever.METADATA_KEY_TITLE, mMetadata.trackTitle); mMetadata.bitmap = data.getBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, mMetadata.bitmap); mClientIdLost = false; if ((mMetadata.trackTitle != null && !mMetadata.trackTitle.equals(mCurrentTrack)) || (mMetadata.bitmap != null && !mMetadata.bitmap.sameAs(mCurrentBitmap))) { mCurrentTrack = mMetadata.trackTitle; mCurrentBitmap = mMetadata.bitmap; refreshState(); if (DEBUG) log(getKey() + ": onClientMetadataUpdate"); } }
Example #2
Source File: NotificationListenerService.java From QuickLyric with GNU General Public License v3.0 | 6 votes |
@Override @SuppressWarnings("NewApi") public void onCreate() { super.onCreate(); if (!isListeningAuthorized(this)) return; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mRemoteController = new WeakReference<>(new RemoteController(this, this)); mRemoteController.get().setArtworkConfiguration(3000, 3000); if (!((AudioManager) getSystemService(Context.AUDIO_SERVICE)).registerRemoteController(mRemoteController.get())) { throw new RuntimeException("Error while registering RemoteController!"); } mediaControllerCallback = new MediaControllerCallback(this); } else { startScrobblingService(); // disableNotificationListenerService(); } }
Example #3
Source File: MediaController2KitKat.java From AcDisplay with GNU General Public License v2.0 | 6 votes |
/** * Updates {@link #mMetadata metadata} from given remote metadata class. * This also updates play state. * * @param data Object of metadata to update from, or {@code null} to clear local metadata. * @see #clearMetadata() */ private void updateMetadata(@Nullable RemoteController.MetadataEditor data) { if (data == null) { if (mMetadata.isEmpty()) return; mMetadata.clear(); } else { mMetadata.title = data.getString(MediaMetadataRetriever.METADATA_KEY_TITLE, null); mMetadata.artist = data.getString(MediaMetadataRetriever.METADATA_KEY_ARTIST, null); mMetadata.album = data.getString(MediaMetadataRetriever.METADATA_KEY_ALBUM, null); mMetadata.duration = data.getLong(MediaMetadataRetriever.METADATA_KEY_DURATION, -1); mMetadata.bitmap = data.getBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, null); mMetadata.generateSubtitle(); } notifyOnMetadataChanged(); }
Example #4
Source File: RemoteControlKitKat.java From Noyze with Apache License 2.0 | 6 votes |
protected void registerController() { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); rController = new RemoteController(mContext, (RemoteController.OnClientUpdateListener) mContext); try { // This is a weird issue that needs more clarification. audioManager.registerRemoteController(rController); } catch (SecurityException se) { rController = null; } // By default an RemoteController.OnClientUpdateListener implementation will not receive bitmaps // for album art. Use setArtworkConfiguration(int, int) to receive images as well. if (null != rController) { Resources res = mContext.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); final int dim = Math.max(dm.widthPixels, dm.heightPixels); rController.setArtworkConfiguration(dim, dim); } }
Example #5
Source File: RemoteControlKitKat.java From Noyze with Apache License 2.0 | 6 votes |
protected void registerController() { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); rController = new RemoteController(mContext, (RemoteController.OnClientUpdateListener) mContext); try { // This is a weird issue that needs more clarification. audioManager.registerRemoteController(rController); } catch (SecurityException se) { rController = null; } // By default an RemoteController.OnClientUpdateListener implementation will not receive bitmaps // for album art. Use setArtworkConfiguration(int, int) to receive images as well. if (null != rController) { Resources res = mContext.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); final int dim = Math.max(dm.widthPixels, dm.heightPixels); rController.setArtworkConfiguration(dim, dim); } }
Example #6
Source File: MediaController2KitKat.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void seekTo(long position) { if (mService == null) { Log.w(TAG, "Seeking a media on stopped controller."); return; } RemoteController rc = mService.getRemoteController(); rc.seekTo(position); }
Example #7
Source File: MediaController2KitKat.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public void sendMediaAction(int action) { if (mService == null) { Log.w(TAG, "Sending a media action on stopped controller."); return; } int keyCode; switch (action) { case ACTION_PLAY_PAUSE: keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case ACTION_STOP: keyCode = KeyEvent.KEYCODE_MEDIA_STOP; break; case ACTION_SKIP_TO_NEXT: keyCode = KeyEvent.KEYCODE_MEDIA_NEXT; break; case ACTION_SKIP_TO_PREVIOUS: keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS; break; default: throw new IllegalArgumentException(); } // TODO We should think about sending these up/down events accurately with touch up/down // on the buttons, but in the near term this will interfere with the long press behavior. RemoteController rc = mService.getRemoteController(); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyCode)); }
Example #8
Source File: MediaController2KitKat.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public long getPlaybackPosition() { if (mService == null) { Log.w(TAG, "Getting a playback position on stopped controller."); return -1; } RemoteController rc = mService.getRemoteController(); return rc.getEstimatedMediaPosition(); }
Example #9
Source File: MediaService.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
@Override public void onCreate() { if (isRemoteControllerSupported()) { mRemoteController = new RemoteController(this, this); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); } }
Example #10
Source File: RemoteControllerActivity.java From Android-RemoteController with Apache License 2.0 | 5 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { String artist = metadataEditor.getString(MediaMetadataRetriever.METADATA_KEY_ARTIST, "null"); String album = metadataEditor.getString(MediaMetadataRetriever.METADATA_KEY_ALBUM, "null"); String title = metadataEditor.getString(MediaMetadataRetriever.METADATA_KEY_TITLE, "null"); Long duration = metadataEditor.getLong(MediaMetadataRetriever.METADATA_KEY_DURATION, -1); Bitmap defaultCover = BitmapFactory.decodeResource(getResources(), android.R.drawable.ic_menu_compass); Bitmap bitmap = metadataEditor.getBitmap(RemoteController.MetadataEditor.BITMAP_KEY_ARTWORK, defaultCover); Log.e(TAG, "artist:" + artist + "album:" + album + "title:" + title + "duration:" + duration); Music music = new Music(); music.setCover(bitmap); music.setTitle(title); music.setArtist(artist); mMusicControlView.onClientMetadataUpdate(music); }
Example #11
Source File: NotificationListenerService.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { // isRemoteControllerPlaying = true; durationObject = metadataEditor.getObject(MediaMetadataRetriever.METADATA_KEY_DURATION, 1200); //allow it to pass if not present artist = metadataEditor.getString(MediaMetadataRetriever.METADATA_KEY_ARTIST, metadataEditor.getString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, "")); track = metadataEditor.getString(MediaMetadataRetriever.METADATA_KEY_TITLE, ""); Bitmap artwork = metadataEditor.getBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, null); mediaControllerCallback.saveArtwork(this, artwork, artist, track); }
Example #12
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientPlaybackStateUpdate(int state) { ((RemoteController.OnClientUpdateListener) mController).onClientPlaybackStateUpdate(state); }
Example #13
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientPlaybackStateUpdate(int state, long stateChangeTimeMs, long currentPosMs, float speed) { ((RemoteController.OnClientUpdateListener) mController).onClientPlaybackStateUpdate(state, stateChangeTimeMs, currentPosMs, speed); }
Example #14
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientTransportControlUpdate(int transportControlFlags) { LOGI("RemoteControlJellyBeanMR2", "onClientTransportControlUpdate(" + transportControlFlags + ")"); ((RemoteController.OnClientUpdateListener) mController).onClientTransportControlUpdate(transportControlFlags); }
Example #15
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { ((RemoteController.OnClientUpdateListener) mController).onClientMetadataUpdate(metadataEditor); }
Example #16
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientChange(boolean clearing) { ((RemoteController.OnClientUpdateListener) mController).onClientChange(clearing); }
Example #17
Source File: RemoteControlKitKat.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { if (null == metadataEditor) return; metadataChanged(mediaMetadata(metadataEditor)); }
Example #18
Source File: MediaService.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { if (mExternalListener != null) { mExternalListener.onClientMetadataUpdate(metadataEditor); } }
Example #19
Source File: MediaController2KitKat.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { updateMetadata(metadataEditor); }
Example #20
Source File: MusicNotificationListenerService.java From Android-RemoteController with Apache License 2.0 | 4 votes |
public void setExternalClientUpdateListener(RemoteController.OnClientUpdateListener externalClientUpdateListener) { mExternalClientUpdateListener = externalClientUpdateListener; }
Example #21
Source File: MediaService.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
/** * Sets up external callback for client update events. */ public void setClientUpdateListener(@Nullable RemoteController.OnClientUpdateListener listener) { mExternalListener = listener; }
Example #22
Source File: MediaService.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
public RemoteController getRemoteController() { return mRemoteController; }
Example #23
Source File: RemoteControlKitKat.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { if (null == metadataEditor) return; metadataChanged(mediaMetadata(metadataEditor)); }
Example #24
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientTransportControlUpdate(int transportControlFlags) { LOGI("RemoteControlJellyBeanMR2", "onClientTransportControlUpdate(" + transportControlFlags + ")"); ((RemoteController.OnClientUpdateListener) mController).onClientTransportControlUpdate(transportControlFlags); }
Example #25
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientPlaybackStateUpdate(int state) { ((RemoteController.OnClientUpdateListener) mController).onClientPlaybackStateUpdate(state); }
Example #26
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientPlaybackStateUpdate(int state, long stateChangeTimeMs, long currentPosMs, float speed) { ((RemoteController.OnClientUpdateListener) mController).onClientPlaybackStateUpdate(state, stateChangeTimeMs, currentPosMs, speed); }
Example #27
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { ((RemoteController.OnClientUpdateListener) mController).onClientMetadataUpdate(metadataEditor); }
Example #28
Source File: MediaControllerService.java From Noyze with Apache License 2.0 | 4 votes |
@Override public void onClientChange(boolean clearing) { ((RemoteController.OnClientUpdateListener) mController).onClientChange(clearing); }
Example #29
Source File: MusicNotificationListenerService.java From Android-RemoteController with Apache License 2.0 | 4 votes |
@Override public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) { if (mExternalClientUpdateListener != null) mExternalClientUpdateListener.onClientMetadataUpdate(metadataEditor); }