mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2026-08-01 14:19:12 -06:00
Audio via OpenAL demo
This commit is contained in:
parent
d5f9db0446
commit
f88f0052c5
4 changed files with 31 additions and 37 deletions
|
|
@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.AsyncPlayer;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.os.Vibrator;
|
||||
|
|
@ -27,8 +29,6 @@ import static net.kdt.pojavlaunch.utils.MathUtils.map;
|
|||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.kdt.LoggerView;
|
||||
|
||||
public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouchListener {
|
||||
|
||||
private AWTCanvasView mTextureView;
|
||||
|
|
@ -220,10 +220,9 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
|||
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
||||
|
||||
|
||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.test);
|
||||
final File miniclient = new File(getCacheDir(), getFileName(this, uri));
|
||||
final File config = new File(getFilesDir(), "config.json");
|
||||
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||
final File config = new File(getFilesDir(), "test2.ogg");
|
||||
|
||||
mTextureView = findViewById(R.id.installmod_surfaceview);
|
||||
mTextureView.setOnTouchListener((v, event) -> {
|
||||
|
|
@ -248,7 +247,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
|||
});
|
||||
new Thread(() -> {
|
||||
try {
|
||||
launchJavaRuntime(miniclient, javaArgs, config);
|
||||
launchJavaRuntime(miniclient, null, config);
|
||||
} catch (Throwable e) {
|
||||
Tools.showError(JavaGUILauncherActivity.this, e);
|
||||
}
|
||||
|
|
@ -340,6 +339,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
|||
}
|
||||
|
||||
public int launchJavaRuntime(File miniclient, String javaArgs,File config) {
|
||||
|
||||
JREUtils.redirectAndPrintJRELog(this);
|
||||
|
||||
// Load saved username and password
|
||||
|
|
@ -349,7 +349,12 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
|||
|
||||
try {
|
||||
JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties();
|
||||
|
||||
|
||||
// Background Music
|
||||
//Uri t = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.t1);
|
||||
//AsyncPlayer ap=new AsyncPlayer("Background-Music");
|
||||
//ap.play(this, t, false, AudioManager.STREAM_MUSIC);
|
||||
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
|
||||
// Enable Caciocavallo
|
||||
|
|
|
|||
|
|
@ -43,13 +43,10 @@ import java.io.InputStream;
|
|||
public class PojavLoginActivity extends BaseActivity {
|
||||
private final Object mLockStoragePerm = new Object();
|
||||
private final Object mLockSelectJRE = new Object();
|
||||
|
||||
private EditText edit2, edit3;
|
||||
|
||||
private final int REQUEST_STORAGE_REQUEST_CODE = 1;
|
||||
private CheckBox sRemember, sOffline;
|
||||
private TextView startupTextView;
|
||||
private SharedPreferences firstLaunchPrefs;
|
||||
|
||||
|
||||
private boolean isSkipInit = false;
|
||||
private boolean isStarting = false;
|
||||
|
||||
|
|
@ -63,7 +60,7 @@ public class PojavLoginActivity extends BaseActivity {
|
|||
isSkipInit = savedInstanceState.getBoolean("isSkipInit");
|
||||
}
|
||||
Tools.updateWindowSize(this);
|
||||
firstLaunchPrefs = getSharedPreferences("pojav_extract", MODE_PRIVATE);
|
||||
SharedPreferences firstLaunchPrefs = getSharedPreferences("pojav_extract", MODE_PRIVATE);
|
||||
new Thread(new InitRunnable()).start();
|
||||
// If we get here that's because the client was closed.
|
||||
// having this here causes the app to close its activity when installing jdk.
|
||||
|
|
@ -145,21 +142,11 @@ public class PojavLoginActivity extends BaseActivity {
|
|||
}
|
||||
private void uiInit() {
|
||||
setContentView(R.layout.launcher_main_v4);
|
||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||
Thread t = new Thread(()->{
|
||||
try {
|
||||
final File miniclient = new File(getCacheDir(), getFileName(this, uri));
|
||||
FileOutputStream fos = new FileOutputStream(miniclient);
|
||||
IOUtils.copy(getContentResolver().openInputStream(uri), fos);
|
||||
fos.close();
|
||||
PojavLoginActivity.this.runOnUiThread(() -> {
|
||||
Intent intent = new Intent(PojavLoginActivity.this, JavaGUILauncherActivity.class);
|
||||
intent.putExtra("miniclient", miniclient);
|
||||
startActivity(intent);
|
||||
});
|
||||
}catch(IOException e) {
|
||||
//Tools.showError(PojavLoginActivity.this,e);
|
||||
}
|
||||
PojavLoginActivity.this.runOnUiThread(() -> {
|
||||
Intent intent = new Intent(PojavLoginActivity.this, JavaGUILauncherActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
|
@ -211,12 +198,16 @@ public class PojavLoginActivity extends BaseActivity {
|
|||
mkdirs(Tools.DIR_GAME_HOME + "/config");
|
||||
mkdirs(Tools.CTRLMAP_PATH);
|
||||
try {
|
||||
// Copy miniclient to storage
|
||||
Uri rawMiniclient = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.test);
|
||||
final File miniclient = new File(getCacheDir(), getFileName(this, rawMiniclient));
|
||||
FileOutputStream fos = new FileOutputStream(miniclient);
|
||||
IOUtils.copy(getContentResolver().openInputStream(rawMiniclient), fos);
|
||||
fos.close();
|
||||
|
||||
Tools.copyAssetFile(this, "components/security/pro-grade.jar", Tools.DIR_DATA, true);
|
||||
Tools.copyAssetFile(this, "components/security/java_sandbox.policy", Tools.DIR_DATA, true);
|
||||
Tools.copyAssetFile(this, "options.txt", Tools.DIR_GAME_NEW, false);
|
||||
// TODO: Remove after implement.
|
||||
Tools.copyAssetFile(this, "launcher_profiles.json", Tools.DIR_GAME_NEW, false);
|
||||
Tools.copyAssetFile(this,"resolv.conf",Tools.DIR_DATA, true);
|
||||
|
||||
AssetManager am = this.getAssets();
|
||||
|
||||
unpackComponent(am, "caciocavallo");
|
||||
|
|
@ -249,12 +240,12 @@ public class PojavLoginActivity extends BaseActivity {
|
|||
(resid, vararg) -> runOnUiThread(()->{if(startupTextView!=null)startupTextView.setText(getString(resid,vararg));}));
|
||||
MultiRTUtils.postPrepare(PojavLoginActivity.this,"Internal");
|
||||
|
||||
// Copy config.json to writable storage
|
||||
// Copy miniclient config.json to writable storage
|
||||
// https://stackoverflow.com/questions/38590996/copy-xml-from-raw-folder-to-internal-storage-and-use-it-in-android
|
||||
File file = new File(getFilesDir(), "config.json");
|
||||
File file = new File(getFilesDir(), "test2.ogg");
|
||||
try {
|
||||
Context context = getApplicationContext();
|
||||
InputStream inputStream = context.getResources().openRawResource(R.raw.config);
|
||||
InputStream inputStream = context.getResources().openRawResource(R.raw.test2);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
byte buf[]=new byte[1024];
|
||||
int len;
|
||||
|
|
@ -263,7 +254,6 @@ public class PojavLoginActivity extends BaseActivity {
|
|||
}
|
||||
fileOutputStream.close();
|
||||
inputStream.close();
|
||||
System.out.println("Write to Local");
|
||||
} catch (IOException e1) {}
|
||||
return true;
|
||||
}catch (IOException e) {
|
||||
|
|
@ -273,8 +263,7 @@ public class PojavLoginActivity extends BaseActivity {
|
|||
}else return true; // we have at least one runtime, and it's compartible, good to go
|
||||
}
|
||||
|
||||
private static boolean mkdirs(String path)
|
||||
{
|
||||
private static boolean mkdirs(String path) {
|
||||
File file = new File(path);
|
||||
// check necessary???
|
||||
if(file.getParentFile().exists())
|
||||
|
|
|
|||
BIN
app_2009scape/src/main/res/raw/test.jar
Normal file
BIN
app_2009scape/src/main/res/raw/test.jar
Normal file
Binary file not shown.
BIN
app_2009scape/src/main/res/raw/test2.ogg
Normal file
BIN
app_2009scape/src/main/res/raw/test2.ogg
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue