summaryrefslogtreecommitdiffstats
path: root/doubletapplayerview
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2024-01-20 18:10:05 +0100
committerThomas <tschneider.ac@gmail.com>2024-01-20 18:10:05 +0100
commitc778c71306a474a340d56c29de0296e3e2e20d76 (patch)
treefd37e8b500755b5e557bf2cb0db8744594bd43b7 /doubletapplayerview
parent596c546cce0947169154070e464dbbad173e7856 (diff)
Prepare Media3
Diffstat (limited to 'doubletapplayerview')
-rw-r--r--doubletapplayerview/.gitignore1
-rw-r--r--doubletapplayerview/build.gradle38
-rw-r--r--doubletapplayerview/consumer-rules.pro0
-rw-r--r--doubletapplayerview/proguard-rules.pro21
-rw-r--r--doubletapplayerview/src/main/AndroidManifest.xml2
-rw-r--r--doubletapplayerview/src/main/java/com/github/vkay94/dtpv/DoubleTapPlayerView.kt222
-rw-r--r--doubletapplayerview/src/main/java/com/github/vkay94/dtpv/PlayerDoubleTapListener.java37
-rw-r--r--doubletapplayerview/src/main/java/com/github/vkay94/dtpv/SeekListener.kt13
-rw-r--r--doubletapplayerview/src/main/java/com/github/vkay94/dtpv/youtube/YouTubeOverlay.kt509
-rw-r--r--doubletapplayerview/src/main/java/com/github/vkay94/dtpv/youtube/views/CircleClipTapView.kt221
-rw-r--r--doubletapplayerview/src/main/java/com/github/vkay94/dtpv/youtube/views/YouTubeSecondsView.kt201
-rw-r--r--doubletapplayerview/src/main/res/drawable/ic_play_triangle.xml11
-rw-r--r--doubletapplayerview/src/main/res/layout/yt_overlay.xml30
-rw-r--r--doubletapplayerview/src/main/res/layout/yt_seconds_view.xml48
-rw-r--r--doubletapplayerview/src/main/res/values-af/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-am/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ar/plurals.xml10
-rw-r--r--doubletapplayerview/src/main/res/values-az/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-b+sr+Latn/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values-be/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-bg/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-bn/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-bs/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values-ca/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-cs/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-da/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-de/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-el/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-en-rGB/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-en-rIN/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-es-rUS/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-es/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-et/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-eu/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-fa/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-fi/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-fr-rCA/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-fr/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-gl/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-gu/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-hi/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-hr/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values-hu/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-hy/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-in/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-is/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-it/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-iw/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-ja/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ka/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-kk/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-km/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-kn/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ko/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ky/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-lo/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-lt/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-lv/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values-mk/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ml/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-mn/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-mr/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ms/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-my/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-nb/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ne/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-nl/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-pa/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-pl/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-pt-rBR/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-pt-rPT/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ro/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values-ru/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-si/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-sk/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-sl/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-sq/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-sr/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values-sv/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-sw/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-ta/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-te/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-th/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-tl/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-tr/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-uk/plurals.xml8
-rw-r--r--doubletapplayerview/src/main/res/values-ur/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-uz/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-vi/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-zh-rCN/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-zh-rHK/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-zh-rTW/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values-zu/plurals.xml6
-rw-r--r--doubletapplayerview/src/main/res/values/dtpv.xml8
-rw-r--r--doubletapplayerview/src/main/res/values/plurals.xml7
-rw-r--r--doubletapplayerview/src/main/res/values/public.xml16
-rw-r--r--doubletapplayerview/src/main/res/values/yt_overlay.xml26
97 files changed, 1913 insertions, 0 deletions
diff --git a/doubletapplayerview/.gitignore b/doubletapplayerview/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/doubletapplayerview/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/doubletapplayerview/build.gradle b/doubletapplayerview/build.gradle
new file mode 100644
index 000000000..4abcd4afb
--- /dev/null
+++ b/doubletapplayerview/build.gradle
@@ -0,0 +1,38 @@
+apply plugin: 'com.android.library'
+android {
+ compileSdk 34
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 34
+
+ vectorDrawables.useSupportLibrary = true
+
+ consumerProguardFiles 'consumer-rules.pro'
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ namespace 'com.github.vkay94.dtpv'
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "androidx.appcompat:appcompat:1.6.1"
+ implementation "androidx.core:core-ktx:1.12.0"
+
+ implementation "androidx.media3:media3-exoplayer:1.2.1"
+ implementation "androidx.media3:media3-exoplayer-dash:1.2.1"
+ implementation "androidx.media3:media3-ui:1.2.1"
+ implementation "androidx.constraintlayout:constraintlayout:2.1.4"
+}
diff --git a/doubletapplayerview/consumer-rules.pro b/doubletapplayerview/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/doubletapplayerview/consumer-rules.pro
diff --git a/doubletapplayerview/proguard-rules.pro b/doubletapplayerview/proguard-rules.pro
new file mode 100644
index 000000000..f1b424510
--- /dev/null
+++ b/doubletapplayerview/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/doubletapplayerview/src/main/AndroidManifest.xml b/doubletapplayerview/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..2d6765895
--- /dev/null
+++ b/doubletapplayerview/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.github.vkay94.dtpv" />
diff --git a/doubletapplayerview/src/main/java/com/github/vkay94/dtpv/DoubleTapPlayerView.kt b/doubletapplayerview/src/main/java/com/github/vkay94/dtpv/DoubleTapPlayerView.kt
new file mode 100644
index 000000000..a3374d90c
--- /dev/null
+++ b/doubletapplayerview/src/main/java/com/github/vkay94/dtpv/DoubleTapPlayerView.kt
@@ -0,0 +1,222 @@
+package com.github.vkay94.dtpv
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.os.Handler
+import android.os.Looper
+import android.util.AttributeSet
+import android.util.Log
+import android.view.GestureDetector
+import android.view.MotionEvent
+import android.view.View
+import androidx.core.view.GestureDetectorCompat
+import androidx.media3.ui.PlayerView
+
+
+/**
+ * Custom player class for Double-Tapping listening
+ */
+open class DoubleTapPlayerView @JvmOverloads constructor(
+ context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : PlayerView(context!!, attrs, defStyleAttr) {
+
+ private val gestureDetector: GestureDetectorCompat
+ private val gestureListener: DoubleTapGestureListener = DoubleTapGestureListener(rootView)
+
+ private var controller: PlayerDoubleTapListener? = null
+ get() = gestureListener.controls
+ set(value) {
+ gestureListener.controls = value
+ field = value
+ }
+
+ private var controllerRef: Int = -1
+
+ init {
+ gestureDetector = GestureDetectorCompat(context, gestureListener)
+
+ // Check whether controller is set through XML
+ attrs?.let {
+ val a = context?.obtainStyledAttributes(attrs, R.styleable.DoubleTapPlayerView, 0,0)
+ controllerRef = a?.getResourceId(R.styleable.DoubleTapPlayerView_dtpv_controller, -1) ?: -1
+
+ a?.recycle()
+ }
+ }
+
+ /**
+ * If this field is set to `true` this view will handle double tapping, otherwise it will
+ * handle touches the same way as the original [PlayerView][com.google.android.exoplayer2.ui.PlayerView] does
+ */
+ var isDoubleTapEnabled = true
+
+ /**
+ * Time window a double tap is active, so a followed tap is calling a gesture detector
+ * method instead of normal tap (see [PlayerView.onTouchEvent])
+ */
+ var doubleTapDelay: Long = 700
+ get() = gestureListener.doubleTapDelay
+ set(value) {
+ gestureListener.doubleTapDelay = value
+ field = value
+ }
+
+ /**
+ * Sets the [PlayerDoubleTapListener] which handles the gesture callbacks.
+ *
+ * Primarily used for [YouTubeOverlay][com.github.vkay94.dtpv.youtube.YouTubeOverlay]
+ */
+ fun controller(controller: PlayerDoubleTapListener) = apply { this.controller = controller }
+
+ /**
+ * Returns the current state of double tapping.
+ */
+ fun isInDoubleTapMode(): Boolean = gestureListener.isDoubleTapping
+
+ /**
+ * Resets the timeout to keep in double tap mode.
+ *
+ * Called once in [PlayerDoubleTapListener.onDoubleTapStarted]. Needs to be called
+ * from outside if the double tap is customized / overridden to detect ongoing taps
+ */
+ fun keepInDoubleTapMode() {
+ gestureListener.keepInDoubleTapMode()
+ }
+
+ /**
+ * Cancels double tap mode instantly by calling [PlayerDoubleTapListener.onDoubleTapFinished]
+ */
+ fun cancelInDoubleTapMode() {
+ gestureListener.cancelInDoubleTapMode()
+ }
+
+ @SuppressLint("ClickableViewAccessibility")
+ override fun onTouchEvent(ev: MotionEvent): Boolean {
+ if (isDoubleTapEnabled) {
+ gestureDetector.onTouchEvent(ev)
+
+ // Do not trigger original behavior when double tapping
+ // otherwise the controller would show/hide - it would flack
+ return true
+ }
+ return super.onTouchEvent(ev)
+ }
+
+ override fun onAttachedToWindow() {
+ super.onAttachedToWindow()
+
+ // If the PlayerView is set by XML then call the corresponding setter method
+ if (controllerRef != -1) {
+ try {
+ val view = (this.parent as View).findViewById(controllerRef) as View
+ if (view is PlayerDoubleTapListener) {
+ controller(view)
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ Log.e("DoubleTapPlayerView",
+ "controllerRef is either invalid or not PlayerDoubleTapListener: ${e.message}")
+