diff src/com/aurellem/capture/examples/Basic.java @ 14:e299cd89074d

creating Advanced Audio documentation.
author Robert McIntyre <rlm@mit.edu>
date Thu, 27 Oct 2011 21:55:51 -0700
parents
children be5ac56826be
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/com/aurellem/capture/examples/Basic.java	Thu Oct 27 21:55:51 2011 -0700
     1.3 @@ -0,0 +1,84 @@
     1.4 +package com.aurellem.capture.examples;
     1.5 +
     1.6 +import java.io.File;
     1.7 +import java.io.IOException;
     1.8 +
     1.9 +import jme3test.helloworld.HelloAudio;
    1.10 +import jme3test.helloworld.HelloJME3;
    1.11 +import jme3test.niftygui.TestNiftyExamples;
    1.12 +import jme3test.water.TestPostWater;
    1.13 +
    1.14 +import com.aurellem.capture.Capture;
    1.15 +import com.aurellem.capture.IsoTimer;
    1.16 +import com.jme3.app.SimpleApplication;
    1.17 +
    1.18 +
    1.19 +/**
    1.20 + * 
    1.21 + * Demonstrates how to use basic Audio/Video capture with a jMonkeyEngine 
    1.22 + * application. You can use these techniques to make high quality cutscenes
    1.23 + * or demo videos, even on very slow laptops.
    1.24 + * 
    1.25 + * @author Robert McIntyre
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +public class Basic {
    1.30 +	
    1.31 +	public static void basicVideo() throws IOException{
    1.32 +		File video = File.createTempFile("HelloJME3", ".avi");
    1.33 +		System.out.println("Saving video to: " + video.getCanonicalPath());
    1.34 +		SimpleApplication app = new HelloJME3();
    1.35 +		app.setTimer(new IsoTimer(60));
    1.36 +		app.setShowSettings(false);
    1.37 +		
    1.38 +		Capture.captureVideo(app, video);
    1.39 +		app.start();
    1.40 +	}
    1.41 +	
    1.42 +	public static void basicVideoGUI() throws IOException {
    1.43 +		File video = File.createTempFile("GUI", ".avi");
    1.44 +		System.out.println("Saving video to: " + video.getCanonicalPath());
    1.45 +		SimpleApplication app = new TestNiftyExamples();
    1.46 +		app.setTimer(new IsoTimer(60));
    1.47 +		app.setShowSettings(false);
    1.48 +		
    1.49 +		Capture.captureVideo(app, video);
    1.50 +		app.start();
    1.51 +	}
    1.52 +	
    1.53 +	public static void basicAudio() throws IOException{
    1.54 +		File audio = File.createTempFile("BasicAudio", ".wav");
    1.55 +		System.out.println("Saving audio to: " + audio.getCanonicalPath());
    1.56 +		SimpleApplication app = new HelloAudio();
    1.57 +		app.setTimer(new IsoTimer(60));
    1.58 +		app.setShowSettings(false);
    1.59 +		
    1.60 +		// you will not hear the audio while it is being captured.
    1.61 +		Capture.captureAudio(app, audio);
    1.62 +		
    1.63 +		app.start();
    1.64 +	}
    1.65 +	
    1.66 +	public static void basicAudioVideo() throws IOException{
    1.67 +		File video = new File("/home/r/tmp/basicVideo.avi");
    1.68 +		File audio = new File("/home/r/tmp/basicAudio.wav");
    1.69 +		
    1.70 +		SimpleApplication app = new TestPostWater();
    1.71 +		app.setTimer(new IsoTimer(60));
    1.72 +		app.setShowSettings(false);
    1.73 +		
    1.74 +		Capture.captureVideo(app, video);
    1.75 +		Capture.captureAudio(app, audio);
    1.76 +		
    1.77 +		app.start();
    1.78 +	}
    1.79 +	
    1.80 +	
    1.81 +	public static void main(String[] ignore) throws IOException{
    1.82 +		basicVideo();
    1.83 +		basicVideoGUI();
    1.84 +		basicAudio();
    1.85 +		basicAudioVideo();
    1.86 +	}
    1.87 +}