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