本文整理匯總了Java中android.media.MediaMetadata.getLong方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaMetadata.getLong方法的具體用法?Java MediaMetadata.getLong怎麽用?Java MediaMetadata.getLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.MediaMetadata
的用法示例。
在下文中一共展示了MediaMetadata.getLong方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMetadataChanged
import android.media.MediaMetadata; //導入方法依賴的package包/類
@Override
protected void onMetadataChanged() {
MediaMetadata metadata = mFragment.getActivity().getMediaController().getMetadata();
if (metadata != null) {
mVideo = new Video.VideoBuilder().buildFromMediaDesc(metadata.getDescription());
int duration = (int) metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
getControlsRow().setTotalTime(duration);
mMediaArt = new BitmapDrawable(mFragment.getResources(),
metadata.getBitmap(MediaMetadata.METADATA_KEY_ART));
}
super.onMetadataChanged();
}
示例2: updateMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
protected void updateMetadata(MediaMetadata metadata) {
if (mPlaybackControlsRow == null) {
initializePlaybackControls(metadata);
}
mDuration = (int) metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
mPlaybackControlsRow.setTotalTime(mDuration);
((MutableMediaMetadataHolder) mPlaybackControlsRow.getItem()).metadata = metadata;
mRowsAdapter.notifyArrayItemRangeChanged(
mRowsAdapter.indexOf(mPlaybackControlsRow), 1);
updateAlbumArt(metadata.getDescription().getIconUri());
}
示例3: updateDuration
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateDuration(MediaMetadata metadata) {
if (metadata == null) {
return;
}
LogHelper.d(TAG, "updateDuration called ");
int duration = (int) metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
mSeekbar.setMax(duration);
mEnd.setText(DateUtils.formatElapsedTime(duration/1000));
}
示例4: updateDuration
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateDuration(MediaMetadata metadata) {
if (metadata == null) {
return;
}
LogHelper.d(TAG, "updateDuration called ");
int duration = (int) metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
mSeekbar.setMax(duration);
mEnd.setText(Utils.formatMillis(duration));
}
示例5: getMediaId
import android.media.MediaMetadata; //導入方法依賴的package包/類
/**
* Returns the ID of the media under playback.
*/
public long getMediaId() {
MediaMetadata mediaMetadata = mMediaController.getMetadata();
return mediaMetadata == null ? UNKNOWN_MEDIA_ID
: mediaMetadata.getLong(MediaMetadata.METADATA_KEY_MEDIA_ID);
}
示例6: getMediaDuration
import android.media.MediaMetadata; //導入方法依賴的package包/類
@Override
public int getMediaDuration() {
MediaMetadata mediaMetadata = mMediaController.getMetadata();
return mediaMetadata == null ? 0
: (int) mediaMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
}
示例7: fromMediaMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
public static Track fromMediaMetadata(MediaMetadata metadata) {
String title = metadata.getString(MediaMetadata.METADATA_KEY_TITLE);
String artist = metadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
String album = metadata.getString(MediaMetadata.METADATA_KEY_ALBUM);
String albumArtist = metadata.getString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST);
Bitmap art = metadata.getBitmap(MediaMetadata.METADATA_KEY_ART);
long duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
if (title == null) {
title = metadata.getString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE);
if (title == null) {
title = "";
}
}
if (art == null) {
art = metadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);
}
Track.Builder builder = Track.builder().track(title);
if (duration < 1000) {
// Apple Music incorrectly reports durations in seconds instead of ms (when it reports
// duration at all).
duration *= 1000;
}
if (duration > 0) {
builder.duration(duration);
}
if (album != null && !album.isEmpty()) {
builder.album(album);
}
if (albumArtist != null && !albumArtist.isEmpty()) {
builder.albumArtist(albumArtist);
}
if (art != null) {
builder.art(art);
}
if (artist != null) {
builder.artist(artist);
} else if (albumArtist != null) {
// Some apps (Telegram) set ALBUM_ARTIST but not ARTIST.
builder.artist(albumArtist);
} else {
return new TitleExtractor().transform(builder.artist("").build());
}
return builder.build();
}