diff --git a/app/src/main/java/org/schabi/newpipe/LocalPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/LocalPlayerActivity.java index aeec24ef6..c51f094aa 100644 --- a/app/src/main/java/org/schabi/newpipe/LocalPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/LocalPlayerActivity.java @@ -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) { diff --git a/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java b/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java index 2556c567d..7376493b6 100644 --- a/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java @@ -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( diff --git a/app/src/main/res/layout/activity_local_player.xml b/app/src/main/res/layout/activity_local_player.xml index 9f314fa60..dc5d11451 100644 --- a/app/src/main/res/layout/activity_local_player.xml +++ b/app/src/main/res/layout/activity_local_player.xml @@ -1,16 +1,16 @@ - + + app:show_shuffle_button="true" /> \ No newline at end of file