fixed controls hiding/showing with taps, and screen dimming issues

This commit is contained in:
polymorphicshade 2021-02-25 20:33:47 -07:00
parent 20b327215c
commit 0e543413d5
3 changed files with 13 additions and 6 deletions

View file

@ -32,6 +32,7 @@ import java.util.List;
public class LocalPlayerActivity extends AppCompatActivity implements Player.EventListener,
LocalPlayerListener, PlaybackParameterDialog.Callback {
private LocalPlayer localPlayer;
private PlayerView playerView;
public static final String TAG = "LocalPlayerActivity";
@Override
@ -49,14 +50,17 @@ public class LocalPlayerActivity extends AppCompatActivity implements Player.Eve
localPlayer = new LocalPlayer(this);
localPlayer.initialize(uri, segments);
localPlayer.setListener(this);
final PlayerView playerView = findViewById(R.id.player_view);
playerView = findViewById(R.id.player_view);
playerView.setPlayer(localPlayer.getExoPlayer());
playerView.getVideoSurfaceView().setOnLongClickListener(v -> {
showPlaybackParameterDialog();
return true;
return false;
});
playerView.getVideoSurfaceView().setOnClickListener(v -> playerView.performClick());
}
public void showPlaybackParameterDialog() {
@ -98,7 +102,7 @@ public class LocalPlayerActivity extends AppCompatActivity implements Player.Eve
@Override
public void onBuffering(final SimpleExoPlayer player) {
setKeepScreenOn(true);
}
@Override
@ -153,6 +157,7 @@ public class LocalPlayerActivity extends AppCompatActivity implements Player.Eve
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
playerView.getRootView().setKeepScreenOn(keepScreenOn);
}
private void hideSystemUi(final boolean isLandscape) {

View file

@ -8,6 +8,7 @@ import android.widget.Toast;
import androidx.preference.PreferenceManager;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player.EventListener;
import com.google.android.exoplayer2.SeekParameters;
@ -61,6 +62,7 @@ public class LocalPlayer implements EventListener {
simpleExoPlayer.addListener(this);
simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context));
simpleExoPlayer.setHandleAudioBecomingNoisy(true);
simpleExoPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
final PlaybackParameters playbackParameters = simpleExoPlayer.getPlaybackParameters();
final float speed = mPrefs.getFloat(context.getString(

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
tools:context=".LocalPlayerActivity">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"