multiple order changes with notifiers and other method calls; added
copying of default music file to special directory;
This commit is contained in:
parent
56d0ac2f51
commit
324e3afe5a
@ -12,6 +12,7 @@ import org.jaudiotagger.audio.mp3.MP3AudioHeader;
|
||||
import org.jaudiotagger.audio.mp3.MP3File;
|
||||
import org.jaudiotagger.tag.TagException;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
public class MinimalAudioHeader {
|
||||
@ -19,7 +20,7 @@ public class MinimalAudioHeader {
|
||||
private SupportedFormats format;
|
||||
private FileHandle musicFile;
|
||||
public MinimalAudioHeader(FileHandle musicFile) {
|
||||
this.musicFile = musicFile;
|
||||
|
||||
format = SupportedFormats.valueOf(musicFile.extension().toUpperCase());
|
||||
try {
|
||||
AudioFile file = AudioFileIO.read(musicFile.file());
|
||||
|
@ -166,10 +166,11 @@ public class MusicController extends Observable implements OnCompletionListener,
|
||||
music.setOnCompletionListener(this);
|
||||
|
||||
setChanged();
|
||||
|
||||
notifyObservers(states.LOADED);
|
||||
if (autoPlay) {
|
||||
play();
|
||||
}
|
||||
notifyObservers(states.LOADED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@ package zero1hd.rhythmbullet.audio;
|
||||
|
||||
import java.util.Observable;
|
||||
|
||||
import javax.activity.InvalidActivityException;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@ -120,9 +118,16 @@ public class MusicList extends Observable {
|
||||
@Override
|
||||
public void run() {
|
||||
Array<FileHandle> obtainedAudioFiles = recursiveMusicSearch(directory);
|
||||
if (Gdx.files.external("RhythmBullet").exists()) {
|
||||
if (!Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3").exists()) {
|
||||
Gdx.files.internal("music/Alan Walker - Spectre.mp3").copyTo(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3"));
|
||||
}
|
||||
} else {
|
||||
Gdx.files.internal("music/Alan Walker - Spectre.mp3").copyTo(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3"));
|
||||
}
|
||||
if (work) {
|
||||
musicList = obtainedAudioFiles;
|
||||
musicList.add(Gdx.files.internal("music/Alan Walker - Spectre.mp3"));
|
||||
musicList.add(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3"));
|
||||
if (work) {
|
||||
searched = true;
|
||||
Gdx.app.debug("MusicList", "recursive async search completed.");
|
||||
|
@ -33,9 +33,9 @@ public class MusicSelectable extends Button {
|
||||
this.metadata = metadata;
|
||||
this.defaultAlbumArt = defaultAlbumArt;
|
||||
this.queueList = queueList;
|
||||
|
||||
album = new Image(defaultAlbumArt);
|
||||
add(album).expand().left();
|
||||
|
||||
informationTable = new Table();
|
||||
name = new ShortenedLabel(metadata.getTitle(), skin, "default-font", skin.getColor("default"));
|
||||
informationTable.add(name).colspan(2).expandX();
|
||||
|
@ -63,6 +63,7 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
|
||||
PCM[sid] = chanVal;
|
||||
}
|
||||
}
|
||||
System.out.println(PCM[0]);
|
||||
PCM[sid] /= Short.MAX_VALUE + 1f;
|
||||
}
|
||||
|
||||
@ -140,7 +141,7 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
|
||||
@Override
|
||||
public float[] getFrequencyBins() {
|
||||
if (updated) {
|
||||
synchronized (PCM) {
|
||||
synchronized (this) {
|
||||
fft.fft(PCM);
|
||||
System.arraycopy(PCM, 1, frequencyBins, 0, frequencyBins.length);
|
||||
}
|
||||
|
@ -268,11 +268,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (o == mc && arg.equals(mc.states.LOADED)) {
|
||||
if (selectables.getChecked().getFileHandle() != mc.getCurrentMusicFileHandle()) {
|
||||
selectables.setChecked(mc.getCurrentlyPlayingIndex());
|
||||
}
|
||||
} else if (o == mmc) {
|
||||
if (o == mmc) {
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user