diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index 4f86f9c53..801adf9e7 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -65,6 +65,7 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory import com.google.android.exoplayer2.source.MediaSource import com.google.android.exoplayer2.source.MergingMediaSource import com.google.android.exoplayer2.source.ProgressiveMediaSource +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout import com.google.android.exoplayer2.ui.PlayerNotificationManager import com.google.android.exoplayer2.ui.StyledPlayerView import com.google.android.exoplayer2.upstream.DataSource @@ -93,6 +94,7 @@ class PlayerFragment : Fragment() { private var eId: Int = 0 private var paused = false private var whichQuality = 0 + private var isZoomed: Boolean = false var isSubscribed: Boolean = false @@ -283,6 +285,17 @@ class PlayerFragment : Fragment() { } } + // switching between original aspect ratio (black bars) and zoomed to fill device screen + view.findViewById(R.id.aspect_ratio_button).setOnClickListener { + if (isZoomed) { + exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT + isZoomed = false + } else { + exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM + isZoomed = true + } + } + val scrollView = view.findViewById(R.id.player_scrollView) scrollView.viewTreeObserver .addOnScrollChangedListener { diff --git a/app/src/main/res/drawable/ic_aspect_ratio.xml b/app/src/main/res/drawable/ic_aspect_ratio.xml new file mode 100644 index 000000000..c7b8b5f55 --- /dev/null +++ b/app/src/main/res/drawable/ic_aspect_ratio.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index 9862ce8f2..4a1a1898e 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -48,13 +48,10 @@ android:layout_height="wrap_content" android:src="@drawable/ic_close2" android:padding="@dimen/exo_icon_padding" - android:background="#00FFFFFF" - - /> + android:background="#00FFFFFF"/> + + android:textColor="#FFFFFF"/>