-
Notifications
You must be signed in to change notification settings - Fork 3
/
VideoFilter.java
97 lines (76 loc) · 2.69 KB
/
VideoFilter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package Harvester;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/*
* @author Nicholas Dunn
* @date November 14, 2008
*
* Allows a user filter files by video file extension.
*
* Based on code from http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
* Some extensions taken from http://people.csail.mit.edu/tbuehler/video/extensions.html
*/
public class VideoFilter extends FileFilter implements java.io.FileFilter {
/** The file extension for .avi movies.*/
public final static String AVI = "avi";
/** The file extension for .divx movies.*/
public final static String DIVX = "divx";
/** The file extension for .dv movies.*/
public final static String DV = "dv";
/** The file extension for .mov movies.*/
public final static String MOV = "mov";
/** The file extension for .avi movies.*/
public final static String MOVIE = "movie";
/** The file extension for .mpeg movies.*/
public final static String MPEG = "mpeg";
/** The file extension for .mpg movies.*/
public final static String MPG = "mpg";
/** The file extension for .mp4 movies.*/
public final static String MP4 = "mp4";
/** The file extension for QuickTime movies.*/
public final static String QT = "qt";
/** The file extension for RealMedia movies.*/
public final static String RM = "rm";
/** The file extension for Windows Media Video movies.*/
public final static String WMV = "wmv";
public String getDescription() {
return "Movie Files";
}
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String extension = getExtension(f);
if (extension != null) {
if (extension.equals(AVI) ||
extension.equals(DIVX) ||
extension.equals(DV) ||
extension.equals(MOV) ||
extension.equals(MOVIE)||
extension.equals(MPEG) ||
extension.equals(MPG) ||
extension.equals(MP4) ||
extension.equals(QT) ||
extension.equals(RM) ||
extension.equals(WMV)) {
return true;
}
else {
return false;
}
}
return false;
}
/*
* Get the extension of a file.
*/
public static String getExtension(File f) {
String ext = null;
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
}
return ext;
}
}