mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Mark MediaItem.Subtitle.mimeType as @Nullable
The MIME type is currently required to select a SubtitleDecoder
implementation in the TextRenderer. Future changes might remove this
requirement, so we pre-emptively mark the field as @Nullable.
The change in SingleSampleMediaSource ensures the track still maps to
the TextRenderer, otherwise it shows up as unmapped. Passing null MIME
type to MediaItem.Subtitle constructor now results in this from
EventLogger:
TextRenderer [
Group:0, adaptive_supported=N/A [
[ ] Track:0, id=null, mimeType=text/x-unknown, language=en, supported=NO_UNSUPPORTED_TYPE
]
]
PiperOrigin-RevId: 398010809
This commit is contained in:
parent
dd39513a2e
commit
e0a9540cd3
4 changed files with 10 additions and 6 deletions
|
|
@ -1189,8 +1189,8 @@ public final class MediaItem implements Bundleable {
|
|||
|
||||
/** The {@link Uri} to the subtitle file. */
|
||||
public final Uri uri;
|
||||
/** The MIME type. */
|
||||
public final String mimeType;
|
||||
/** The optional MIME type of the subtitle file, or {@code null} if unspecified. */
|
||||
@Nullable public final String mimeType;
|
||||
/** The language. */
|
||||
@Nullable public final String language;
|
||||
/** The selection flags. */
|
||||
|
|
@ -1261,7 +1261,7 @@ public final class MediaItem implements Bundleable {
|
|||
Subtitle other = (Subtitle) obj;
|
||||
|
||||
return uri.equals(other.uri)
|
||||
&& mimeType.equals(other.mimeType)
|
||||
&& Util.areEqual(mimeType, other.mimeType)
|
||||
&& Util.areEqual(language, other.language)
|
||||
&& selectionFlags == other.selectionFlags
|
||||
&& roleFlags == other.roleFlags
|
||||
|
|
@ -1271,7 +1271,7 @@ public final class MediaItem implements Bundleable {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = uri.hashCode();
|
||||
result = 31 * result + mimeType.hashCode();
|
||||
result = 31 * result + (mimeType == null ? 0 : mimeType.hashCode());
|
||||
result = 31 * result + (language == null ? 0 : language.hashCode());
|
||||
result = 31 * result + selectionFlags;
|
||||
result = 31 * result + roleFlags;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ public final class MimeTypes {
|
|||
|
||||
public static final String TEXT_EXOPLAYER_CUES = BASE_TYPE_TEXT + "/x-exoplayer-cues";
|
||||
|
||||
public static final String TEXT_UNKNOWN = BASE_TYPE_TEXT + "/x-unknown";
|
||||
|
||||
// application/ MIME types
|
||||
|
||||
public static final String APPLICATION_MP4 = BASE_TYPE_APPLICATION + "/mp4";
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||
mediaSources[0] = mediaSource;
|
||||
for (int i = 0; i < subtitles.size(); i++) {
|
||||
if (useProgressiveMediaSourceForSubtitles
|
||||
&& subtitles.get(i).mimeType.equals(MimeTypes.TEXT_VTT)) {
|
||||
&& MimeTypes.TEXT_VTT.equals(subtitles.get(i).mimeType)) {
|
||||
int index = i;
|
||||
ProgressiveMediaSource.Factory progressiveMediaSourceFactory =
|
||||
new ProgressiveMediaSource.Factory(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package com.google.android.exoplayer2.source;
|
||||
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
@ -28,6 +29,7 @@ import com.google.android.exoplayer2.upstream.DataSpec;
|
|||
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
||||
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
|
||||
import com.google.android.exoplayer2.upstream.TransferListener;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
|
|
@ -163,7 +165,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||
format =
|
||||
new Format.Builder()
|
||||
.setId(trackId)
|
||||
.setSampleMimeType(subtitle.mimeType)
|
||||
.setSampleMimeType(firstNonNull(subtitle.mimeType, MimeTypes.TEXT_UNKNOWN))
|
||||
.setLanguage(subtitle.language)
|
||||
.setSelectionFlags(subtitle.selectionFlags)
|
||||
.setRoleFlags(subtitle.roleFlags)
|
||||
|
|
|
|||
Loading…
Reference in a new issue