arrow key music selection now functions
This commit is contained in:
parent
16992e1345
commit
30f7df2ad0
@ -5,8 +5,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
|
||||
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
|
||||
@ -135,11 +133,11 @@ public class Mp3Manager implements MusicManager {
|
||||
if (currentByteSet != null) {
|
||||
samples[sid] += (workset[1] << 8) + (workset[0] & 0x00ff);
|
||||
if (channels > 1) {
|
||||
samples[sid] += (workset[3] << 8) + (workset[2] & 0x00ff);
|
||||
samples[sid] /= 2;
|
||||
short altChan = (short) ((workset[3] << 8) + (workset[2] & 0x00ff));
|
||||
|
||||
samples[sid] = altChan > samples[sid] ? altChan : samples[sid];
|
||||
}
|
||||
framesRead ++;
|
||||
|
||||
samples[sid] /= Short.MAX_VALUE+1;
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,10 @@ public class WavDecoder {
|
||||
if (audioInputStream.read(buffer) > 0) {
|
||||
samples[sampleID] += (buffer[1] << 8) + (buffer[0] & 0x00ff);
|
||||
if (audioInputStream.getFormat().getChannels() > 1) {
|
||||
samples[sampleID] += (buffer[3] << 8) + (buffer[2] & 0x00ff);
|
||||
samples[sampleID] /= 2;
|
||||
short altChan = (short) ((buffer[3] << 8) + (buffer[2] & 0x00ff));
|
||||
samples[sampleID] = altChan > samples[sampleID] ? altChan : samples[sampleID];
|
||||
}
|
||||
framesRead ++;
|
||||
|
||||
samples[sampleID] /= Short.MAX_VALUE+1;
|
||||
}
|
||||
|
||||
|
@ -35,11 +35,12 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
|
||||
|
||||
private VerticalGroup vGroup;
|
||||
|
||||
private MusicSelectionPage msp;
|
||||
public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC, MusicSelectionPage msp) {
|
||||
table = new Table(skin);
|
||||
table.setBackground("holo-pane");
|
||||
vGroup = new VerticalGroup();
|
||||
|
||||
this.msp = msp;
|
||||
setName(musicFile.name());
|
||||
table.defaults().pad(10f);
|
||||
|
||||
@ -131,6 +132,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
|
||||
public void select() {
|
||||
table.setBackground("holo-pane-down");
|
||||
selected = true;
|
||||
msp.setCurrentlySelected(this);
|
||||
}
|
||||
|
||||
public void deselect() {
|
||||
|
@ -112,19 +112,20 @@ public class MusicSelectionPage extends Page {
|
||||
addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean keyDown(InputEvent event, int keycode) {
|
||||
Gdx.app.debug("MusicSelectionPage", "Scrolling");
|
||||
int index;
|
||||
if (keycode == Keys.DOWN) {
|
||||
if ((index = (songTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) {
|
||||
index = songTable.getChildren().size;
|
||||
if ((index = (songTable.getChildren().indexOf(currentlySelected, true) + 1)) == songTable.getChildren().size) {
|
||||
index = 0;
|
||||
}
|
||||
deselectAll();
|
||||
((MusicSelectable)songTable.getChildren().get(index)).select();
|
||||
scrollbar.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
|
||||
}
|
||||
if (keycode == Keys.UP) {
|
||||
if ((index = (songTable.getChildren().indexOf(currentlySelected, true) + 1)) < songTable.getChildren().size -1) {
|
||||
index = 0;
|
||||
if ((index = (songTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) {
|
||||
|
||||
index = songTable.getChildren().size-1;
|
||||
|
||||
}
|
||||
deselectAll();
|
||||
((MusicSelectable)songTable.getChildren().get(index)).select();
|
||||
|
Loading…
Reference in New Issue
Block a user