feat: trickplay on gesture
This commit is contained in:
parent
ed69473e26
commit
9baa84e1e7
9 changed files with 67 additions and 4 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -16,7 +16,7 @@ captures/
|
|||
*.apk
|
||||
*.dm
|
||||
output.json
|
||||
output-metadata.json
|
||||
app/phone/libre/release/output-metadata.json
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
|
|
|
@ -146,6 +146,10 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
it.currentTrickplay = currentTrickplay
|
||||
}
|
||||
|
||||
playerGestureHelper?.let {
|
||||
it.currentTrickplay = currentTrickplay
|
||||
}
|
||||
|
||||
// Chapters
|
||||
if (appPreferences.showChapterMarkers && currentChapters != null) {
|
||||
currentChapters?.let { chapters ->
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.nomadics9.ananas.utils
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.SystemClock
|
||||
|
@ -19,15 +20,20 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.widget.ImageView
|
||||
import androidx.media3.ui.AspectRatioFrameLayout
|
||||
import androidx.media3.ui.PlayerView
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import com.nomadics9.ananas.AppPreferences
|
||||
import com.nomadics9.ananas.Constants
|
||||
import com.nomadics9.ananas.PlayerActivity
|
||||
import com.nomadics9.ananas.isControlsLocked
|
||||
import com.nomadics9.ananas.models.PlayerChapter
|
||||
import com.nomadics9.ananas.models.Trickplay
|
||||
import com.nomadics9.ananas.mpv.MPVPlayer
|
||||
import timber.log.Timber
|
||||
import kotlin.math.abs
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import coil.load
|
||||
|
||||
class PlayerGestureHelper(
|
||||
private val appPreferences: AppPreferences,
|
||||
private val activity: PlayerActivity,
|
||||
|
@ -62,6 +68,10 @@ class PlayerGestureHelper(
|
|||
private val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
||||
private val screenHeight = Resources.getSystem().displayMetrics.heightPixels
|
||||
|
||||
var currentTrickplay: Trickplay? = null
|
||||
private val roundedCorners = RoundedCornersTransformation(10f)
|
||||
private var currentBitMap: Bitmap? = null
|
||||
|
||||
private var currentNumberOfPointers: Int = 0
|
||||
|
||||
private val tapGestureDetector = GestureDetector(
|
||||
|
@ -265,6 +275,13 @@ class PlayerGestureHelper(
|
|||
activity.binding.progressScrubberLayout.visibility = View.VISIBLE
|
||||
activity.binding.progressScrubberText.text = "${longToTimestamp(difference)} [${longToTimestamp(newPos, true)}]"
|
||||
swipeGestureValueTrackerProgress = newPos
|
||||
|
||||
if (currentTrickplay != null) {
|
||||
onMove(newPos)
|
||||
} else {
|
||||
activity.binding.imagePreviewGesture.visibility = View.GONE
|
||||
}
|
||||
|
||||
swipeGestureProgressOpen = true
|
||||
true
|
||||
} else {
|
||||
|
@ -471,11 +488,28 @@ class PlayerGestureHelper(
|
|||
return false
|
||||
}
|
||||
|
||||
fun onMove(position: Long) {
|
||||
val trickplay = currentTrickplay ?: return
|
||||
val image = trickplay.images[position.div(trickplay.interval).toInt()]
|
||||
|
||||
if (currentBitMap != image) {
|
||||
activity.binding.imagePreviewGesture.load(image) {
|
||||
dispatcher(Dispatchers.Main.immediate)
|
||||
transformations(roundedCorners)
|
||||
}
|
||||
currentBitMap = image
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
if (appPreferences.playerBrightnessRemember) {
|
||||
activity.window.attributes.screenBrightness = appPreferences.playerBrightness
|
||||
}
|
||||
|
||||
if (!appPreferences.playerTrickPlayGesture) {
|
||||
activity.binding.imagePreviewGesture.visibility = View.GONE
|
||||
}
|
||||
|
||||
updateZoomMode(appPreferences.playerStartMaximized)
|
||||
|
||||
@Suppress("ClickableViewAccessibility")
|
||||
|
|
|
@ -16,8 +16,11 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/progress_scrubber_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="64dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/overlay_background"
|
||||
android:clickable="false"
|
||||
android:gravity="center"
|
||||
|
@ -25,10 +28,20 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_preview_gesture"
|
||||
android:layout_width="272dp"
|
||||
android:layout_height="153dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
||||
android:contentDescription="@string/player_trickplay" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_scrubber_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall"
|
||||
android:textColor="@android:color/white"
|
||||
tools:text="+00:00:10 [00:00:20]" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import org.gradle.api.JavaVersion
|
||||
|
||||
object Versions {
|
||||
const val appCode = 3
|
||||
const val appCode = 4
|
||||
const val appName = "0.14.2"
|
||||
|
||||
const val compileSdk = 34
|
||||
|
|
|
@ -193,4 +193,6 @@
|
|||
<string name="add_to_favorites">Add to favorites</string>
|
||||
<string name="remove_from_favorites">Remove from favorites</string>
|
||||
<string name="alaskarTV_requests">AlaskarTV Requests</string>
|
||||
<string name="pref_player_trickplay_gesture">Trick Play in seek gesture</string>
|
||||
<string name="pref_player_trickplay_gesture_summary">Requires \'Seek gesture\' and \'Trick Play\'</string>
|
||||
</resources>
|
||||
|
|
|
@ -103,6 +103,14 @@
|
|||
app:title="@string/pref_player_trickplay"
|
||||
app:widgetLayout="@layout/preference_material3_switch" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:dependency="pref_player_trickplay"
|
||||
app:key="pref_player_trick_play_gesture"
|
||||
app:summary="@string/pref_player_trickplay_gesture_summary"
|
||||
app:title="@string/pref_player_trickplay_gesture"
|
||||
app:widgetLayout="@layout/preference_material3_switch" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:key="pref_player_chapter_markers"
|
||||
|
|
|
@ -79,6 +79,7 @@ constructor(
|
|||
val playerMpvAo get() = sharedPreferences.getString(Constants.PREF_PLAYER_MPV_AO, "audiotrack")!!
|
||||
val playerIntroSkipper get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_INTRO_SKIPPER, true)
|
||||
val playerTrickplay get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_TRICKPLAY, true)
|
||||
val playerTrickPlayGesture get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_TRICKPLAY_GESTURE, true)
|
||||
val showChapterMarkers get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_CHAPTER_MARKERS, true)
|
||||
|
||||
val playerPipGesture get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_PIP_GESTURE, false)
|
||||
|
|
|
@ -28,6 +28,7 @@ object Constants {
|
|||
const val PREF_PLAYER_MPV_AO = "pref_player_mpv_ao"
|
||||
const val PREF_PLAYER_INTRO_SKIPPER = "pref_player_intro_skipper"
|
||||
const val PREF_PLAYER_TRICKPLAY = "pref_player_trickplay"
|
||||
const val PREF_PLAYER_TRICKPLAY_GESTURE = "pref_player_trickplay_gesture"
|
||||
const val PREF_PLAYER_CHAPTER_MARKERS = "pref_player_chapter_markers"
|
||||
const val PREF_PLAYER_PIP_GESTURE = "pref_player_picture_in_picture_gesture"
|
||||
const val PREF_AUDIO_LANGUAGE = "pref_audio_language"
|
||||
|
|
Loading…
Reference in a new issue