Search in sources :

Example 1 with MediaFormat

use of org.schabi.newpipe.extractor.MediaFormat in project NewPipe by TeamNewPipe.

the class ListHelper method getDefaultFormat.

private static MediaFormat getDefaultFormat(Context context, @StringRes int defaultFormatKey, @StringRes int defaultFormatValueKey) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String defaultFormat = context.getString(defaultFormatValueKey);
    String defaultFormatString = preferences.getString(context.getString(defaultFormatKey), defaultFormat);
    MediaFormat defaultMediaFormat = getMediaFormatFromKey(context, defaultFormatString);
    if (defaultMediaFormat == null) {
        preferences.edit().putString(context.getString(defaultFormatKey), defaultFormat).apply();
        defaultMediaFormat = getMediaFormatFromKey(context, defaultFormat);
    }
    return defaultMediaFormat;
}
Also used : MediaFormat(org.schabi.newpipe.extractor.MediaFormat) SharedPreferences(android.content.SharedPreferences)

Example 2 with MediaFormat

use of org.schabi.newpipe.extractor.MediaFormat in project NewPipe by TeamNewPipe.

the class ListHelper method getSortedStreamVideosList.

/**
 * Join the two lists of video streams (video_only and normal videos), and sort them according with default format
 * chosen by the user
 *
 * @param context          context to search for the format to give preference
 * @param videoStreams     normal videos list
 * @param videoOnlyStreams video only stream list
 * @param ascendingOrder   true -> smallest to greatest | false -> greatest to smallest
 * @return the sorted list
 */
public static List<VideoStream> getSortedStreamVideosList(Context context, List<VideoStream> videoStreams, List<VideoStream> videoOnlyStreams, boolean ascendingOrder) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    boolean showHigherResolutions = preferences.getBoolean(context.getString(R.string.show_higher_resolutions_key), false);
    MediaFormat defaultFormat = getDefaultFormat(context, R.string.default_video_format_key, R.string.default_video_format_value);
    return getSortedStreamVideosList(defaultFormat, showHigherResolutions, videoStreams, videoOnlyStreams, ascendingOrder);
}
Also used : MediaFormat(org.schabi.newpipe.extractor.MediaFormat) SharedPreferences(android.content.SharedPreferences)

Aggregations

SharedPreferences (android.content.SharedPreferences)2 MediaFormat (org.schabi.newpipe.extractor.MediaFormat)2