Search in sources :

Example 1 with SubtitleConfiguration

use of com.google.android.exoplayer2.MediaItem.SubtitleConfiguration in project ExoPlayer by google.

the class IntentUtil method createMediaItemFromIntent.

private static MediaItem createMediaItemFromIntent(Uri uri, Intent intent, String extrasKeySuffix) {
    @Nullable String mimeType = intent.getStringExtra(MIME_TYPE_EXTRA + extrasKeySuffix);
    @Nullable String title = intent.getStringExtra(TITLE_EXTRA + extrasKeySuffix);
    @Nullable String adTagUri = intent.getStringExtra(AD_TAG_URI_EXTRA + extrasKeySuffix);
    @Nullable SubtitleConfiguration subtitleConfiguration = createSubtitleConfiguration(intent, extrasKeySuffix);
    MediaItem.Builder builder = new MediaItem.Builder().setUri(uri).setMimeType(mimeType).setMediaMetadata(new MediaMetadata.Builder().setTitle(title).build()).setClippingConfiguration(new ClippingConfiguration.Builder().setStartPositionMs(intent.getLongExtra(CLIP_START_POSITION_MS_EXTRA + extrasKeySuffix, 0)).setEndPositionMs(intent.getLongExtra(CLIP_END_POSITION_MS_EXTRA + extrasKeySuffix, C.TIME_END_OF_SOURCE)).build());
    if (adTagUri != null) {
        builder.setAdsConfiguration(new MediaItem.AdsConfiguration.Builder(Uri.parse(adTagUri)).build());
    }
    if (subtitleConfiguration != null) {
        builder.setSubtitleConfigurations(ImmutableList.of(subtitleConfiguration));
    }
    return populateDrmPropertiesFromIntent(builder, intent, extrasKeySuffix).build();
}
Also used : SubtitleConfiguration(com.google.android.exoplayer2.MediaItem.SubtitleConfiguration) MediaItem(com.google.android.exoplayer2.MediaItem) Nullable(androidx.annotation.Nullable)

Example 2 with SubtitleConfiguration

use of com.google.android.exoplayer2.MediaItem.SubtitleConfiguration in project ExoPlayer by google.

the class IntentUtil method addPlaybackPropertiesToIntent.

private static void addPlaybackPropertiesToIntent(MediaItem.LocalConfiguration localConfiguration, Intent intent, String extrasKeySuffix) {
    intent.putExtra(MIME_TYPE_EXTRA + extrasKeySuffix, localConfiguration.mimeType).putExtra(AD_TAG_URI_EXTRA + extrasKeySuffix, localConfiguration.adsConfiguration != null ? localConfiguration.adsConfiguration.adTagUri.toString() : null);
    if (localConfiguration.drmConfiguration != null) {
        addDrmConfigurationToIntent(localConfiguration.drmConfiguration, intent, extrasKeySuffix);
    }
    if (!localConfiguration.subtitleConfigurations.isEmpty()) {
        checkState(localConfiguration.subtitleConfigurations.size() == 1);
        MediaItem.SubtitleConfiguration subtitleConfiguration = localConfiguration.subtitleConfigurations.get(0);
        intent.putExtra(SUBTITLE_URI_EXTRA + extrasKeySuffix, subtitleConfiguration.uri.toString());
        intent.putExtra(SUBTITLE_MIME_TYPE_EXTRA + extrasKeySuffix, subtitleConfiguration.mimeType);
        intent.putExtra(SUBTITLE_LANGUAGE_EXTRA + extrasKeySuffix, subtitleConfiguration.language);
    }
}
Also used : SubtitleConfiguration(com.google.android.exoplayer2.MediaItem.SubtitleConfiguration) MediaItem(com.google.android.exoplayer2.MediaItem)

Aggregations

MediaItem (com.google.android.exoplayer2.MediaItem)2 SubtitleConfiguration (com.google.android.exoplayer2.MediaItem.SubtitleConfiguration)2 Nullable (androidx.annotation.Nullable)1