Add missing properties of MediaItem.Subtitle
Issue: #8044 PiperOrigin-RevId: 336955479
This commit is contained in:
parent
8f04968fb1
commit
36c2fe1053
@ -669,6 +669,10 @@ public final class MediaItem {
|
||||
@Nullable public final String language;
|
||||
/** The selection flags. */
|
||||
@C.SelectionFlags public final int selectionFlags;
|
||||
/** The role flags. */
|
||||
@C.RoleFlags public final int roleFlags;
|
||||
/** The label. */
|
||||
@Nullable public final String label;
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
@ -682,7 +686,7 @@ public final class MediaItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance with the given selection flags.
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param uri The {@link Uri URI} to the subtitle file.
|
||||
* @param mimeType The MIME type.
|
||||
@ -691,10 +695,32 @@ public final class MediaItem {
|
||||
*/
|
||||
public Subtitle(
|
||||
Uri uri, String mimeType, @Nullable String language, @C.SelectionFlags int selectionFlags) {
|
||||
this(uri, mimeType, language, selectionFlags, /* roleFlags= */ 0, /* label= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param uri The {@link Uri URI} to the subtitle file.
|
||||
* @param mimeType The MIME type.
|
||||
* @param language The optional language.
|
||||
* @param selectionFlags The selection flags.
|
||||
* @param roleFlags The role flags.
|
||||
* @param label The optional label.
|
||||
*/
|
||||
public Subtitle(
|
||||
Uri uri,
|
||||
String mimeType,
|
||||
@Nullable String language,
|
||||
@C.SelectionFlags int selectionFlags,
|
||||
@C.RoleFlags int roleFlags,
|
||||
@Nullable String label) {
|
||||
this.uri = uri;
|
||||
this.mimeType = mimeType;
|
||||
this.language = language;
|
||||
this.selectionFlags = selectionFlags;
|
||||
this.roleFlags = roleFlags;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -711,7 +737,9 @@ public final class MediaItem {
|
||||
return uri.equals(other.uri)
|
||||
&& mimeType.equals(other.mimeType)
|
||||
&& Util.areEqual(language, other.language)
|
||||
&& selectionFlags == other.selectionFlags;
|
||||
&& selectionFlags == other.selectionFlags
|
||||
&& roleFlags == other.roleFlags
|
||||
&& Util.areEqual(label, other.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -720,6 +748,8 @@ public final class MediaItem {
|
||||
result = 31 * result + mimeType.hashCode();
|
||||
result = 31 * result + (language == null ? 0 : language.hashCode());
|
||||
result = 31 * result + selectionFlags;
|
||||
result = 31 * result + roleFlags;
|
||||
result = 31 * result + (label == null ? 0 : label.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,14 @@ public class MediaItemTest {
|
||||
Uri.parse(URI_STRING + "/de"),
|
||||
MimeTypes.APPLICATION_TTML,
|
||||
/* language= */ null,
|
||||
C.SELECTION_FLAG_DEFAULT));
|
||||
C.SELECTION_FLAG_DEFAULT),
|
||||
new MediaItem.Subtitle(
|
||||
Uri.parse(URI_STRING + "/fr"),
|
||||
MimeTypes.APPLICATION_SUBRIP,
|
||||
/* language= */ "fr",
|
||||
C.SELECTION_FLAG_DEFAULT,
|
||||
C.ROLE_FLAG_ALTERNATE,
|
||||
"label"));
|
||||
|
||||
MediaItem mediaItem =
|
||||
new MediaItem.Builder().setUri(URI_STRING).setSubtitles(subtitles).build();
|
||||
@ -317,7 +324,10 @@ public class MediaItemTest {
|
||||
new MediaItem.Subtitle(
|
||||
Uri.parse(URI_STRING + "/en"),
|
||||
MimeTypes.APPLICATION_TTML,
|
||||
/* language= */ "en")))
|
||||
/* language= */ "en",
|
||||
C.SELECTION_FLAG_FORCED,
|
||||
C.ROLE_FLAG_ALTERNATE,
|
||||
"label")))
|
||||
.setTag(new Object())
|
||||
.build();
|
||||
|
||||
|
@ -281,6 +281,8 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
||||
.setSampleMimeType(subtitle.mimeType)
|
||||
.setLanguage(subtitle.language)
|
||||
.setSelectionFlags(subtitle.selectionFlags)
|
||||
.setRoleFlags(subtitle.roleFlags)
|
||||
.setLabel(subtitle.label)
|
||||
.build();
|
||||
dataSpec =
|
||||
new DataSpec.Builder().setUri(subtitle.uri).setFlags(DataSpec.FLAG_ALLOW_GZIP).build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user