SoundManager, SoundBuffer Fixed, BufferUtils.java rename to BufferUtilsEngine.java to avoid conflict with org.lwjgl.BufferUtils

Le son fonctionne yay
This commit is contained in:
Antoine
2021-05-31 18:45:38 +02:00
parent 00a19177c7
commit bd587a5587
9 changed files with 59 additions and 40 deletions

View File

@ -1,13 +1,16 @@
package engine.utils;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.channels.FileChannel;
public class BufferUtils {
public class BufferUtilsEngine {
private BufferUtils() {
private BufferUtilsEngine() {
}
@ -29,8 +32,4 @@ public class BufferUtils {
return result;
}
public static ByteBuffer StringToByteBuffer(String msg){
return ByteBuffer.wrap(msg.getBytes());
}
}

View File

@ -1,9 +1,13 @@
package engine.utils;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.lwjgl.BufferUtils;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class FileUtils {
@ -17,13 +21,27 @@ public class FileUtils {
BufferedReader reader = new BufferedReader(new FileReader(file));
String buffer = "";
while ((buffer = reader.readLine()) != null) {
result.append(buffer +"\n");
result.append(buffer).append("\n");
}
reader.close();
} catch (IOException e){
e.printStackTrace();
System.exit(1);
}
return result.toString();
}
public static ByteBuffer loadAsByteBuffer(String file) throws IOException{
ByteBuffer buffer;
Path path = Paths.get(file);
try (SeekableByteChannel fc = Files.newByteChannel(path)) {
buffer = BufferUtils.createByteBuffer((int) fc.size() + 1);
while (fc.read(buffer) != -1) ;
}
buffer.flip();
return buffer;
}
}