本文整理汇总了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();
}
}
}