added Youtube download, Video conversion and caching, tweaked some settings
This commit is contained in:
parent
b44363990d
commit
f9e5988dca
Binary file not shown.
BIN
ShootingStars/lib/commons-codec-1.4.jar
Normal file
BIN
ShootingStars/lib/commons-codec-1.4.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/commons-io-2.1.jar
Normal file
BIN
ShootingStars/lib/commons-io-2.1.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/commons-lang3-3.1.jar
Normal file
BIN
ShootingStars/lib/commons-lang3-3.1.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/commons-logging-1.1.1.jar
Normal file
BIN
ShootingStars/lib/commons-logging-1.1.1.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/httpclient-4.1.3.jar
Normal file
BIN
ShootingStars/lib/httpclient-4.1.3.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/httpcore-4.1.4.jar
Normal file
BIN
ShootingStars/lib/httpcore-4.1.4.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/jogg-0.0.7.jar
Normal file
BIN
ShootingStars/lib/jogg-0.0.7.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/jorbis-0.0.15.jar
Normal file
BIN
ShootingStars/lib/jorbis-0.0.15.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/tritonus_jorbis-0.3.6.jar
Normal file
BIN
ShootingStars/lib/tritonus_jorbis-0.3.6.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/vget-1.1.0.jar
Normal file
BIN
ShootingStars/lib/vget-1.1.0.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/wget-1.2.7.jar
Normal file
BIN
ShootingStars/lib/wget-1.2.7.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/xmlpull-1.1.3.1.jar
Normal file
BIN
ShootingStars/lib/xmlpull-1.1.3.1.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/xpp3_min-1.1.4c.jar
Normal file
BIN
ShootingStars/lib/xpp3_min-1.1.4c.jar
Normal file
Binary file not shown.
BIN
ShootingStars/lib/xstream-1.4.2.jar
Normal file
BIN
ShootingStars/lib/xstream-1.4.2.jar
Normal file
Binary file not shown.
@ -32,14 +32,28 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.AudioProcessing-1.0.jar=lib\\AudioProcessing-1.0.jar
|
||||
file.reference.commons-codec-1.4.jar=lib\\commons-codec-1.4.jar
|
||||
file.reference.commons-io-2.1.jar=lib\\commons-io-2.1.jar
|
||||
file.reference.commons-lang3-3.1.jar=lib\\commons-lang3-3.1.jar
|
||||
file.reference.commons-logging-1.1.1.jar=lib\\commons-logging-1.1.1.jar
|
||||
file.reference.httpclient-4.1.3.jar=lib\\httpclient-4.1.3.jar
|
||||
file.reference.httpcore-4.1.4.jar=lib\\httpcore-4.1.4.jar
|
||||
file.reference.jaudiotagger-2.2.0.jar=lib\\jaudiotagger-2.2.0.jar
|
||||
file.reference.jl1.0.1.jar=lib\\jl1.0.1.jar
|
||||
file.reference.jna-3.5.2.jar=lib\\jna-3.5.2.jar
|
||||
file.reference.jogg-0.0.7.jar=lib\\jogg-0.0.7.jar
|
||||
file.reference.jorbis-0.0.15.jar=lib\\jorbis-0.0.15.jar
|
||||
file.reference.mp3spi1.9.5.jar=lib\\mp3spi1.9.5.jar
|
||||
file.reference.platform-3.5.2.jar=lib\\platform-3.5.2.jar
|
||||
file.reference.tritonus_aos-0.3.6.jar=lib\\tritonus_aos-0.3.6.jar
|
||||
file.reference.tritonus_jorbis-0.3.6.jar=lib\\tritonus_jorbis-0.3.6.jar
|
||||
file.reference.tritonus_share-0.3.6.jar=lib\\tritonus_share-0.3.6.jar
|
||||
file.reference.vget-1.1.0.jar=lib\\vget-1.1.0.jar
|
||||
file.reference.vlcj-2.3.0.jar=lib\\vlcj-2.3.0.jar
|
||||
file.reference.wget-1.2.7.jar=lib\\wget-1.2.7.jar
|
||||
file.reference.xmlpull-1.1.3.1.jar=lib\\xmlpull-1.1.3.1.jar
|
||||
file.reference.xpp3_min-1.1.4c.jar=lib\\xpp3_min-1.1.4c.jar
|
||||
file.reference.xstream-1.4.2.jar=lib\\xstream-1.4.2.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
@ -57,7 +71,21 @@ javac.classpath=\
|
||||
${file.reference.tritonus_share-0.3.6.jar}:\
|
||||
${file.reference.AudioProcessing-1.0.jar}:\
|
||||
${libs.jme3-libraries-effects.classpath}:\
|
||||
${file.reference.jaudiotagger-2.2.0.jar}
|
||||
${file.reference.jaudiotagger-2.2.0.jar}:\
|
||||
${file.reference.commons-codec-1.4.jar}:\
|
||||
${file.reference.commons-io-2.1.jar}:\
|
||||
${file.reference.commons-lang3-3.1.jar}:\
|
||||
${file.reference.commons-logging-1.1.1.jar}:\
|
||||
${file.reference.httpclient-4.1.3.jar}:\
|
||||
${file.reference.httpcore-4.1.4.jar}:\
|
||||
${file.reference.jogg-0.0.7.jar}:\
|
||||
${file.reference.jorbis-0.0.15.jar}:\
|
||||
${file.reference.tritonus_jorbis-0.3.6.jar}:\
|
||||
${file.reference.vget-1.1.0.jar}:\
|
||||
${file.reference.wget-1.2.7.jar}:\
|
||||
${file.reference.xmlpull-1.1.3.1.jar}:\
|
||||
${file.reference.xpp3_min-1.1.4c.jar}:\
|
||||
${file.reference.xstream-1.4.2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#jME3 AppSettings
|
||||
#Fri Jun 14 08:27:23 CEST 2013
|
||||
#Fri Jun 14 11:11:30 CEST 2013
|
||||
Renderer(string)=LWJGL-OpenGL2
|
||||
Width(int)=1360
|
||||
Width(int)=1366
|
||||
DisableJoysticks(bool)=true
|
||||
SettingsDialogImage(string)=
|
||||
Title(string)=Shooting Stars
|
||||
@ -12,13 +12,13 @@ Samples(int)=0
|
||||
UseInput(bool)=true
|
||||
BitsPerPixel(int)=24
|
||||
Frequency(int)=60
|
||||
Username(string)=Chris
|
||||
Username(string)=Darth Affe
|
||||
DepthBits(int)=32
|
||||
FXVolume(int)=85
|
||||
Fullscreen(bool)=false
|
||||
AudioRenderer(string)=LWJGL
|
||||
StencilBits(int)=0
|
||||
PostProcessing(bool)=false
|
||||
PostProcessing(bool)=true
|
||||
VSync(bool)=true
|
||||
FrameRate(int)=-1
|
||||
SoundVolume(int)=24
|
||||
|
||||
@ -29,7 +29,7 @@ import com.jme3.renderer.Camera;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.Node;
|
||||
import org.wyrez.persij.PersiJContainer;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.game.GameSettings;
|
||||
import org.wyrez.shootingstars.states.GameState;
|
||||
@ -46,14 +46,11 @@ public class ShootingStars extends SimpleApplication {
|
||||
|
||||
private PersiJContainer container;
|
||||
private StateManager sManager;
|
||||
private Screen screen;
|
||||
private OptionSettings optionSettings;
|
||||
private GameSettings gameSettings;
|
||||
|
||||
public ShootingStars() {
|
||||
super(new StatsAppState(), new DebugKeysAppState());
|
||||
optionSettings = new OptionSettings();
|
||||
gameSettings = new GameSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,21 +85,21 @@ public class ShootingStars extends SimpleApplication {
|
||||
container.registerSingleton(AssetManager.class, assetManager);
|
||||
container.registerSingleton(ViewPort.class, viewPort);
|
||||
container.registerSingleton(OptionSettings.class, optionSettings);
|
||||
container.registerSingleton(GameSettings.class, gameSettings);
|
||||
container.registerType(GameSettings.class, true);
|
||||
container.registerType(StateManager.class, true);
|
||||
container.registerType(Screen.class, true);
|
||||
container.registerType(AudioDataManager.class, true);
|
||||
container.registerType(AudioDataManager.class, true);
|
||||
}
|
||||
|
||||
|
||||
private void initKeys() {
|
||||
inputManager.addMapping("Pause", new KeyTrigger(KeyInput.KEY_P));
|
||||
inputManager.addMapping("Pause", new KeyTrigger(KeyInput.KEY_P));
|
||||
inputManager.deleteMapping(INPUT_MAPPING_EXIT);
|
||||
inputManager.addMapping("ESC", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||
|
||||
inputManager.addMapping("ESC", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initSettings() {
|
||||
if(optionSettings.saveExists()) {
|
||||
if (optionSettings.saveExists()) {
|
||||
optionSettings.init(false);
|
||||
optionSettings.load();
|
||||
} else {
|
||||
@ -115,7 +112,7 @@ public class ShootingStars extends SimpleApplication {
|
||||
ShootingStars app = new ShootingStars();
|
||||
|
||||
//app.setSettings(optionSettings);
|
||||
|
||||
|
||||
app.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -22,7 +22,7 @@ import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import java.util.Random;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -20,7 +20,7 @@ import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import java.util.Random;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -19,7 +19,7 @@ package org.wyrez.shootingstars.controls;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.helper.MathHelper;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.audiodata;
|
||||
package org.wyrez.shootingstars.data;
|
||||
|
||||
import org.wyrez.audio.AudioProcessor;
|
||||
import org.wyrez.audio.decoder.DecoderFactory;
|
||||
@ -22,7 +22,6 @@ import org.wyrez.audio.util.Band;
|
||||
import org.wyrez.audio.util.SampleBuffer;
|
||||
import org.wyrez.audio.util.SampleHelper;
|
||||
import org.wyrez.shootingstars.game.GameSettings;
|
||||
import org.wyrez.shootingstars.states.GameState;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
|
||||
/**
|
||||
@ -34,7 +33,7 @@ public class AudioDataManager {
|
||||
private static final int MIN_PEAK_DIFF = 13; //~198.8bpm
|
||||
private static final Band LOW_BAND = new Band(1f, 140);
|
||||
private static final Band MID_BAND = new Band(400f, 1200f);
|
||||
private static final Band HIGH_BAND = new Band(4000f, 16000f);
|
||||
private static final Band HIGH_BAND = new Band(2000f, 16000f);
|
||||
/**/
|
||||
private AudioProcessor audioProcessorLowBand;
|
||||
private AudioProcessor audioProcessorMidBand;
|
||||
@ -0,0 +1,77 @@
|
||||
package org.wyrez.shootingstars.data;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class OggConverter {
|
||||
|
||||
private CountDownLatch completionLatch;
|
||||
private final MediaPlayerFactory mediaPlayerFactory;
|
||||
private final MediaPlayer mediaPlayer;
|
||||
private boolean success = false;
|
||||
|
||||
public OggConverter() {
|
||||
mediaPlayerFactory = new MediaPlayerFactory();
|
||||
mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
|
||||
mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
|
||||
@Override
|
||||
public void finished(MediaPlayer mediaPlayer) {
|
||||
System.out.println("Rip completed successfully");
|
||||
success = true;
|
||||
completionLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(MediaPlayer mediaPlayer) {
|
||||
System.out.println("Rip failed");
|
||||
success = false;
|
||||
completionLatch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void convert(String in, String out, int bitrate) throws Exception {
|
||||
System.out.println("Convert '" + in + "' to '" + out + "'...");
|
||||
completionLatch = new CountDownLatch(1);
|
||||
mediaPlayer.playMedia(in, String.format(
|
||||
"sout=#transcode{acodec=vorb,channels=2,ab=%d,samplerate=44100,vcodec=dummy}:standard{dst=%s,mux=ogg,access=file}",
|
||||
bitrate, out));
|
||||
|
||||
try {
|
||||
completionLatch.await();
|
||||
if (!success) {
|
||||
throw new Exception("failed conversion...");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("failed...");
|
||||
throw new Exception("failed conversion...");
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
mediaPlayer.release();
|
||||
mediaPlayerFactory.release();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package org.wyrez.shootingstars.data;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import com.github.axet.vget.VGet;
|
||||
import com.github.axet.vget.info.VideoInfo;
|
||||
import com.github.axet.vget.info.VideoInfo.VideoQuality;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class YTDownloader {
|
||||
|
||||
private File lastTarget;
|
||||
|
||||
public YTDownloader() {
|
||||
}
|
||||
|
||||
public boolean download(String source, String targetFolder) {
|
||||
System.out.println("downloading " + source);
|
||||
boolean first = true;
|
||||
boolean process = true;
|
||||
VideoInfo info = null;
|
||||
|
||||
while (process) {
|
||||
try {
|
||||
if (first) {
|
||||
info = new VideoInfo(new URL(source));
|
||||
info.setUserQuality(VideoQuality.p720);
|
||||
info.setVideoQuality(VideoQuality.p720);
|
||||
}
|
||||
VGet v = new VGet(info, new File(targetFolder));
|
||||
v.download();
|
||||
lastTarget = v.getTarget();
|
||||
System.out.println("success!");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
if (first && info != null) {
|
||||
System.out.println("failed... retry with other quality");
|
||||
info.setUserQuality(null);
|
||||
info.setVideoQuality(null);
|
||||
first = false;
|
||||
} else {
|
||||
process = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public File getLastTarget() {
|
||||
return lastTarget;
|
||||
}
|
||||
}
|
||||
@ -35,21 +35,13 @@ public class GameSettings {
|
||||
private boolean useVideo;
|
||||
|
||||
public GameSettings() {
|
||||
// this.audioFile = audioFile;
|
||||
// if (videoFile == null) {
|
||||
// videoFile = audioFile;
|
||||
// useVideo = false;
|
||||
// } else {
|
||||
// this.videoFile = videoFile;
|
||||
// useVideo = true;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public void setAudioFile(String audioFile) {
|
||||
this.audioFile = audioFile;
|
||||
this.useVideo = false;
|
||||
}
|
||||
|
||||
|
||||
public void setVideoFile(String videoFile) {
|
||||
this.videoFile = videoFile;
|
||||
this.useVideo = true;
|
||||
@ -62,8 +54,8 @@ public class GameSettings {
|
||||
public String getVideoFile() {
|
||||
return videoFile;
|
||||
}
|
||||
|
||||
public boolean useVideo(){
|
||||
|
||||
public boolean useVideo() {
|
||||
return useVideo;
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.controls.GroundGlowControl;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.mesh.HexPrism;
|
||||
|
||||
@ -22,7 +22,7 @@ import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.controls.GroundBorderGlowControl;
|
||||
import org.wyrez.shootingstars.controls.GroundGlowControl;
|
||||
import org.wyrez.shootingstars.controls.GroundMoveControl;
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.helper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class ChecksumHelper {
|
||||
|
||||
public static String createMD5(String path) throws Exception {
|
||||
return DigestUtils.md5Hex(new FileInputStream(new File(path)));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.helper;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class PathHelper {
|
||||
|
||||
private static final String CACHE_FOLDER = "cache/";
|
||||
|
||||
public static String getCacheFolder() {
|
||||
File file = new File(CACHE_FOLDER);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
return CACHE_FOLDER;
|
||||
}
|
||||
|
||||
public static String replaceFileEnding(String path, String newEnding) {
|
||||
return path.substring(0, path.lastIndexOf(".") + 1) + newEnding;
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.wyrez.shootingstars.states;
|
||||
|
||||
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.asset.AssetManager;
|
||||
@ -32,7 +31,7 @@ import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.controls.PlayerCamControl;
|
||||
import org.wyrez.shootingstars.controls.PlayerMouseControl;
|
||||
import org.wyrez.shootingstars.controls.PlayerMoveControl;
|
||||
@ -70,7 +69,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
private Spatial player;
|
||||
private boolean isRunning = false;
|
||||
|
||||
|
||||
public GameState(Node rootNode, Screen screen, StateManager stateManager,
|
||||
AssetManager assetManager, ViewPort viewPort,
|
||||
InputManager inputManager, Camera camera, AudioDataManager audioDataManager, GameSettings settings) {
|
||||
@ -102,16 +100,11 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
viewPort.addProcessor(fpp);
|
||||
}
|
||||
|
||||
public boolean initMediaPlayer() {
|
||||
try {
|
||||
mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(settings.getVideoFormat(),
|
||||
settings.getVideoWidth(), settings.getVideoHeight(),
|
||||
settings.getVideoWidth() * settings.getVideoDepth(), cinema);
|
||||
mediaPlayer.prepareMedia(settings.getVideoFile());
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
public void initMediaPlayer() throws Exception {
|
||||
mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(settings.getVideoFormat(),
|
||||
settings.getVideoWidth(), settings.getVideoHeight(),
|
||||
settings.getVideoWidth() * settings.getVideoDepth(), cinema);
|
||||
mediaPlayer.prepareMedia(settings.getVideoFile());
|
||||
}
|
||||
|
||||
public void loadCinema() {
|
||||
@ -189,7 +182,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
|
||||
public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if (name.equals("ESC") && !isPressed) {
|
||||
gui.showMenu();
|
||||
|
||||
@ -18,8 +18,13 @@ package org.wyrez.shootingstars.states;
|
||||
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import org.wyrez.shootingstars.audiodata.AudioDataManager;
|
||||
import java.io.File;
|
||||
import org.wyrez.shootingstars.data.AudioDataManager;
|
||||
import org.wyrez.shootingstars.data.OggConverter;
|
||||
import org.wyrez.shootingstars.game.GameSettings;
|
||||
import org.wyrez.shootingstars.gui.LoadingGui;
|
||||
import org.wyrez.shootingstars.helper.ChecksumHelper;
|
||||
import org.wyrez.shootingstars.helper.PathHelper;
|
||||
import org.wyrez.shootingstars.states.util.LoadingProgress;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
@ -33,12 +38,14 @@ public class LoadingState extends AbstractAppState {
|
||||
private LoadingGui gui;
|
||||
private AudioDataManager audioDataManager;
|
||||
private LoadingProgress currentProgress;
|
||||
private GameSettings settings;
|
||||
|
||||
public LoadingState(Screen screen, StateManager stateManager,
|
||||
AudioDataManager audioDataManager) {
|
||||
AudioDataManager audioDataManager, GameSettings settings) {
|
||||
this.stateManager = stateManager;
|
||||
this.gui = new LoadingGui(screen);
|
||||
this.audioDataManager = audioDataManager;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,52 +61,73 @@ public class LoadingState extends AbstractAppState {
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
switch (currentProgress) {
|
||||
case START:
|
||||
currentProgress = LoadingProgress.LOADING_CINEMA;
|
||||
break;
|
||||
case LOADING_CINEMA:
|
||||
loadingCinema();
|
||||
currentProgress = LoadingProgress.INIT_AUDIO_PLAYER;
|
||||
break;
|
||||
case INIT_AUDIO_PLAYER:
|
||||
initAudioPlayer();
|
||||
currentProgress = LoadingProgress.INIT_AUDIO_ANALYSIS;
|
||||
break;
|
||||
case INIT_AUDIO_ANALYSIS:
|
||||
initAudioAnalysis();
|
||||
currentProgress = LoadingProgress.ANALYSE_LOW_BAND;
|
||||
break;
|
||||
case ANALYSE_LOW_BAND:
|
||||
analyseLowBand();
|
||||
currentProgress = LoadingProgress.ANALYSE_MID_BAND;
|
||||
break;
|
||||
case ANALYSE_MID_BAND:
|
||||
analyseMidBand();
|
||||
currentProgress = LoadingProgress.ANALYSE_HIGH_BAND;
|
||||
break;
|
||||
case ANALYSE_HIGH_BAND:
|
||||
analyseHighBand();
|
||||
currentProgress = LoadingProgress.GENERATING_SCENE;
|
||||
break;
|
||||
case GENERATING_SCENE:
|
||||
generateScene();
|
||||
currentProgress = LoadingProgress.LOADING_PLAYER;
|
||||
break;
|
||||
case LOADING_PLAYER:
|
||||
loadPlayer();
|
||||
currentProgress = LoadingProgress.DONE;
|
||||
break;
|
||||
case DONE:
|
||||
done();
|
||||
break;
|
||||
try {
|
||||
switch (currentProgress) {
|
||||
case START:
|
||||
currentProgress = LoadingProgress.LOADING_CINEMA;
|
||||
break;
|
||||
case LOADING_CINEMA:
|
||||
loadingCinema();
|
||||
currentProgress = LoadingProgress.INIT_AUDIO_PLAYER;
|
||||
break;
|
||||
case INIT_AUDIO_PLAYER:
|
||||
initAudioPlayer();
|
||||
currentProgress = LoadingProgress.INIT_AUDIO_ANALYSIS;
|
||||
break;
|
||||
case INIT_AUDIO_ANALYSIS:
|
||||
if (initAudioAnalysis()) {
|
||||
currentProgress = LoadingProgress.ANALYSE_LOW_BAND;
|
||||
} else {
|
||||
currentProgress = LoadingProgress.CONVERT_AUDIO;
|
||||
}
|
||||
break;
|
||||
case CONVERT_AUDIO:
|
||||
convertAudio();
|
||||
currentProgress = LoadingProgress.INIT_AUDIO_ANALYSIS;
|
||||
break;
|
||||
case ANALYSE_LOW_BAND:
|
||||
analyseLowBand();
|
||||
currentProgress = LoadingProgress.ANALYSE_MID_BAND;
|
||||
break;
|
||||
case ANALYSE_MID_BAND:
|
||||
analyseMidBand();
|
||||
currentProgress = LoadingProgress.ANALYSE_HIGH_BAND;
|
||||
break;
|
||||
case ANALYSE_HIGH_BAND:
|
||||
analyseHighBand();
|
||||
currentProgress = LoadingProgress.GENERATING_SCENE;
|
||||
break;
|
||||
case GENERATING_SCENE:
|
||||
generateScene();
|
||||
currentProgress = LoadingProgress.LOADING_PLAYER;
|
||||
break;
|
||||
case LOADING_PLAYER:
|
||||
loadPlayer();
|
||||
currentProgress = LoadingProgress.DONE;
|
||||
break;
|
||||
case DONE:
|
||||
done();
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
stateManager.setState(State.MENU);
|
||||
}
|
||||
gui.updateProgress(currentProgress);
|
||||
}
|
||||
|
||||
private void initAudioAnalysis() {
|
||||
private boolean initAudioAnalysis() {
|
||||
GameState gs = stateManager.getState(State.GAME);
|
||||
audioDataManager.initialize(gs.getSettings(), gs.getMediaPlayer()); //TODO path
|
||||
return audioDataManager.initialize(gs.getSettings(), gs.getMediaPlayer());
|
||||
}
|
||||
|
||||
private void convertAudio() throws Exception {
|
||||
String sourceChecksum = ChecksumHelper.createMD5(settings.getVideoFile());
|
||||
String audioPath = PathHelper.getCacheFolder() + sourceChecksum + ".ogg";
|
||||
if (!new File(audioPath).exists()) {
|
||||
new OggConverter().convert(settings.getVideoFile(), audioPath, 192);
|
||||
}
|
||||
settings.setAudioFile(audioPath);
|
||||
}
|
||||
|
||||
private void analyseLowBand() {
|
||||
@ -114,7 +142,7 @@ public class LoadingState extends AbstractAppState {
|
||||
audioDataManager.analyseHighBand();
|
||||
}
|
||||
|
||||
private void initAudioPlayer() {
|
||||
private void initAudioPlayer() throws Exception {
|
||||
GameState gs = stateManager.getState(State.GAME);
|
||||
gs.initMediaPlayer();
|
||||
}
|
||||
|
||||
@ -29,20 +29,20 @@ import tonegod.gui.core.Screen;
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class SelectTrackState extends AbstractAppState implements SelectFileListener{
|
||||
public class SelectTrackState extends AbstractAppState implements SelectFileListener {
|
||||
|
||||
private StateManager stateManager;
|
||||
private GameSettings settings;
|
||||
private SelectTrackGUI gui;
|
||||
|
||||
|
||||
public SelectTrackState(Screen screen, StateManager stateManager, GameSettings settings) {
|
||||
this.stateManager = stateManager;
|
||||
this.settings = settings;
|
||||
this.gui = new SelectTrackGUI(screen, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
gui.attach();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList
|
||||
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = jFileChooser.getSelectedFile();
|
||||
settings.setAudioFile(file.getAbsolutePath());
|
||||
settings.setVideoFile(file.getPath());
|
||||
stateManager.setState(State.FILEMETAINFO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,43 +18,45 @@ package org.wyrez.shootingstars.states;
|
||||
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import org.wyrez.shootingstars.data.YTDownloader;
|
||||
import org.wyrez.shootingstars.game.GameSettings;
|
||||
import org.wyrez.shootingstars.gui.YTDownloadGUI;
|
||||
import org.wyrez.shootingstars.gui.listener.YTDownloadListener;
|
||||
import org.wyrez.shootingstars.helper.PathHelper;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class YTDownloadState extends AbstractAppState implements YTDownloadListener{
|
||||
|
||||
public class YTDownloadState extends AbstractAppState implements YTDownloadListener {
|
||||
|
||||
private StateManager stateManager;
|
||||
private GameSettings settings;
|
||||
private YTDownloadGUI gui;
|
||||
private YTDownloader downloader;
|
||||
|
||||
|
||||
public YTDownloadState(Screen screen, StateManager stateManager, GameSettings settings) {
|
||||
public YTDownloadState(Screen screen, StateManager stateManager,
|
||||
GameSettings settings, YTDownloader downloader) {
|
||||
this.stateManager = stateManager;
|
||||
this.settings = settings;
|
||||
this.gui = new YTDownloadGUI(screen, this);
|
||||
this.downloader = downloader;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
gui.attach();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stateDetached(AppStateManager stateManager) {
|
||||
gui.detach();
|
||||
}
|
||||
|
||||
public void downloadYTVideo(String url) {
|
||||
//TODO: Download Video
|
||||
System.out.println(url);
|
||||
downloader.download(url, PathHelper.getCacheFolder());
|
||||
settings.setVideoFile(downloader.getLastTarget().getPath());
|
||||
stateManager.setState(State.FILEMETAINFO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ public enum LoadingProgress {
|
||||
LOADING_CINEMA("Loading Cinema", 1),
|
||||
INIT_AUDIO_PLAYER("Loading Audio-Player...", 2),
|
||||
INIT_AUDIO_ANALYSIS("Creating Samples...", 3),
|
||||
CONVERT_AUDIO("Converting...", 3),
|
||||
ANALYSE_LOW_BAND("Analyse Low-Band...", 4),
|
||||
ANALYSE_MID_BAND("Analyse Mid-Band...", 5),
|
||||
ANALYSE_HIGH_BAND("Analyse High-Band...", 6),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user