From 11e472b18bdf1f7dbe5b6d11fccfcc0dd3f4bee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Fri, 18 Feb 2022 18:00:51 +0100 Subject: [PATCH] PreviewVideoActivity: fix control buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason only previous/next were working. Manually bind play and pause, and remove the rest Signed-off-by: Álvaro Brey Vilas --- .../ui/preview/PreviewVideoActivity.java | 12 ++++++---- ..._layout.xml => activity_preview_video.xml} | 0 .../res/layout/exo_player_control_view.xml | 24 ++++--------------- 3 files changed, 12 insertions(+), 24 deletions(-) rename src/main/res/layout/{video_layout.xml => activity_preview_video.xml} (100%) diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java b/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java index 54933ed8e8..6aeaa0b82c 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java @@ -30,10 +30,10 @@ import android.os.Bundle; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.MediaItem; -import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.ui.StyledPlayerView; import com.nextcloud.client.media.ErrorFormat; import com.owncloud.android.R; +import com.owncloud.android.databinding.ActivityPreviewVideoBinding; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.FileActivity; @@ -66,13 +66,15 @@ public class PreviewVideoActivity extends FileActivity implements OnCompletionLi private boolean mAutoplay; // when 'true', the playback starts immediately with the activity private ExoPlayer exoPlayer; // view to play the file; both performs and show the playback private Uri mStreamUri; + private ActivityPreviewVideoBinding binding; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log_OC.v(TAG, "onCreate"); - setContentView(R.layout.video_layout); + binding = ActivityPreviewVideoBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); Bundle extras = getIntent().getExtras(); @@ -87,10 +89,12 @@ public class PreviewVideoActivity extends FileActivity implements OnCompletionLi } StyledPlayerView playerView = findViewById(R.id.videoPlayer); - exoPlayer = new SimpleExoPlayer.Builder(this).build(); + exoPlayer = new ExoPlayer.Builder(this).build(); playerView.setPlayer(exoPlayer); - findViewById(R.id.exo_exit_fs).setOnClickListener(v -> onBackPressed()); + binding.getRoot().findViewById(R.id.exo_exit_fs).setOnClickListener(v -> onBackPressed()); + binding.getRoot().findViewById(R.id.exo_pause).setOnClickListener(v -> exoPlayer.pause()); + binding.getRoot().findViewById(R.id.exo_play).setOnClickListener(v -> exoPlayer.play()); if (mSavedPlaybackPosition >= 0) { exoPlayer.seekTo(mSavedPlaybackPosition); diff --git a/src/main/res/layout/video_layout.xml b/src/main/res/layout/activity_preview_video.xml similarity index 100% rename from src/main/res/layout/video_layout.xml rename to src/main/res/layout/activity_preview_video.xml diff --git a/src/main/res/layout/exo_player_control_view.xml b/src/main/res/layout/exo_player_control_view.xml index d3f1a7d10c..59e7a5e4fc 100644 --- a/src/main/res/layout/exo_player_control_view.xml +++ b/src/main/res/layout/exo_player_control_view.xml @@ -31,38 +31,22 @@ - - - - - - - - - -