Amphitheatre icon indicating copy to clipboard operation
Amphitheatre copied to clipboard

isVideoFile needs to work for capitalized file types as well

Open Fleker opened this issue 9 years ago • 0 comments

This was a frustrating issue that came up while debugging.

VideoUtils.isVideoFile works fine if the extension is lowercase, like .mov or .vob. When the extension is capitalized, like .VOB for some reason, the method returns false. This is obviously incorrect.

Below is the fixed method

public static boolean isVideoFile(String s) {
    String[] fileTypes = new String[]{".3gp", ".aaf.", "mp4", ".ts", ".webm", ".m4v", ".mkv", ".divx", ".xvid", ".rec", ".avi", ".flv", ".f4v", ".moi", ".mpeg", ".mpg", /*".mts", ".m2ts",*/ ".ogv", ".rm", ".rmvb", ".mov", ".wmv", /*".iso",*/ ".vob", ".ifo", ".wtv", ".pyv", ".ogm", /*".img"*/};
    int count = fileTypes.length;
    for (int i = 0; i < count; i++)
        if (s.toLowerCase().endsWith(fileTypes[i]))
            return true;
    return false;
}

Fleker avatar Jun 09 '15 07:06 Fleker