completed proper save mechanism for custom metadata
This commit is contained in:
parent
466f1cfc3e
commit
02a65651ea
@ -22,7 +22,7 @@ public interface AudioMetadata extends Disposable {
|
||||
|
||||
public RhythmBulletMetadata getRBMetadata();
|
||||
|
||||
public void flushRBMetadata();
|
||||
public boolean flushRBMetadata();
|
||||
|
||||
@Override
|
||||
public void dispose();
|
||||
|
@ -11,6 +11,7 @@ import com.badlogic.gdx.utils.Json;
|
||||
import com.mpatric.mp3agic.ID3v1;
|
||||
import com.mpatric.mp3agic.InvalidDataException;
|
||||
import com.mpatric.mp3agic.Mp3File;
|
||||
import com.mpatric.mp3agic.NotSupportedException;
|
||||
import com.mpatric.mp3agic.UnsupportedTagException;
|
||||
|
||||
public class MP3Metadata implements AudioMetadata {
|
||||
@ -105,12 +106,21 @@ public class MP3Metadata implements AudioMetadata {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushRBMetadata() {
|
||||
public boolean flushRBMetadata() {
|
||||
try {
|
||||
Mp3File mp3file = new Mp3File(fileHandle.file());
|
||||
mp3file.setCustomTag(Base64Coder.encodeString(json.toJson(rbMetadata)).getBytes());
|
||||
} catch (UnsupportedTagException | InvalidDataException | IOException e) {
|
||||
String tempName = "." + fileHandle.name() + ".tmp";
|
||||
mp3file.save(tempName);
|
||||
String path = fileHandle.path();
|
||||
path.substring(0, path.length() - path.indexOf(tempName));
|
||||
path += tempName;
|
||||
fileHandle.delete();
|
||||
fileHandle = Gdx.files.absolute(path);
|
||||
return true;
|
||||
} catch (UnsupportedTagException | InvalidDataException | IOException | NotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ public class WAVMetadata implements AudioMetadata {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushRBMetadata() {
|
||||
public boolean flushRBMetadata() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user