SoundPool: explicitly extract soundfile asset

With the recent changes assets are no longer extracted by default
This commit is contained in:
Julian Winkler
2024-05-26 16:11:30 +02:00
parent 4374ac01ad
commit ff3c103377
2 changed files with 7 additions and 3 deletions

View File

@@ -610,7 +610,7 @@ public final class AssetManager {
return cookies;
}
private static void extractFromAPK(String path, String target) throws IOException {
public static void extractFromAPK(String path, String target) throws IOException {
if (path.endsWith("/")) { // directory
try (JarFile apk = new JarFile(Context.this_application.getPackageCodePath())) {
Enumeration<JarEntry> entries = apk.entries();

View File

@@ -1,6 +1,9 @@
package android.media;
import java.io.IOException;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
public class SoundPool {
@@ -21,8 +24,9 @@ public class SoundPool {
nativePool = native_constructor();
}
public int load(AssetFileDescriptor afd, int priority) {
return nativeLoad(nativePool, android.os.Environment.getExternalStorageDirectory().getPath() + afd.fileName);
public int load(AssetFileDescriptor afd, int priority) throws IOException {
AssetManager.extractFromAPK(afd.fileName, afd.fileName);
return nativeLoad(nativePool, android.os.Environment.getExternalStorageDirectory().getPath() + "/" + afd.fileName);
}
/**