Search in sources :

Example 16 with MediaMetadata

use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.

the class IcyHeadersTest method populateMediaMetadata.

@Test
public void populateMediaMetadata() {
    IcyHeaders headers = new IcyHeaders(/* bitrate= */
    1234, /* genre= */
    "pop", /* name= */
    "radio station", /* url= */
    "url", /* isPublic= */
    true, /* metadataInterval= */
    5678);
    MediaMetadata.Builder builder = new MediaMetadata.Builder();
    headers.populateMediaMetadata(builder);
    MediaMetadata mediaMetadata = builder.build();
    assertThat(mediaMetadata.station.toString()).isEqualTo("radio station");
    assertThat(mediaMetadata.genre.toString()).isEqualTo("pop");
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Test(org.junit.Test)

Example 17 with MediaMetadata

use of com.google.android.exoplayer2.MediaMetadata in project ExoPlayer by google.

the class DefaultMediaItemConverter method getMediaItem.

// Deserialization.
private static MediaItem getMediaItem(JSONObject customData, com.google.android.exoplayer2.MediaMetadata mediaMetadata) {
    try {
        JSONObject mediaItemJson = customData.getJSONObject(KEY_MEDIA_ITEM);
        MediaItem.Builder builder = new MediaItem.Builder().setUri(Uri.parse(mediaItemJson.getString(KEY_URI))).setMediaId(mediaItemJson.getString(KEY_MEDIA_ID)).setMediaMetadata(mediaMetadata);
        if (mediaItemJson.has(KEY_MIME_TYPE)) {
            builder.setMimeType(mediaItemJson.getString(KEY_MIME_TYPE));
        }
        if (mediaItemJson.has(KEY_DRM_CONFIGURATION)) {
            populateDrmConfiguration(mediaItemJson.getJSONObject(KEY_DRM_CONFIGURATION), builder);
        }
        return builder.build();
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }
}
Also used : JSONObject(org.json.JSONObject) MediaItem(com.google.android.exoplayer2.MediaItem) JSONException(org.json.JSONException)

Example 18 with MediaMetadata

use of com.google.android.exoplayer2.MediaMetadata in project Douya by DreaminginCodeZH.

the class MediaPlayback method createMediaSource.

private MediaSource createMediaSource() {
    if (mMediaMetadatas.size() == 1) {
        return mCreateMediaSource.apply(mMediaMetadatas.get(0));
    }
    MediaSource[] mediaSources = new MediaSource[mMediaMetadatas.size()];
    for (int i = 0; i < mMediaMetadatas.size(); ++i) {
        MediaMetadataCompat mediaMetadata = mMediaMetadatas.get(i);
        mediaSources[i] = mCreateMediaSource.apply(mediaMetadata);
    }
    return new ConcatenatingMediaSource(mediaSources);
}
Also used : MediaMetadataCompat(android.support.v4.media.MediaMetadataCompat) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) SuppressLint(android.annotation.SuppressLint)

Aggregations

Test (org.junit.Test)10 MediaMetadata (com.google.android.exoplayer2.MediaMetadata)8 Metadata (com.google.android.exoplayer2.metadata.Metadata)4 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)3 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 Nullable (androidx.annotation.Nullable)2 MediaItem (com.google.android.exoplayer2.MediaItem)2 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)2 EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)2 TestPlayerRunHelper.playUntilStartOfMediaItem (com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilStartOfMediaItem)2 ArrayList (java.util.ArrayList)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 MediaMetadataCompat (android.support.v4.media.MediaMetadataCompat)1 TextUtils (android.text.TextUtils)1 ContextCompat (androidx.core.content.ContextCompat)1 CallbackMediaItem (androidx.media2.common.CallbackMediaItem)1