From d7d597f23555753d01028b6fce175ed2f9c77869 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 29 Dec 2018 15:09:20 +0100 Subject: [PATCH] Fullscreen Button --- .../peertube/activity/VideoPlayActivity.java | 17 ++++++---- .../main/res/layout/activity_video_play.xml | 7 ++--- ...l_view.xml => video_playback_controls.xml} | 31 ++++++++++++------- 3 files changed, 34 insertions(+), 21 deletions(-) rename app/src/main/res/layout/{exo_playback_control_view.xml => video_playback_controls.xml} (84%) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 4f85fca..cdfe2f0 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -35,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.PopupMenu; import android.util.Log; +import android.util.TypedValue; import android.view.Surface; import android.view.View; import android.view.ViewGroup; @@ -54,6 +55,7 @@ import com.github.se_bastiaan.torrentstream.TorrentStream; import com.github.se_bastiaan.torrentstream.listeners.TorrentListener; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.decoder.DecoderCounters; +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoRendererEventListener; @@ -134,6 +136,9 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere simpleExoPlayerView = new PlayerView(this); simpleExoPlayerView = findViewById(R.id.video_view); + simpleExoPlayerView.setControllerShowTimeoutMs(1000); + simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); + // Full screen Icon fullscreenButton = findViewById(R.id.exo_fullscreen); fullscreenButton.setText(R.string.video_expand_icon); @@ -243,7 +248,7 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) simpleExoPlayerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); simpleExoPlayerView.setLayoutParams(params); nameView.setVisibility(View.VISIBLE); @@ -440,11 +445,11 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere @Override protected void onStart() { super.onStart(); -// -// if (!mBound) { -// videoPlayerIntent = new Intent(this, VideoPlayerService.class); -// bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE); -// } + + if (!mBound) { + videoPlayerIntent = new Intent(this, VideoPlayerService.class); + bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE); + } Log.v(TAG, "onStart()..."); } diff --git a/app/src/main/res/layout/activity_video_play.xml b/app/src/main/res/layout/activity_video_play.xml index 6e38fce..84808ea 100644 --- a/app/src/main/res/layout/activity_video_play.xml +++ b/app/src/main/res/layout/activity_video_play.xml @@ -18,11 +18,10 @@ android:layout_width="match_parent" android:layout_height="250dp" android:background="@color/videoBackgroundColor" + app:resize_mode="fixed_width" + app:controller_layout_id="@layout/video_playback_controls" - app:layout_constraintDimensionRatio="H,3:1" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + /> - + + + + + +