custom shuffle button

This commit is contained in:
Bnyro 2022-07-10 13:56:17 +02:00
parent e3a2b32de7
commit bedfb13539
4 changed files with 44 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import android.app.PictureInPictureParams
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.graphics.Color
import android.graphics.Rect
import android.net.Uri
import android.os.Build
@ -685,7 +686,6 @@ class PlayerFragment : Fragment() {
setShowSubtitleButton(true)
setShowNextButton(false)
setShowPreviousButton(false)
setRepeatToggleModes(RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL)
// controllerShowTimeoutMs = 1500
controllerHideOnTouch = true
useController = false
@ -808,6 +808,18 @@ class PlayerFragment : Fragment() {
}
})
// repeat toggle button
playerBinding.repeatToggle.setOnClickListener {
if (exoPlayer.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL) {
// turn off repeat mode
exoPlayer.repeatMode = RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE
playerBinding.repeatToggle.setColorFilter(Color.GRAY)
} else {
exoPlayer.repeatMode = RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL
playerBinding.repeatToggle.setColorFilter(Color.WHITE)
}
}
// share button
binding.relPlayerShare.setOnClickListener {
val shareDialog = ShareDialog(videoId!!, false)

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M7,7h10v3l4,-4 -4,-4v3L5,5v6h2L7,7zM17,17L7,17v-3l-4,4 4,4v-3h12v-6h-2v4z" />
</vector>

View File

@ -75,7 +75,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:background="#00FFFFFF"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/exo_icon_padding"
android:src="@drawable/ic_aspect_ratio" />
@ -85,6 +85,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="5dp"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/exo_icon_padding"
android:text="1x"
android:textColor="#FFFFFF" />
@ -95,6 +96,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="5dp"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/exo_icon_padding"
android:text="@string/hls"
android:textColor="#FFFFFF" />
@ -114,7 +116,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:layout_marginBottom="-5dp"
android:paddingStart="@dimen/exo_styled_bottom_bar_time_padding"
android:paddingLeft="@dimen/exo_styled_bottom_bar_time_padding"
android:paddingEnd="@dimen/exo_styled_bottom_bar_time_padding"
@ -125,7 +127,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp">
android:layout_marginStart="5dp">
<TextView
android:id="@id/exo_position"
@ -172,16 +174,18 @@
android:layout_height="wrap_content">
<ImageButton
android:id="@id/exo_repeat_toggle"
style="@style/ExoStyledControls.Button.Bottom.RepeatToggle" />
android:id="@+id/repeat_toggle"
style="@style/PlayerButton"
android:src="@drawable/ic_repeat"
app:tint="@android:color/darker_gray"/>
<ImageButton
android:id="@id/exo_subtitle"
style="@style/ExoStyledControls.Button.Bottom.CC" />
style="@style/PlayerButton" />
<ImageButton
android:id="@+id/fullscreen"
style="@style/ExoStyledControls.Button.Bottom.FullScreen"
style="@style/PlayerButton"
android:src="@drawable/ic_fullscreen"
app:tint="@android:color/white" />

View File

@ -114,4 +114,14 @@
</style>
<style name="PlayerButton">
<item name="android:padding">6dp</item>
<item name="android:layout_height">36dp</item>
<item name="android:layout_width">36dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:background">?attr/selectableItemBackground</item>
</style>
</resources>