Add in seeking

main
Joshua Sigona 3 years ago
parent e87126e851
commit f916963a84
  1. 5
      LLSIG/src/main/java/LLSIG/LLSIG.java
  2. 25
      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);
public boolean EDITMODE = false;
public boolean METRONOME = true;
public boolean METRONOME = false;
public boolean BPM_MEASURE = false;
public boolean PLAYING = true; //Whether or not a song is loaded and playing.
public static int beatNumber = 0;
@ -111,7 +111,7 @@ public class LLSIG implements KeyListener{
PLAYING = new File("music/"+song+".mp3").exists();
if (PLAYING) {
this.musicPlayer = new Player(Paths.get("music/"+song+".mp3").toUri().toString());
musicPlayer.play(148900l);
musicPlayer.play();
LoadSongData(song,lanes);
}
@ -263,6 +263,7 @@ public class LLSIG implements KeyListener{
testOffset=musicPlayer.getPlayPosition();
beatNumber=0;
}
musicPlayer.seek(148900);
}break;
case KeyEvent.VK_S:{lane=1;}break;
case KeyEvent.VK_D:{lane=2;}break;

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

Loading…
Cancel
Save