- add empty constructor to VideoRecorderAppState using user.home and currentTimeMillis

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8715 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 69e691872d
commit 183f46ed3e
  1. 15
      engine/src/desktop/com/jme3/app/state/VideoRecorderAppState.java

@ -48,6 +48,10 @@ public class VideoRecorderAppState extends AbstractAppState {
}); });
private int numCpus = Runtime.getRuntime().availableProcessors(); private int numCpus = Runtime.getRuntime().availableProcessors();
public VideoRecorderAppState() {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "JME3 VideoRecorder running on {0} CPU's", numCpus);
}
public VideoRecorderAppState(File file) { public VideoRecorderAppState(File file) {
this.file = file; this.file = file;
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "JME3 VideoRecorder running on {0} CPU's", numCpus); Logger.getLogger(this.getClass().getName()).log(Level.INFO, "JME3 VideoRecorder running on {0} CPU's", numCpus);
@ -58,6 +62,9 @@ public class VideoRecorderAppState extends AbstractAppState {
} }
public void setFile(File file) { public void setFile(File file) {
if (isInitialized()) {
throw new IllegalStateException("Cannot set file while attached!");
}
this.file = file; this.file = file;
} }
@ -74,6 +81,7 @@ public class VideoRecorderAppState extends AbstractAppState {
public void cleanup() { public void cleanup() {
app.getViewPort().removeProcessor(processor); app.getViewPort().removeProcessor(processor);
app.setTimer(new NanoTimer()); app.setTimer(new NanoTimer());
initialized = false;
super.cleanup(); super.cleanup();
} }
@ -153,7 +161,12 @@ public class VideoRecorderAppState extends AbstractAppState {
public void preFrame(float tpf) { public void preFrame(float tpf) {
if (null == writer) { if (null == writer) {
try { try {
writer = new MjpegFileWriter(file, width, height, framerate); if (file != null) {
String filename = System.getProperty("user.home") + "/jMonkey-" + System.currentTimeMillis() / 1000;
writer = new MjpegFileWriter(new File(filename + ".avi"), width, height, framerate);
} else {
writer = new MjpegFileWriter(file, width, height, framerate);
}
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.SEVERE, "Error creating file writer {0}", ex); Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.SEVERE, "Error creating file writer {0}", ex);
} }

Loading…
Cancel
Save