forked from clayandgithub/javaplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVlcjTest.java
More file actions
96 lines (85 loc) · 3.21 KB
/
VlcjTest.java
File metadata and controls
96 lines (85 loc) · 3.21 KB
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
/**
* @author clayoverwind
* @version 2017/4/10
* @E-mail clayanddev@163.com
*/
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import com.clayoverwind.javaplayer.util.NativeDiscovery;
import com.clayoverwind.javaplayer.util.WinVlcDiscoveryStrategy;
import org.apache.log4j.BasicConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.runtime.x.LibXUtil;
import com.sun.jna.NativeLibrary;
/**
* Base class for tests.
* <p>
* This makes it a lot easier to switch vlc versions or vlc install directories without having to
* change system properties on a lot of IDE application run-configurations.
* <p>
* Explicitly setting a search path forces JNA to search that path <em>first</em>.
* <p>
* The search path should be the directory that contains libvlc.so and libvlccore.so.
* <p>
* If you do not explicitly set the search path, the system search path will be used.
* <p>
* You can also set the log level here.
*/
public abstract class VlcjTest {
/**
* Log.
*/
private static final Logger logger = LoggerFactory.getLogger(VlcjTest.class);
/**
* Change this to point to your own vlc installation, or comment out the code if you want to use
* your system default installation.
* <p>
* This is a bit more explicit than using the -Djna.library.path= system property.
*/
private static final String NATIVE_LIBRARY_SEARCH_PATH = null;
/**
* Set to true to dump out native JNA memory structures.
*/
private static final String DUMP_NATIVE_MEMORY = "false";
/**
* Static initialisation.
*/
static {
// Initialise Log4J (this is good enough for testing, vlcj depends on log4j only for testing here)
BasicConfigurator.configure();
// Safely try to initialise LibX11 to reduce the opportunity for native
// crashes - this will silently throw an Error on Windows (and maybe MacOS)
// that can safely be ignored
LibXUtil.initialise();
new NativeDiscovery(new WinVlcDiscoveryStrategy()).discover();
// if(null != NATIVE_LIBRARY_SEARCH_PATH) {
// logger.info("Explicitly adding JNA native library search path: '{}'", NATIVE_LIBRARY_SEARCH_PATH);
// NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), NATIVE_LIBRARY_SEARCH_PATH);
// }
//
// System.setProperty("jna.dump_memory", DUMP_NATIVE_MEMORY);
}
/**
* Set the standard look and feel.
*/
protected static final void setLookAndFeel() {
String lookAndFeelClassName = null;
LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
for(LookAndFeelInfo lookAndFeel : lookAndFeelInfos) {
if("Nimbus".equals(lookAndFeel.getName())) {
lookAndFeelClassName = lookAndFeel.getClassName();
}
}
if(lookAndFeelClassName == null) {
lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName();
}
try {
UIManager.setLookAndFeel(lookAndFeelClassName);
}
catch(Exception e) {
// Silently fail, it doesn't matter
}
}
}