本文整理匯總了Java中android.media.MediaMetadata.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaMetadata.Builder方法的具體用法?Java MediaMetadata.Builder怎麽用?Java MediaMetadata.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.MediaMetadata
的用法示例。
在下文中一共展示了MediaMetadata.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateNowPlayingMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
/**
* Update title and pic on now playing card
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void updateNowPlayingMetadata() {
MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();
String title = mVideoInfo.scraperTitle!=null?mVideoInfo.scraperTitle:mVideoInfo.title!=null?mVideoInfo.title:Utils.getFileNameWithoutExtension(mUri);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE,
title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE,title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
mVideoInfo.scraperCover);
Bitmap bitmap = BitmapFactory.decodeFile(mVideoInfo.scraperCover);
if (bitmap == null&&mVideoInfo.id >= 0) { //if no scrapped poster, try to get a thumbnail
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
bitmap = VideoStore.Video.Thumbnails.getThumbnail(getContentResolver(),mVideoInfo.id, VideoStore.Video.Thumbnails.MINI_KIND, options);
}
if (bitmap == null) {
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.widget_default_video);
}
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
mSession.setMetadata(metadataBuilder.build());
}
示例2: updateMediaSession
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMediaSession(int state) {
MediaMetadata.Builder mediaBuilder = null;
Bitmap bitmap = null;
try {
URL url = new URL(mRadioIcon);
bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e) {
Log.e(TAG, "BitmapFactory.decodeStream", e);
}
mediaBuilder = new MediaMetadata.Builder();
mediaBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, mTitle);
if (bitmap != null) {
mediaBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
}
mMediaSession.setMetadata(mediaBuilder.build());
PlaybackState.Builder stateBuilder = new PlaybackState.Builder();
stateBuilder.setState(state, 0, 1.0f);
mMediaSession.setPlaybackState(stateBuilder.build());
}
示例3: updateMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMetadata(final Movie movie) {
final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();
String title = movie.getTitle().replace("_", " -");
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE,
movie.getDescription());
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
movie.getCardImageUrl());
// And at minimum the title and artist for legacy support
metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, movie.getStudio());
Glide.with(this)
.load(Uri.parse(movie.getCardImageUrl()))
.asBitmap()
.into(new SimpleTarget<Bitmap>(500, 500) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
mSession.setMetadata(metadataBuilder.build());
}
});
}
示例4: updateMediaSession
import android.media.MediaMetadata; //導入方法依賴的package包/類
public static void updateMediaSession(boolean updateMetadata,
MediaMetadata.Builder mediaBuilder,
final MediaSession mediaSession,
final int playbackState,
final long position,
final float speed) {
if (mediaSession.isActive()) {
if (updateMetadata) {
mediaSession.setMetadata(mediaBuilder.build());
}
PlaybackState.Builder stateBuilder = new PlaybackState.Builder();
stateBuilder.setState(playbackState,
position,
speed);
mediaSession.setPlaybackState(stateBuilder.build());
}
}
示例5: getMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
public static MediaMetadata getMetadata(Context ctx, String mediaId) {
MediaMetadata metadataWithoutBitmap = music.get(mediaId);
Bitmap albumArt = getAlbumBitmap(ctx, mediaId);
// Since MediaMetadata is immutable, we need to create a copy to set the album art
// We don't set it initially on all items so that they don't take unnecessary memory
MediaMetadata.Builder builder = new MediaMetadata.Builder();
for (String key: new String[]{MediaMetadata.METADATA_KEY_MEDIA_ID,
MediaMetadata.METADATA_KEY_ALBUM, MediaMetadata.METADATA_KEY_ARTIST,
MediaMetadata.METADATA_KEY_GENRE, MediaMetadata.METADATA_KEY_TITLE}) {
builder.putString(key, metadataWithoutBitmap.getString(key));
}
builder.putLong(MediaMetadata.METADATA_KEY_DURATION,
metadataWithoutBitmap.getLong(MediaMetadata.METADATA_KEY_DURATION));
builder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, albumArt);
return builder.build();
}
示例6: setMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
public void setMetadata(MusicDirectory.Entry currentSong, Bitmap bitmap) {
MediaMetadata.Builder builder = new MediaMetadata.Builder();
builder.putString(MediaMetadata.METADATA_KEY_ARTIST, (currentSong == null) ? null : currentSong.getArtist())
.putString(MediaMetadata.METADATA_KEY_ALBUM, (currentSong == null) ? null : currentSong.getAlbum())
.putString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST, (currentSong == null) ? null : currentSong.getArtist())
.putString(MediaMetadata.METADATA_KEY_TITLE, (currentSong) == null ? null : currentSong.getTitle())
.putString(MediaMetadata.METADATA_KEY_GENRE, (currentSong) == null ? null : currentSong.getGenre())
.putLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER, (currentSong == null) ?
0 : ((currentSong.getTrack() == null) ? 0 : currentSong.getTrack()))
.putLong(MediaMetadata.METADATA_KEY_DURATION, (currentSong == null) ?
0 : ((currentSong.getDuration() == null) ? 0 : (currentSong.getDuration() * 1000)));
if(bitmap != null) {
builder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, bitmap);
}
mediaSession.setMetadata(builder.build());
}
示例7: initMediaMetaData
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void initMediaMetaData( String id ) {
for( Song song : mSongs ) {
if( !TextUtils.isEmpty( song.getuId() ) && song.getuId().equalsIgnoreCase( id ) ) {
MediaMetadata.Builder builder = new MediaMetadata.Builder();
if( !TextUtils.isEmpty( song.getTitle() ) )
builder.putText( MediaMetadata.METADATA_KEY_TITLE, song.getTitle() );
if( !TextUtils.isEmpty( song.getArtist() ) )
builder.putText( MediaMetadata.METADATA_KEY_ARTIST, song.getArtist() );
if( !TextUtils.isEmpty( song.getGenre() ) )
builder.putText( MediaMetadata.METADATA_KEY_GENRE, song.getGenre() );
if( !TextUtils.isEmpty( song.getAlbum() ) )
builder.putText( MediaMetadata.METADATA_KEY_ALBUM, song.getAlbum() );
if( !TextUtils.isEmpty( song.getAlbumUrl() ) )
builder.putText( MediaMetadata.METADATA_KEY_ALBUM_ART_URI, song.getAlbumUrl() );
mMediaSession.setMetadata( builder.build() );
}
}
}
示例8: updateMediaSessionData
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMediaSessionData() {
if (mCurrentEpisode == null) {
return;
}
final MediaMetadata.Builder builder = new MediaMetadata.Builder();
updatePlaybackState(ExoPlayer.STATE_IDLE);
updateMediaSessionIntent();
builder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, mCurrentEpisode.getSeriesTitle());
builder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, mCurrentEpisode.getTitle());
builder.putLong(MediaMetadata.METADATA_KEY_DURATION, mCurrentEpisode.getDuration() * 1000);
builder.putString(MediaMetadata.METADATA_KEY_TITLE, mCurrentEpisode.getSeriesTitle());
builder.putString(MediaMetadata.METADATA_KEY_ARTIST, mCurrentEpisode.getTitle());
Point size = new Point(getResources().getDimensionPixelSize(R.dimen.card_width),
getResources().getDimensionPixelSize(R.dimen.card_height));
Picasso.with(this).load(mCurrentEpisode.getThumbnail()).resize(size.x, size.y).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
builder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
mediaSession.setMetadata(builder.build());
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
示例9: handlePlayRequest
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void handlePlayRequest() {
delayedStopHandler.removeCallbacksAndMessages(null);
if (!serviceStarted) {
startService(new Intent(getApplicationContext(), MusicBrowserService.class));
serviceStarted = true;
}
if (!mediaSession.isActive()) {
mediaSession.setActive(true);
}
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject == null) {
return;
}
MediaMetadata.Builder builder = new MediaMetadata.Builder();
builder.putLong(MediaMetadata.METADATA_KEY_DURATION, messageObject.getDuration() * 1000);
builder.putString(MediaMetadata.METADATA_KEY_ARTIST, messageObject.getMusicAuthor());
builder.putString(MediaMetadata.METADATA_KEY_TITLE, messageObject.getMusicTitle());
AudioInfo audioInfo = MediaController.getInstance().getAudioInfo();
if (audioInfo != null) {
Bitmap bitmap = audioInfo.getCover();
if (bitmap != null) {
builder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, bitmap);
}
}
mediaSession.setMetadata(builder.build());
}
示例10: updateMetaData
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMetaData() {
MySong song = App.MiamPlayer.getCurrentSong();
if (song != null && song.getArt() != null) {
MediaMetadata.Builder builder = new MediaMetadata.Builder();
builder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, song.getArt());
builder.putString(MediaMetadata.METADATA_KEY_ALBUM, song.getAlbum());
builder.putString(MediaMetadata.METADATA_KEY_TITLE, song.getTitle());
builder.putString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST, song.getAlbumartist());
builder.putString(MediaMetadata.METADATA_KEY_ARTIST, song.getArtist());
mMediaSession.setMetadata(builder.build());
}
}
示例11: updateMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMetadata(Video video) {
final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();
String title = video.description.replace("_", " -");
metadataBuilder.putString(MediaMetadata.METADATA_KEY_MEDIA_ID, video.title);
String uri = "android.resource://" + getPackageName() + "/" + video.imageResource;
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE,
video.title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_DESCRIPTION,
video.description);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
uri);
metadataBuilder.putLong(MediaMetadata.METADATA_KEY_DURATION, mVideoView.getDuration());
// And at minimum the title and artist for legacy support
metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, video.description);
Glide.with(this)
.load(R.drawable.lake)
.asBitmap()
.into(new SimpleTarget<Bitmap>(500, 500) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
mSession.setMetadata(metadataBuilder.build());
}
});
}
示例12: onCreate
import android.media.MediaMetadata; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
media = (MediaFile) getIntent().getSerializableExtra(MEDIA);
videoFragment = (VideoFragment) getFragmentManager().findFragmentById(R.id.playback_fragment);
VideoFragmentGlueHost glueHost = new VideoFragmentGlueHost(videoFragment);
subtitleView = (SubtitleView) findViewById(R.id.subtitle_view);
if (subtitleView != null) {
subtitleView.setUserDefaultStyle();
subtitleView.setUserDefaultTextSize();
}
Handler mainHandler = new Handler();
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
MappingTrackSelector trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
player.addListener(this);
player.setTextOutput(this);
glueHelper = new ExoPlayerGlue(player, trackSelector, this);
glueHelper.setHost(glueHost);
session = new MediaSession(this, "ITPlayer");
session.setCallback(new ExoPlayerMediaSessionCalback(player));
session.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
session.setActive(true);
MediaMetadata.Builder metaBuilder = new MediaMetadata.Builder();
session.setMetadata(metaBuilder.build());
new SourceTask().execute(media);
}
示例13: updateClientBitmap
import android.media.MediaMetadata; //導入方法依賴的package包/類
private synchronized Void updateClientBitmap(Bitmap bitmap) {
if (remoteClientBitmap == bitmap) return null;
final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder(mediaMetadata);
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, bitmap);
mediaSession.setMetadata(mediaMetadata = metadataBuilder.build());
// Track the remote client bitmap and recycle it in case the remote control client
// does not properly recycle the bitmap
if (remoteClientBitmap != null) remoteClientBitmap.recycle();
remoteClientBitmap = bitmap;
return null;
}
示例14: updateMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMetadata() {
MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();
if (mediaTitle == null && mediaArtist == null) {
metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, "No info");
}
else {
// And at minimum the title and artist for legacy support
metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, mediaTitle);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, mediaArtist);
}
// Add any other fields you have for your data as well
mSession.setMetadata(metadataBuilder.build());
}
示例15: updateMetadata
import android.media.MediaMetadata; //導入方法依賴的package包/類
private void updateMetadata(Post post) {
final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();
String title = post.description.replace("_", " -");
metadataBuilder.putString(MediaMetadata.METADATA_KEY_MEDIA_ID, post.postId);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE,
post.username);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_DESCRIPTION,
post.description);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
post.avatarUrl);
metadataBuilder.putLong(MediaMetadata.METADATA_KEY_DURATION, mVideoView.getDuration());
// And at minimum the title and artist for legacy support
metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title);
metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, post.username);
Glide.with(this)
.load(post.avatarUrl)
.asBitmap()
.into(new SimpleTarget<Bitmap>(500, 500) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
mSession.setMetadata(metadataBuilder.build());
}
});
}