Add in seeking

main
Joshua Sigona 3 years ago
parent e87126e851
commit f916963a84
  1. 5
      LLSIG/src/main/java/LLSIG/LLSIG.java
  2. 17
      LLSIG/src/main/java/LLSIG/Player.java

@ -48,7 +48,7 @@ public class LLSIG implements KeyListener{
final static Dimension WINDOW_SIZE = new Dimension(1280,1050); final static Dimension WINDOW_SIZE = new Dimension(1280,1050);
public boolean EDITMODE = false; public boolean EDITMODE = false;
public boolean METRONOME = true; public boolean METRONOME = false;
public boolean BPM_MEASURE = false; public boolean BPM_MEASURE = false;
public boolean PLAYING = true; //Whether or not a song is loaded and playing. public boolean PLAYING = true; //Whether or not a song is loaded and playing.
public static int beatNumber = 0; public static int beatNumber = 0;
@ -111,7 +111,7 @@ public class LLSIG implements KeyListener{
PLAYING = new File("music/"+song+".mp3").exists(); PLAYING = new File("music/"+song+".mp3").exists();
if (PLAYING) { if (PLAYING) {
this.musicPlayer = new Player(Paths.get("music/"+song+".mp3").toUri().toString()); this.musicPlayer = new Player(Paths.get("music/"+song+".mp3").toUri().toString());
musicPlayer.play(148900l); musicPlayer.play();
LoadSongData(song,lanes); LoadSongData(song,lanes);
} }
@ -263,6 +263,7 @@ public class LLSIG implements KeyListener{
testOffset=musicPlayer.getPlayPosition(); testOffset=musicPlayer.getPlayPosition();
beatNumber=0; beatNumber=0;
} }
musicPlayer.seek(148900);
}break; }break;
case KeyEvent.VK_S:{lane=1;}break; case KeyEvent.VK_S:{lane=1;}break;
case KeyEvent.VK_D:{lane=2;}break; case KeyEvent.VK_D:{lane=2;}break;

@ -12,21 +12,17 @@ public class Player {
jlpp = new MediaPlayer(this.song); jlpp = new MediaPlayer(this.song);
} }
public void play() { public void play() {
new Thread() {
public void run() {
jlpp.stop(); jlpp.stop();
jlpp.play(); jlpp.play();
} }
}.start();
}
public void play(long frame) { public void play(long frame) {
new Thread() {
public void run() {
jlpp.stop();
jlpp.play(); jlpp.play();
jlpp.seek(new Duration(frame)); try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
} }
}.start(); this.seek(frame);
} }
public void pause() { public void pause() {
jlpp.pause(); jlpp.pause();
@ -47,4 +43,7 @@ public class Player {
public double getPlayPosition() { public double getPlayPosition() {
return jlpp.getCurrentTime().toMillis(); return jlpp.getCurrentTime().toMillis();
} }
public void seek(long frame) {
jlpp.seek(new Duration(frame));
}
} }

Loading…
Cancel
Save