mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-18 18:42:46 +00:00
Allow the display to go off if the stream disconnects
This commit is contained in:
parent
e0a7ff1880
commit
3a868045d7
@ -146,10 +146,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// We don't want a title bar
|
// We don't want a title bar
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
// Full-screen and don't let the display go off
|
// Full-screen
|
||||||
getWindow().addFlags(
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN |
|
|
||||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
||||||
|
|
||||||
// If we're going to use immersive mode, we want to have
|
// If we're going to use immersive mode, we want to have
|
||||||
// the entire screen
|
// the entire screen
|
||||||
@ -1169,10 +1167,15 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stageStarting(String stage) {
|
public void stageStarting(final String stage) {
|
||||||
if (spinner != null) {
|
runOnUiThread(new Runnable() {
|
||||||
spinner.setMessage(getResources().getString(R.string.conn_starting)+" "+stage);
|
@Override
|
||||||
}
|
public void run() {
|
||||||
|
if (spinner != null) {
|
||||||
|
spinner.setMessage(getResources().getString(R.string.conn_starting) + " " + stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1197,70 +1200,78 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stageFailed(String stage, long errorCode) {
|
public void stageFailed(final String stage, final long errorCode) {
|
||||||
if (spinner != null) {
|
runOnUiThread(new Runnable() {
|
||||||
spinner.dismiss();
|
@Override
|
||||||
spinner = null;
|
public void run() {
|
||||||
}
|
if (spinner != null) {
|
||||||
|
spinner.dismiss();
|
||||||
|
spinner = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Enable cursor visibility again
|
if (!displayedFailureDialog) {
|
||||||
inputCaptureProvider.disableCapture();
|
displayedFailureDialog = true;
|
||||||
|
LimeLog.severe(stage + " failed: " + errorCode);
|
||||||
|
|
||||||
if (!displayedFailureDialog) {
|
// If video initialization failed and the surface is still valid, display extra information for the user
|
||||||
displayedFailureDialog = true;
|
if (stage.contains("video") && streamView.getHolder().getSurface().isValid()) {
|
||||||
LimeLog.severe(stage+" failed: "+errorCode);
|
|
||||||
|
|
||||||
// If video initialization failed and the surface is still valid, display extra information for the user
|
|
||||||
if (stage.contains("video") && streamView.getHolder().getSurface().isValid()) {
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(Game.this, "Video decoder failed to initialize. Your device may not support the selected resolution.", Toast.LENGTH_LONG).show();
|
Toast.makeText(Game.this, "Video decoder failed to initialize. Your device may not support the selected resolution.", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog.displayDialog(this, getResources().getString(R.string.conn_error_title),
|
Dialog.displayDialog(Game.this, getResources().getString(R.string.conn_error_title),
|
||||||
getResources().getString(R.string.conn_error_msg)+" "+stage, true);
|
getResources().getString(R.string.conn_error_msg) + " " + stage, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionTerminated(long errorCode) {
|
public void connectionTerminated(final long errorCode) {
|
||||||
// Enable cursor visibility again
|
runOnUiThread(new Runnable() {
|
||||||
inputCaptureProvider.disableCapture();
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Let the display go to sleep now
|
||||||
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
if (!displayedFailureDialog) {
|
// Enable cursor visibility again
|
||||||
displayedFailureDialog = true;
|
inputCaptureProvider.disableCapture();
|
||||||
LimeLog.severe("Connection terminated: "+errorCode);
|
|
||||||
stopConnection();
|
|
||||||
|
|
||||||
Dialog.displayDialog(this, getResources().getString(R.string.conn_terminated_title),
|
if (!displayedFailureDialog) {
|
||||||
getResources().getString(R.string.conn_terminated_msg), true);
|
displayedFailureDialog = true;
|
||||||
}
|
LimeLog.severe("Connection terminated: " + errorCode);
|
||||||
|
stopConnection();
|
||||||
|
|
||||||
|
Dialog.displayDialog(Game.this, getResources().getString(R.string.conn_terminated_title),
|
||||||
|
getResources().getString(R.string.conn_terminated_msg), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStarted() {
|
public void connectionStarted() {
|
||||||
if (spinner != null) {
|
|
||||||
spinner.dismiss();
|
|
||||||
spinner = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
connected = true;
|
|
||||||
connecting = false;
|
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (spinner != null) {
|
||||||
|
spinner.dismiss();
|
||||||
|
spinner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
connected = true;
|
||||||
|
connecting = false;
|
||||||
|
|
||||||
// Hide the mouse cursor now. Doing it before
|
// Hide the mouse cursor now. Doing it before
|
||||||
// dismissing the spinner seems to be undone
|
// dismissing the spinner seems to be undone
|
||||||
// when the spinner gets displayed.
|
// when the spinner gets displayed.
|
||||||
inputCaptureProvider.enableCapture();
|
inputCaptureProvider.enableCapture();
|
||||||
|
|
||||||
|
// Keep the display on
|
||||||
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
|
hideSystemUi(1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hideSystemUi(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user