List of usage examples for android.media MediaMetadataRetriever METADATA_KEY_ARTIST
int METADATA_KEY_ARTIST
To view the source code for android.media MediaMetadataRetriever METADATA_KEY_ARTIST.
Click Source Link
From source file:org.runbuddy.tomahawk.activities.TomahawkMainActivity.java
private void handleIntent(Intent intent) { if (MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH.equals(intent.getAction())) { intent.setAction(null);/*from w w w . j a va2s.co m*/ String playbackManagerId = getSupportMediaController().getExtras() .getString(PlaybackService.EXTRAS_KEY_PLAYBACKMANAGER); PlaybackManager playbackManager = PlaybackManager.getByKey(playbackManagerId); MediaPlayIntentHandler intentHandler = new MediaPlayIntentHandler( getSupportMediaController().getTransportControls(), playbackManager); intentHandler.mediaPlayFromSearch(intent.getExtras()); } if ("com.google.android.gms.actions.SEARCH_ACTION".equals(intent.getAction())) { intent.setAction(null); String query = intent.getStringExtra(SearchManager.QUERY); if (query != null && !query.isEmpty()) { DatabaseHelper.get().addEntryToSearchHistory(query); Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.QUERY_STRING, query); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC); FragmentUtils.replace(TomahawkMainActivity.this, SearchPagerFragment.class, bundle); } } if (SHOW_PLAYBACKFRAGMENT_ON_STARTUP.equals(intent.getAction())) { intent.setAction(null); // if this Activity is being shown after the user clicked the notification if (mSlidingUpPanelLayout != null) { mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); } } if (intent.hasExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)) { intent.removeExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); Bundle bundle = new Bundle(); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC_SMALL); FragmentUtils.replace(this, PreferencePagerFragment.class, bundle); } if (intent.getData() != null) { final Uri data = intent.getData(); intent.setData(null); List<String> pathSegments = data.getPathSegments(); String host = data.getHost(); String scheme = data.getScheme(); if ((scheme != null && (scheme.equals("spotify") || scheme.equals("tomahawk"))) || (host != null && (host.contains("spotify.com") || host.contains("hatchet.is") || host.contains("toma.hk") || host.contains("beatsmusic.com") || host.contains("deezer.com") || host.contains("rdio.com") || host.contains("soundcloud.com")))) { PipeLine.get().lookupUrl(data.toString()); } else if ((pathSegments != null && pathSegments.get(pathSegments.size() - 1).endsWith(".xspf")) || (intent.getType() != null && intent.getType().equals("application/xspf+xml"))) { TomahawkRunnable r = new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_HIGH) { @Override public void run() { Playlist pl = XspfParser.parse(data); if (pl != null) { final Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.PLAYLIST, pl.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } }); } } }; ThreadManager.get().execute(r); } else if (pathSegments != null && (pathSegments.get(pathSegments.size() - 1).endsWith(".axe") || pathSegments.get(pathSegments.size() - 1).endsWith(".AXE"))) { InstallPluginConfigDialog dialog = new InstallPluginConfigDialog(); Bundle args = new Bundle(); args.putString(InstallPluginConfigDialog.PATH_TO_AXE_URI_STRING, data.toString()); dialog.setArguments(args); dialog.show(getSupportFragmentManager(), null); } else { String albumName; String trackName; String artistName; try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(this, data); albumName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM); artistName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); trackName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); retriever.release(); } catch (Exception e) { Log.e(TAG, "handleIntent: " + e.getClass() + ": " + e.getLocalizedMessage()); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { String msg = TomahawkApp.getContext().getString(R.string.invalid_file); Toast.makeText(TomahawkApp.getContext(), msg, Toast.LENGTH_LONG).show(); } }); return; } if (TextUtils.isEmpty(trackName) && pathSegments != null) { trackName = pathSegments.get(pathSegments.size() - 1); } Query query = Query.get(trackName, albumName, artistName, false); Result result = Result.get(data.toString(), query.getBasicTrack(), UserCollectionStubResolver.get()); float trackScore = query.howSimilar(result); query.addTrackResult(result, trackScore); Bundle bundle = new Bundle(); List<Query> queries = new ArrayList<>(); queries.add(query); Playlist playlist = Playlist.fromQueryList(IdGenerator.getSessionUniqueStringId(), "", "", queries); playlist.setFilled(true); playlist.setName(artistName + " - " + trackName); bundle.putString(TomahawkFragment.PLAYLIST, playlist.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } } }
From source file:com.iamplus.musicplayer.MusicService.java
private void updateRemoteControlPlayingState() { // Tell any remote controls that our playback state is 'Playing'. if (mRemoteControlClientCompat != null) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); // Update the remote controls //Bitmap bitmap = MediaAlbumsAdaptor.getAlbumArtwork(getApplicationContext(), mCurrentPlayingItem.getAlbumid(), true); mRemoteControlClientCompat.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, mCurrentPlayingItem.getArtist()) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mCurrentPlayingItem.getAlbum()) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mCurrentPlayingItem.getTitle()) .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, mCurrentPlayingItem.getDuration()) .apply();/* w w w . ja va2 s.c om*/ //.putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK,bitmap).apply(); Log.d(TAG, "Setting Remote Control Meta data **** Start"); Log.d(TAG, "Title = " + mCurrentPlayingItem.getTitle()); Log.d(TAG, "Album = " + mCurrentPlayingItem.getAlbum()); Log.d(TAG, "Artist = " + mCurrentPlayingItem.getArtist()); Log.d(TAG, "Duration = " + mCurrentPlayingItem.getDuration()); //Log.d(TAG, "Bitmap = " + bitmap); Log.d(TAG, "Setting Remote Control Meta data **** End"); } }
From source file:com.yamin.kk.service.AudioService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!Util.isICSOrLater()) // NOP check return;/*w ww . ja v a 2 s . c om*/ if (mRemoteControlClient != null) { MetadataEditor editor = mRemoteControlClient.editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getCurrentMedia().getAlbum()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getCurrentMedia().getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, getCurrentMedia().getGenre()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getCurrentMedia().getTitle()); editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, getCurrentMedia().getLength()); editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, getCover()); editor.apply(); } }
From source file:org.videolan.myvlc.core.mediaController.AudioService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!Util.isICSOrLater()) // NOP check return;//from w ww. j a v a 2 s. c om if (mRemoteControlClient != null) { MetadataEditor editor = mRemoteControlClient.editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mCurrentMedia.getAlbum()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, mCurrentMedia.getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, mCurrentMedia.getGenre()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mCurrentMedia.getTitle()); editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, mCurrentMedia.getLength()); editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, getCover()); editor.apply(); } }
From source file:org.tomahawk.tomahawk_android.activities.TomahawkMainActivity.java
private void handleIntent(Intent intent) { if (SHOW_PLAYBACKFRAGMENT_ON_STARTUP.equals(intent.getAction())) { // if this Activity is being shown after the user clicked the notification if (mSlidingUpPanelLayout != null) { mSlidingUpPanelLayout.expandPanel(); }/*from w w w .j a v a2s . c om*/ } if (intent.hasExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)) { Bundle bundle = new Bundle(); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC_SMALL); FragmentUtils.replace(this, PreferencePagerFragment.class, bundle); } if (intent.getData() != null) { final Uri data = intent.getData(); intent.setData(null); List<String> pathSegments = data.getPathSegments(); String host = data.getHost(); String scheme = data.getScheme(); if ((scheme != null && (scheme.equals("spotify") || scheme.equals("tomahawk"))) || (host != null && (host.contains("spotify.com") || host.contains("hatchet.is") || host.contains("toma.hk") || host.contains("beatsmusic.com") || host.contains("deezer.com") || host.contains("rdio.com") || host.contains("soundcloud.com")))) { PipeLine.get().lookupUrl(data.toString()); } else if ((pathSegments != null && pathSegments.get(pathSegments.size() - 1).endsWith(".xspf")) || (intent.getType() != null && intent.getType().equals("application/xspf+xml"))) { TomahawkRunnable r = new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_HIGH) { @Override public void run() { Playlist pl = XspfParser.parse(data); if (pl != null) { final Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.PLAYLIST, pl.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } }); } } }; ThreadManager.get().execute(r); } else if (pathSegments != null && (pathSegments.get(pathSegments.size() - 1).endsWith(".axe") || pathSegments.get(pathSegments.size() - 1).endsWith(".AXE"))) { InstallPluginConfigDialog dialog = new InstallPluginConfigDialog(); Bundle args = new Bundle(); args.putString(InstallPluginConfigDialog.PATH_TO_AXE_URI_STRING, data.toString()); dialog.setArguments(args); dialog.show(getSupportFragmentManager(), null); } else { String albumName; String trackName; String artistName; try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(this, data); albumName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM); artistName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); trackName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); retriever.release(); } catch (Exception e) { Log.e(TAG, "handleIntent: " + e.getClass() + ": " + e.getLocalizedMessage()); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { String msg = TomahawkApp.getContext().getString(R.string.invalid_file); Toast.makeText(TomahawkApp.getContext(), msg, Toast.LENGTH_LONG).show(); } }); return; } if (TextUtils.isEmpty(trackName) && pathSegments != null) { trackName = pathSegments.get(pathSegments.size() - 1); } Query query = Query.get(trackName, albumName, artistName, false); Result result = Result.get(data.toString(), query.getBasicTrack(), UserCollectionStubResolver.get()); float trackScore = query.howSimilar(result); query.addTrackResult(result, trackScore); Bundle bundle = new Bundle(); List<Query> queries = new ArrayList<>(); queries.add(query); Playlist playlist = Playlist.fromQueryList(TomahawkMainActivity.getSessionUniqueStringId(), false, "", "", queries); bundle.putString(TomahawkFragment.PLAYLIST, playlist.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } } }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MediaPlaybackService.java
/** * Notify the change-receivers that something has changed. * The intent that is sent contains the following data * for the currently playing track:// www . ja v a2s . com * "id" - Integer: the database row ID * "artist" - String: the name of the artist * "album" - String: the name of the album * "track" - String: the name of the track * The intent has an action that is one of * "com.android.music.metachanged" * "com.android.music.queuechanged", * "com.android.music.playbackcomplete" * "com.android.music.playstatechanged" * respectively indicating that a new track has * started playing, that the playback queue has * changed, that playback has stopped because * the last file in the list has been played, * or that the play-state changed (paused/resumed). */ private void notifyChange(String what) { Intent i = new Intent(what); i.putExtra("id", Long.valueOf(getAudioId())); i.putExtra("artist", getArtistName()); i.putExtra("album", getAlbumName()); i.putExtra("track", getTrackName()); i.putExtra("playing", isPlaying()); sendStickyBroadcast(i); if (what.equals(PLAYSTATE_CHANGED)) { mRemoteControlClient.setPlaybackState( isPlaying() ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED); } else if (what.equals(META_CHANGED)) { RemoteControlClient.MetadataEditor ed = mRemoteControlClient.editMetadata(true); ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName()); ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName()); ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName()); ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration()); Bitmap b = MusicUtils.getArtwork(this, getAudioId(), getAlbumId(), false); if (b != null) { ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b); } ed.apply(); } if (what.equals(QUEUE_CHANGED)) { saveQueue(true); } else { saveQueue(false); } // Share this notification directly with our widgets mAppWidgetProvider.notifyChange(this, what); }
From source file:org.videolan.vlc.audio.AudioService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!LibVlcUtil.isICSOrLater()) // NOP check return;/* w ww .j av a 2 s. co m*/ Media media = getCurrentMedia(); if (mRemoteControlClient != null && media != null) { MetadataEditor editor = mRemoteControlClient.editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, media.getAlbum()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, media.getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle()); editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength()); // Copy the cover bitmap because the RemonteControlClient can recycle its artwork bitmap. Bitmap cover = getCover(); editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, ((cover != null) ? cover.copy(cover.getConfig(), false) : null)); editor.apply(); } }
From source file:org.videolan.vlc2.audio.AudioService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!LibVlcUtil.isICSOrLater()) // NOP check return;/*from w ww . j a va2 s. c om*/ Media media = getCurrentMedia(); if (mRemoteControlClient != null && media != null) { MetadataEditor editor = mRemoteControlClient.editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, media.getAlbum()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, media.getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, media.getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle()); editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength()); // Copy the cover bitmap because the RemonteControlClient can recycle its artwork bitmap. Bitmap cover = getCover(); editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, ((cover != null) ? cover.copy(cover.getConfig(), false) : null)); editor.apply(); } }
From source file:com.dzt.musicplay.player.AudioService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!LibVlcUtil.isICSOrLater()) // NOP check return;/*from www. j a va2s . c o m*/ Media media = getCurrentMedia(); if (mRemoteControlClient != null && media != null) { MetadataEditor editor = mRemoteControlClient.editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, media.getAlbum()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, media.getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle()); editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength()); // Copy the cover bitmap because the RemonteControlClient can // recycle its artwork bitmap. Bitmap cover = getCover(); editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, ((cover != null) ? cover.copy(cover.getConfig(), false) : null)); editor.apply(); } }
From source file:com.andrew.apolloMod.service.ApolloService.java
/** * Notify the change-receivers that something has changed. The intent that * is sent contains the following data for the currently playing track: "id" * - Integer: the database row ID "artist" - String: the name of the artist * "album" - String: the name of the album "track" - String: the name of the * track The intent has an action that is one of * "com.andrew.apolloMod.metachanged" "com.andrew.apolloMod.queuechanged", * "com.andrew.apolloMod.playbackcomplete" "com.andrew.apolloMod.playstatechanged" * respectively indicating that a new track has started playing, that the * playback queue has changed, that playback has stopped because the last * file in the list has been played, or that the play-state changed * (paused/resumed).// ww w .java 2s .c o m */ public void notifyChange(String what) { Intent i = new Intent(what); i.putExtra("id", Long.valueOf(getAudioId())); i.putExtra("artist", getArtistName()); i.putExtra("album", getAlbumName()); i.putExtra("track", getTrackName()); i.putExtra("playing", mIsSupposedToBePlaying); i.putExtra("isfavorite", isFavorite()); sendStickyBroadcast(i); i = new Intent(i); i.setAction(what.replace(APOLLO_PACKAGE_NAME, MUSIC_PACKAGE_NAME)); sendStickyBroadcast(i); if (Constants.isApi14Supported()) { if (what.equals(PLAYSTATE_CHANGED)) { mRemoteControlClient.setPlaybackState(mIsSupposedToBePlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED); } else if (what.equals(META_CHANGED)) { RemoteControlClient.MetadataEditor ed = mRemoteControlClient.editMetadata(true); ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName()); ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName()); ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName()); ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration()); Bitmap b = getAlbumBitmap(); if (b != null) { ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b); } ed.apply(); } } if (what.equals(QUEUE_CHANGED)) { saveQueue(true); } else { saveQueue(false); } mAppWidgetProvider1x1.notifyChange(this, what); mAppWidgetProvider4x1.notifyChange(this, what); mAppWidgetProvider4x2.notifyChange(this, what); }