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");
}
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();
}
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);
}
}
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);
}
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);
}
Aggregations