jerrellmardis / Amphitheatre

Amphitheatre is an Android TV app that connects with network shares, organizes and serves videos to any Android capable media player app.
Apache License 2.0
437 stars 87 forks source link

isVideoFile needs to work for capitalized file types as well #53

Open Fleker opened 9 years ago

Fleker commented 9 years ago

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;
}