continue problem fixing

This commit is contained in:
Harrison Deng 2017-05-22 23:17:32 -05:00
parent 0fff556332
commit 1e5a743739

View File

@ -44,28 +44,30 @@ public class MusicController extends Window {
togglePlay = new Image(skin.getDrawable("loading")) { togglePlay = new Image(skin.getDrawable("loading")) {
@Override @Override
public void act(float delta) { public void act(float delta) {
if (audiofile.getPlaybackMusic() != null) { // if (audiofile != null) {
if (audiofile.getPlaybackMusic().isPlaying()) { // if (audiofile.getPlaybackMusic().isPlaying()) {
setDrawable(skin.getDrawable("pause")); // setDrawable(skin.getDrawable("pause"));
} else if (!audiofile.getPlaybackMusic().isPlaying() && audiofile != null) { // } else if (!audiofile.getPlaybackMusic().isPlaying() && audiofile != null) {
setDrawable(skin.getDrawable("arrow")); // setDrawable(skin.getDrawable("arrow"));
} // }
} // }
super.act(delta); super.act(delta);
} }
}; };
togglePlay.addListener(new ClickListener() { togglePlay.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (audiofile.getPlaybackMusic() != null) { if (audiofile != null) {
if (audiofile.getPlaybackMusic().isPlaying()) { if (audiofile.getPlaybackMusic().isPlaying()) {
audiofile.getPlaybackMusic().pause(); audiofile.getPlaybackMusic().pause();
togglePlay.setDrawable(skin.getDrawable("arrow"));
} else { } else {
if (audiofile != null) { togglePlay.setDrawable(skin.getDrawable("pause"));
audiofile.getPlaybackMusic().play(); audiofile.getPlaybackMusic().play();
} }
} }
}
super.clicked(event, x, y); super.clicked(event, x, y);
} }
}); });
@ -75,7 +77,7 @@ public class MusicController extends Window {
fastForward.addListener(new ChangeListener() { fastForward.addListener(new ChangeListener() {
@Override @Override
public void changed(ChangeEvent event, Actor actor) { public void changed(ChangeEvent event, Actor actor) {
if (audiofile.getPlaybackMusic() != null) { if (audiofile != null) {
audiofile.getPlaybackMusic().play(); audiofile.getPlaybackMusic().play();
audiofile.getPlaybackMusic().setPosition(audiofile.getPlaybackMusic().getPosition() + 2); audiofile.getPlaybackMusic().setPosition(audiofile.getPlaybackMusic().getPosition() + 2);
info.setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec"); info.setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec");
@ -88,7 +90,7 @@ public class MusicController extends Window {
info = new TextField(null, skin) { info = new TextField(null, skin) {
@Override @Override
public void act(float delta) { public void act(float delta) {
if (audiofile.getPlaybackMusic() != null && audiofile.getPlaybackMusic().isPlaying()) { if (audiofile != null && audiofile.getPlaybackMusic().isPlaying()) {
setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec"); setText(String.valueOf(MathUtils.round(audiofile.getPlaybackMusic().getPosition())) + " sec");
} }
super.act(delta); super.act(delta);