Skip to content

Commit

Permalink
Merge pull request #68 from damontecres/fix/player-controls
Browse files Browse the repository at this point in the history
Fixes to playback controls
  • Loading branch information
damontecres authored Jan 28, 2024
2 parents 1c0f04c + d9b90d7 commit 4088a81
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.media3.datasource.DataSource
import androidx.media3.datasource.DefaultHttpDataSource
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
import androidx.media3.ui.PlayerControlView
import androidx.media3.ui.PlayerView
import androidx.preference.PreferenceManager
import com.github.damontecres.stashapp.data.Scene
Expand All @@ -40,7 +41,7 @@ class PlaybackExoFragment :
override val currentVideoPosition get() = player?.currentPosition ?: playbackPosition

override fun hideControlsIfVisible(): Boolean {
if (videoView.isControllerFullyVisible) {
if (videoView.isControllerFullyVisible || previewTimeBar.isShown) {
videoView.hideController()
previewTimeBar.hidePreview()
previewTimeBar.hideScrubber(250L)
Expand Down Expand Up @@ -156,10 +157,12 @@ class PlaybackExoFragment :
val position = requireActivity().intent.getLongExtra(VideoDetailsFragment.POSITION_ARG, -1)
Log.d(TAG, "scene=${scene.id}, ${VideoDetailsFragment.POSITION_ARG}=$position")

val controllerShowTimeoutMs =
PreferenceManager.getDefaultSharedPreferences(requireContext())
.getInt("controllerShowTimeoutMs", PlayerControlView.DEFAULT_SHOW_TIMEOUT_MS)

videoView = view.findViewById(R.id.video_view)
videoView.requestFocus()
videoView.controllerShowTimeoutMs = 2000
videoView.hideController()
videoView.controllerShowTimeoutMs = controllerShowTimeoutMs

val mFocusedZoom =
requireContext().resources.getFraction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,34 @@
android:orientation="vertical">

<LinearLayout
android:id="@+id/controlsLayout"
android:layout_width="match_parent"
android:id="@id/exo_center_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#CC000000"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
android:padding="@dimen/exo_styled_controls_padding"
android:clipToPadding="false"
android:layoutDirection="ltr"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">

<ImageButton
android:id="@id/exo_prev"
style="@style/ExoMediaButton.Previous" />
style="@style/ExoStyledControls.Button.Center.Previous" />

<ImageButton
android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind" />
<include layout="@layout/exo_player_control_rewind_button" />

<ImageButton
android:id="@id/exo_play_pause"
style="@style/ExoMediaButton.Play" />
style="@style/ExoStyledControls.Button.Center.PlayPause" />

<ImageButton
android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward" />
<include layout="@layout/exo_player_control_ffwd_button" />

<ImageButton
android:id="@id/exo_next"
style="@style/ExoMediaButton.Next" />
style="@style/ExoStyledControls.Button.Center.Next" />

</LinearLayout>

Expand All @@ -59,7 +60,7 @@
android:textColor="#FFBEBEBE"
android:textSize="12sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/controlsLayout"
app:layout_constraintBottom_toTopOf="@id/exo_center_controls"
app:layout_constraintStart_toStartOf="parent"
tools:text="18:20" />

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/video_playback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_buffering="when_playing"
app:auto_show="true"
app:auto_show="false"
app:hide_on_touch="true"
app:animation_enabled="true"
app:scrubber_dragged_size="22dp"
app:played_color="@color/selected_background"
app:controller_layout_id="@layout/exoplayer_controls"
app:use_controller="true" />

</FrameLayout>
8 changes: 8 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
app:key="playerChoice"
app:title="Which player to use for playback"
app:defaultValue="true" />
<SeekBarPreference
app:key="controllerShowTimeoutMs"
app:title="Hide controls after (milliseconds)"
app:seekBarIncrement="100"
app:showSeekBarValue="true"
android:min="0"
android:max="15000"
app:defaultValue="5000" />
</PreferenceCategory>

<PreferenceCategory app:title="@string/stashapp_config_tasks_job_queue">
Expand Down

0 comments on commit 4088a81

Please sign in to comment.