Loading media/java/android/media/MediaFormat.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -197,6 +197,28 @@ public final class MediaFormat { */ */ public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level"; public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level"; /** * A key for boolean AUTOSELECT field. Tracks with AUTOSELECT=true are * considered when automatically selecting a track without specific user * choice (as defined by HLS). * @hide */ public static final String KEY_AUTOSELECT = "autoselect"; /** * A key for boolean DEFAULT field. The track with DEFAULT=true is selected * in the absence of a specific user choice (as defined by HLS). * @hide */ public static final String KEY_DEFAULT = "default"; /** * A key for boolean FORCED field for subtitle tracks. True if it is a * forced subtitle track. * @hide */ public static final String KEY_FORCED = "forced"; /* package private */ MediaFormat(Map<String, Object> map) { /* package private */ MediaFormat(Map<String, Object> map) { mMap = map; mMap = map; } } Loading media/java/android/media/MediaPlayer.java +22 −4 Original line number Original line Diff line number Diff line Loading @@ -1578,7 +1578,8 @@ public class MediaPlayer implements SubtitleController.Listener * unknown or could not be determined, null is returned. * unknown or could not be determined, null is returned. */ */ public MediaFormat getFormat() { public MediaFormat getFormat() { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT || mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { return mFormat; return mFormat; } } return null; return null; Loading @@ -1602,6 +1603,12 @@ public class MediaPlayer implements SubtitleController.Listener if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { mFormat = MediaFormat.createSubtitleFormat( mFormat = MediaFormat.createSubtitleFormat( MEDIA_MIMETYPE_TEXT_SUBRIP, language); MEDIA_MIMETYPE_TEXT_SUBRIP, language); } else if (mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { mFormat = MediaFormat.createSubtitleFormat( MEDIA_MIMETYPE_TEXT_VTT, language); mFormat.setInteger(MediaFormat.KEY_AUTOSELECT, in.readInt()); mFormat.setInteger(MediaFormat.KEY_DEFAULT, in.readInt()); mFormat.setInteger(MediaFormat.KEY_FORCED, in.readInt()); } else { } else { mFormat = new MediaFormat(); mFormat = new MediaFormat(); mFormat.setString(MediaFormat.KEY_LANGUAGE, language); mFormat.setString(MediaFormat.KEY_LANGUAGE, language); Loading Loading @@ -1629,6 +1636,12 @@ public class MediaPlayer implements SubtitleController.Listener public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mTrackType); dest.writeInt(mTrackType); dest.writeString(getLanguage()); dest.writeString(getLanguage()); if (mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { dest.writeInt(mFormat.getInteger(MediaFormat.KEY_AUTOSELECT)); dest.writeInt(mFormat.getInteger(MediaFormat.KEY_DEFAULT)); dest.writeInt(mFormat.getInteger(MediaFormat.KEY_FORCED)); } } } /** /** Loading Loading @@ -1693,6 +1706,12 @@ public class MediaPlayer implements SubtitleController.Listener */ */ public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; /** * MIME type for WebVTT subtitle data. * @hide */ public static final String MEDIA_MIMETYPE_TEXT_VTT = "text/vtt"; /* /* * A helper function to check if the mime type is supported by media framework. * A helper function to check if the mime type is supported by media framework. */ */ Loading Loading @@ -1829,9 +1848,8 @@ public class MediaPlayer implements SubtitleController.Listener if (i < mInbandSubtitleTracks.length) { if (i < mInbandSubtitleTracks.length) { inbandTracks[i] = mInbandSubtitleTracks[i]; inbandTracks[i] = mInbandSubtitleTracks[i]; } else { } else { MediaFormat format = MediaFormat.createSubtitleFormat( SubtitleTrack track = mSubtitleController.addTrack( "text/vtt", tracks[i].getLanguage()); tracks[i].getFormat()); SubtitleTrack track = mSubtitleController.addTrack(format); inbandTracks[i] = track; inbandTracks[i] = track; } } } } Loading Loading
media/java/android/media/MediaFormat.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -197,6 +197,28 @@ public final class MediaFormat { */ */ public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level"; public static final String KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level"; /** * A key for boolean AUTOSELECT field. Tracks with AUTOSELECT=true are * considered when automatically selecting a track without specific user * choice (as defined by HLS). * @hide */ public static final String KEY_AUTOSELECT = "autoselect"; /** * A key for boolean DEFAULT field. The track with DEFAULT=true is selected * in the absence of a specific user choice (as defined by HLS). * @hide */ public static final String KEY_DEFAULT = "default"; /** * A key for boolean FORCED field for subtitle tracks. True if it is a * forced subtitle track. * @hide */ public static final String KEY_FORCED = "forced"; /* package private */ MediaFormat(Map<String, Object> map) { /* package private */ MediaFormat(Map<String, Object> map) { mMap = map; mMap = map; } } Loading
media/java/android/media/MediaPlayer.java +22 −4 Original line number Original line Diff line number Diff line Loading @@ -1578,7 +1578,8 @@ public class MediaPlayer implements SubtitleController.Listener * unknown or could not be determined, null is returned. * unknown or could not be determined, null is returned. */ */ public MediaFormat getFormat() { public MediaFormat getFormat() { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT || mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { return mFormat; return mFormat; } } return null; return null; Loading @@ -1602,6 +1603,12 @@ public class MediaPlayer implements SubtitleController.Listener if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT) { mFormat = MediaFormat.createSubtitleFormat( mFormat = MediaFormat.createSubtitleFormat( MEDIA_MIMETYPE_TEXT_SUBRIP, language); MEDIA_MIMETYPE_TEXT_SUBRIP, language); } else if (mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { mFormat = MediaFormat.createSubtitleFormat( MEDIA_MIMETYPE_TEXT_VTT, language); mFormat.setInteger(MediaFormat.KEY_AUTOSELECT, in.readInt()); mFormat.setInteger(MediaFormat.KEY_DEFAULT, in.readInt()); mFormat.setInteger(MediaFormat.KEY_FORCED, in.readInt()); } else { } else { mFormat = new MediaFormat(); mFormat = new MediaFormat(); mFormat.setString(MediaFormat.KEY_LANGUAGE, language); mFormat.setString(MediaFormat.KEY_LANGUAGE, language); Loading Loading @@ -1629,6 +1636,12 @@ public class MediaPlayer implements SubtitleController.Listener public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mTrackType); dest.writeInt(mTrackType); dest.writeString(getLanguage()); dest.writeString(getLanguage()); if (mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { dest.writeInt(mFormat.getInteger(MediaFormat.KEY_AUTOSELECT)); dest.writeInt(mFormat.getInteger(MediaFormat.KEY_DEFAULT)); dest.writeInt(mFormat.getInteger(MediaFormat.KEY_FORCED)); } } } /** /** Loading Loading @@ -1693,6 +1706,12 @@ public class MediaPlayer implements SubtitleController.Listener */ */ public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip"; /** * MIME type for WebVTT subtitle data. * @hide */ public static final String MEDIA_MIMETYPE_TEXT_VTT = "text/vtt"; /* /* * A helper function to check if the mime type is supported by media framework. * A helper function to check if the mime type is supported by media framework. */ */ Loading Loading @@ -1829,9 +1848,8 @@ public class MediaPlayer implements SubtitleController.Listener if (i < mInbandSubtitleTracks.length) { if (i < mInbandSubtitleTracks.length) { inbandTracks[i] = mInbandSubtitleTracks[i]; inbandTracks[i] = mInbandSubtitleTracks[i]; } else { } else { MediaFormat format = MediaFormat.createSubtitleFormat( SubtitleTrack track = mSubtitleController.addTrack( "text/vtt", tracks[i].getLanguage()); tracks[i].getFormat()); SubtitleTrack track = mSubtitleController.addTrack(format); inbandTracks[i] = track; inbandTracks[i] = track; } } } } Loading