rlm@14
|
1 package com.aurellem.capture.examples;
|
rlm@14
|
2
|
rlm@14
|
3 import java.io.File;
|
rlm@14
|
4 import java.io.IOException;
|
rlm@14
|
5
|
rlm@14
|
6 import jme3test.helloworld.HelloAudio;
|
rlm@14
|
7 import jme3test.helloworld.HelloJME3;
|
rlm@14
|
8 import jme3test.niftygui.TestNiftyExamples;
|
rlm@14
|
9 import jme3test.water.TestPostWater;
|
rlm@14
|
10
|
rlm@14
|
11 import com.aurellem.capture.Capture;
|
rlm@14
|
12 import com.aurellem.capture.IsoTimer;
|
rlm@14
|
13 import com.jme3.app.SimpleApplication;
|
rlm@14
|
14
|
rlm@14
|
15
|
rlm@14
|
16 /**
|
rlm@14
|
17 *
|
rlm@14
|
18 * Demonstrates how to use basic Audio/Video capture with a jMonkeyEngine
|
rlm@14
|
19 * application. You can use these techniques to make high quality cutscenes
|
rlm@14
|
20 * or demo videos, even on very slow laptops.
|
rlm@14
|
21 *
|
rlm@14
|
22 * @author Robert McIntyre
|
rlm@14
|
23 *
|
rlm@14
|
24 */
|
rlm@14
|
25
|
rlm@14
|
26 public class Basic {
|
rlm@14
|
27
|
rlm@14
|
28 public static void basicVideo() throws IOException{
|
rlm@14
|
29 File video = File.createTempFile("HelloJME3", ".avi");
|
rlm@14
|
30 System.out.println("Saving video to: " + video.getCanonicalPath());
|
rlm@14
|
31 SimpleApplication app = new HelloJME3();
|
rlm@14
|
32 app.setTimer(new IsoTimer(60));
|
rlm@14
|
33 app.setShowSettings(false);
|
rlm@14
|
34
|
rlm@14
|
35 Capture.captureVideo(app, video);
|
rlm@14
|
36 app.start();
|
rlm@14
|
37 }
|
rlm@14
|
38
|
rlm@14
|
39 public static void basicVideoGUI() throws IOException {
|
rlm@14
|
40 File video = File.createTempFile("GUI", ".avi");
|
rlm@14
|
41 System.out.println("Saving video to: " + video.getCanonicalPath());
|
rlm@14
|
42 SimpleApplication app = new TestNiftyExamples();
|
rlm@14
|
43 app.setTimer(new IsoTimer(60));
|
rlm@14
|
44 app.setShowSettings(false);
|
rlm@14
|
45
|
rlm@14
|
46 Capture.captureVideo(app, video);
|
rlm@14
|
47 app.start();
|
rlm@14
|
48 }
|
rlm@14
|
49
|
rlm@14
|
50 public static void basicAudio() throws IOException{
|
rlm@14
|
51 File audio = File.createTempFile("BasicAudio", ".wav");
|
rlm@14
|
52 System.out.println("Saving audio to: " + audio.getCanonicalPath());
|
rlm@14
|
53 SimpleApplication app = new HelloAudio();
|
rlm@14
|
54 app.setTimer(new IsoTimer(60));
|
rlm@14
|
55 app.setShowSettings(false);
|
rlm@14
|
56
|
rlm@14
|
57 // you will not hear the audio while it is being captured.
|
rlm@14
|
58 Capture.captureAudio(app, audio);
|
rlm@14
|
59
|
rlm@14
|
60 app.start();
|
rlm@14
|
61 }
|
rlm@14
|
62
|
rlm@14
|
63 public static void basicAudioVideo() throws IOException{
|
rlm@14
|
64 File video = new File("/home/r/tmp/basicVideo.avi");
|
rlm@14
|
65 File audio = new File("/home/r/tmp/basicAudio.wav");
|
rlm@14
|
66
|
rlm@14
|
67 SimpleApplication app = new TestPostWater();
|
rlm@14
|
68 app.setTimer(new IsoTimer(60));
|
rlm@14
|
69 app.setShowSettings(false);
|
rlm@14
|
70
|
rlm@14
|
71 Capture.captureVideo(app, video);
|
rlm@14
|
72 Capture.captureAudio(app, audio);
|
rlm@14
|
73
|
rlm@14
|
74 app.start();
|
rlm@14
|
75 }
|
rlm@14
|
76
|
rlm@14
|
77
|
rlm@14
|
78 public static void main(String[] ignore) throws IOException{
|
rlm@14
|
79 basicVideo();
|
rlm@14
|
80 basicVideoGUI();
|
rlm@14
|
81 basicAudio();
|
rlm@14
|
82 basicAudioVideo();
|
rlm@14
|
83 }
|
rlm@14
|
84 }
|