Skip to content

Commit

Permalink
fix controller visibility when not playingOnScrubStart
Browse files Browse the repository at this point in the history
  • Loading branch information
GuhDoy committed Aug 5, 2023
1 parent cc3a14d commit 2980f82
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ class VideoPlayerFragment : BaseFragment() {

override fun onDoubleTap(ev: MotionEvent) {
val player = player ?: return
player.playWhenReady = !player.playWhenReady
playerView.useController = false
playerView.isClickable = true
player.playWhenReady = !player.playWhenReady
val DURATION_FOR_HIDING_ANIMATION_MS = 250L
controller.postDelayed(DURATION_FOR_HIDING_ANIMATION_MS) {
playerView.useController = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ open class CustomOnScrubListener(private val playerView: PlayerView) : TimeBar.O
}

override fun onScrubMove(timeBar: TimeBar, position: Long) {
if (!playingOnScrubStart) {
controlsBackground.isVisible = false
centerControls.isVisible = false
}
playerView.player?.seekTo(position)
seekDelta.text = getDeltaString(position - startingPosition)
}
Expand All @@ -92,7 +96,13 @@ open class CustomOnScrubListener(private val playerView: PlayerView) : TimeBar.O
playerView.player?.play()
}
if (!controllerVisibleOnScrubStart) {
if (controller.isFullyVisible) {
if (!playingOnScrubStart) {
playerView.useController = false
playerView.isClickable = true
controller.postDelayed(3 * DURATION_FOR_SHOWING_ANIMATION_MS) {
playerView.useController = true
}
} else if (controller.isFullyVisible) {
controller.hideImmediately()
} else {
// The controller is animating show.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023 Green Mushroom
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package me.gm.cleaner.plugin.mediastore.video.customexo

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.media3.ui.PlayerView

// Standby
class CustomPlayerView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : PlayerView(context, attrs, defStyleAttr) {

override fun onTrackballEvent(event: MotionEvent): Boolean = false
}

0 comments on commit 2980f82

Please sign in to comment.