2222 * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2323 */
2424
25+ import javax .annotation .Nonnull ;
2526import java .util .Arrays ;
27+ import java .util .List ;
2628import java .util .function .Function ;
29+ import java .util .stream .Collectors ;
2730
2831/**
2932 * Static data about various media formats support by NewPipe, eg mime type, extension
@@ -41,9 +44,18 @@ public enum MediaFormat {
4144 M4A (0x100 , "m4a" , "m4a" , "audio/mp4" ),
4245 WEBMA (0x200 , "WebM" , "webm" , "audio/webm" ),
4346 MP3 (0x300 , "MP3" , "mp3" , "audio/mpeg" ),
47+ MP2 (0x310 , "MP2" , "mp2" , "audio/mpeg" ),
4448 OPUS (0x400 , "opus" , "opus" , "audio/opus" ),
4549 OGG (0x500 , "ogg" , "ogg" , "audio/ogg" ),
4650 WEBMA_OPUS (0x200 , "WebM Opus" , "webm" , "audio/webm" ),
51+ AIFF (0x600 , "AIFF" , "aiff" , "audio/aiff" ),
52+ /**
53+ * Same as {@link MediaFormat.AIFF}, just with the shorter suffix/file extension
54+ */
55+ AIF (0x600 , "AIFF" , "aif" , "audio/aiff" ),
56+ WAV (0x700 , "WAV" , "wav" , "audio/wav" ),
57+ FLAC (0x800 , "FLAC" , "flac" , "audio/flac" ),
58+ ALAC (0x900 , "ALAC" , "alac" , "audio/alac" ),
4759 // subtitles formats
4860 VTT (0x1000 , "WebVTT" , "vtt" , "text/vtt" ),
4961 TTML (0x2000 , "Timed Text Markup Language" , "ttml" , "application/ttml+xml" ),
@@ -121,6 +133,19 @@ public static MediaFormat getFromMimeType(final String mimeType) {
121133 .orElse (null );
122134 }
123135
136+ /**
137+ * Get all media formats which have the given mime type.
138+ * @param mimeType the mime type to search for
139+ * @return a modifiable {@link List} which contains the {@link MediaFormat}s
140+ * that have the given mime type.
141+ */
142+ @ Nonnull
143+ public static List <MediaFormat > getAllFromMimeType (final String mimeType ) {
144+ return Arrays .stream (MediaFormat .values ())
145+ .filter (mediaFormat -> mediaFormat .mimeType .equals (mimeType ))
146+ .collect (Collectors .toList ());
147+ }
148+
124149 /**
125150 * Get the media format by its id.
126151 *
0 commit comments