本文整理匯總了Java中android.support.v4.media.MediaMetadataCompat.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaMetadataCompat.getString方法的具體用法?Java MediaMetadataCompat.getString怎麽用?Java MediaMetadataCompat.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.media.MediaMetadataCompat
的用法示例。
在下文中一共展示了MediaMetadataCompat.getString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateArt
import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void updateArt(MediaMetadataCompat metadataCompat){
if(metadataCompat==null) return;
String text=Long.toString(metadataCompat.getLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER))
+" of "+Long.toString(metadataCompat.getLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS));
trackName.setText(metadataCompat.getText(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE));
artist.setText(metadataCompat.getText(MediaMetadataCompat.METADATA_KEY_ARTIST));
pages.setText(text);
String imageUrl=metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI);
showArt(imageUrl);
}
示例2: isMediaIdSame
import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private boolean isMediaIdSame(MediaMetadataCompat currentMedia,
MediaMetadataCompat newMedia) {
if (currentMedia == null || newMedia == null) {
return false;
}
String newMediaId =
newMedia.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID);
String currentMediaId =
currentMedia.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID);
return newMediaId.equals(currentMediaId);
}
示例3: play
import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
@Override
public void play(MediaSessionCompat.QueueItem item) {
mPlayOnFocusGain = true;
getAudioFocus();
registerNoisyReceiver();
String mediaId = item.getDescription().getMediaId();
boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);
if (mediaHasChanged) {
mCurrentPosition = 0;
mCurrentMediaId = mediaId;
}
if (mPlaybackState == PlaybackStateCompat.STATE_PAUSED &&
!mediaHasChanged && mPlayer != null) {
configMediaPlayerState();
} else {
mPlaybackState = PlaybackStateCompat.STATE_STOPPED;
releaseResource(false);
MediaMetadataCompat track = mProvider.getMusic(mediaId);
String source = track.getString(MusicProviderSource.CUSTOM_METADATA_MUSIC_FILE_PATH);
try {
createOrResetMediaPlayer();
mPlaybackState = PlaybackStateCompat.STATE_BUFFERING;
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mPlayer.setDataSource(source);
mPlayer.prepareAsync();
if (mCallback != null) {
mCallback.onPlayStateChanged(mPlaybackState);
}
} catch (IOException e) {
if (mCallback != null) {
mCallback.onError(PlaybackStateCompat.ERROR_CODE_NOT_SUPPORTED, e.getMessage());
}
e.printStackTrace();
}
}
}