Search in sources :

Example 21 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder 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 22 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class WorkManagerScheduler method buildConstraints.

private static Constraints buildConstraints(Requirements requirements) {
    Requirements filteredRequirements = requirements.filterRequirements(SUPPORTED_REQUIREMENTS);
    if (!filteredRequirements.equals(requirements)) {
        Log.w(TAG, "Ignoring unsupported requirements: " + (filteredRequirements.getRequirements() ^ requirements.getRequirements()));
    }
    Constraints.Builder builder = new Constraints.Builder();
    if (requirements.isUnmeteredNetworkRequired()) {
        builder.setRequiredNetworkType(NetworkType.UNMETERED);
    } else if (requirements.isNetworkRequired()) {
        builder.setRequiredNetworkType(NetworkType.CONNECTED);
    } else {
        builder.setRequiredNetworkType(NetworkType.NOT_REQUIRED);
    }
    if (Util.SDK_INT >= 23 && requirements.isIdleRequired()) {
        setRequiresDeviceIdle(builder);
    }
    if (requirements.isChargingRequired()) {
        builder.setRequiresCharging(true);
    }
    if (requirements.isStorageNotLowRequired()) {
        builder.setRequiresStorageNotLow(true);
    }
    return builder.build();
}
Also used : Constraints(androidx.work.Constraints) Requirements(com.google.android.exoplayer2.scheduler.Requirements)

Example 23 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder 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 24 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class DefaultMediaItemConverterTest method serialize_deserialize_complete.

@Test
public void serialize_deserialize_complete() {
    MediaItem.Builder builder = new MediaItem.Builder();
    MediaItem item = builder.setUri(Uri.parse("http://example.com")).setMediaMetadata(MediaMetadata.EMPTY).setMimeType(MimeTypes.APPLICATION_MPD).setDrmConfiguration(new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID).setLicenseUri("http://license.com").setLicenseRequestHeaders(ImmutableMap.of("key", "value")).build()).build();
    DefaultMediaItemConverter converter = new DefaultMediaItemConverter();
    MediaQueueItem queueItem = converter.toMediaQueueItem(item);
    MediaItem reconstructedItem = converter.toMediaItem(queueItem);
    assertThat(reconstructedItem).isEqualTo(item);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) MediaQueueItem(com.google.android.gms.cast.MediaQueueItem) Test(org.junit.Test)

Example 25 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class DefaultMediaItemConverterTest method serialize_deserialize_minimal.

@Test
public void serialize_deserialize_minimal() {
    MediaItem.Builder builder = new MediaItem.Builder();
    MediaItem item = builder.setUri("http://example.com").setMimeType(MimeTypes.APPLICATION_MPD).build();
    DefaultMediaItemConverter converter = new DefaultMediaItemConverter();
    MediaQueueItem queueItem = converter.toMediaQueueItem(item);
    MediaItem reconstructedItem = converter.toMediaItem(queueItem);
    assertThat(reconstructedItem).isEqualTo(item);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) MediaQueueItem(com.google.android.gms.cast.MediaQueueItem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Nullable (androidx.annotation.Nullable)7 MediaItem (com.google.android.exoplayer2.MediaItem)6 MediaMetadata (com.google.android.exoplayer2.MediaMetadata)5 Metadata (com.google.android.exoplayer2.metadata.Metadata)4 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)3 ParametersBuilder (com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder)3 ImmutableList (com.google.common.collect.ImmutableList)3 Bundle (android.os.Bundle)2 FakeDataSource (com.google.android.exoplayer2.testutil.FakeDataSource)2 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)2 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)2 MediaQueueItem (com.google.android.gms.cast.MediaQueueItem)2 SurfaceTexture (android.graphics.SurfaceTexture)1 PlaybackStateCompat (android.support.v4.media.session.PlaybackStateCompat)1 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)1 BackgroundColorSpan (android.text.style.BackgroundColorSpan)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 RelativeSizeSpan (android.text.style.RelativeSizeSpan)1 StrikethroughSpan (android.text.style.StrikethroughSpan)1