PreviewVideoActivity: fix control buttons

For some reason only previous/next were working.

Manually bind play and pause, and remove the rest

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-02-18 18:00:51 +01:00
parent 22555a901a
commit 11e472b18b
No known key found for this signature in database
GPG key ID: 2585783189A62105
3 changed files with 12 additions and 24 deletions

View file

@ -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);

View file

@ -31,38 +31,22 @@
<ImageButton
android:id="@id/exo_prev"
android:foreground="?attr/selectableItemBackgroundBorderless"
style="@style/ExoMediaButton.Previous" />
<ImageButton
android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind" />
<ImageButton
android:id="@id/exo_shuffle"
style="@style/ExoMediaButton" />
<ImageButton
android:id="@id/exo_repeat_toggle"
style="@style/ExoMediaButton" />
<ImageButton
android:id="@id/exo_play"
android:foreground="?attr/selectableItemBackgroundBorderless"
style="@style/ExoMediaButton.Play" />
<ImageButton
android:id="@id/exo_pause"
android:foreground="?attr/selectableItemBackgroundBorderless"
style="@style/ExoMediaButton.Pause" />
<ImageButton
android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward" />
<ImageButton
android:id="@id/exo_vr"
style="@style/ExoMediaButton.VR" />
<ImageButton
android:id="@+id/exo_exit_fs"
android:foreground="?attr/selectableItemBackgroundBorderless"
style="@style/ExoMediaButton.ExitFullscreen" />
</LinearLayout>