Skip to content

Commit

Permalink
Merge pull request for Release 0.7.0
Browse files Browse the repository at this point in the history
Merge dev for Release 0.7.0
  • Loading branch information
vkay94 authored Dec 3, 2019
2 parents 9ef177d + 3f071f9 commit df0950e
Show file tree
Hide file tree
Showing 120 changed files with 2,052 additions and 586 deletions.
165 changes: 119 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ Created to handle fast forward/rewind behavior like YouTube.
<img src="github/youtube_preview.png" alt="youtube_preview" width="350"/>
</p>

Download
--------
Gradle:
# Sample app

If you would like to test the YouTube overlay, then you can either download the demo app,
which can be found under Assets of the release or build it yourself from code.
It provides all modifications available.

The sample videos own by *Blender Foundation* and a full list can be found [here][videolist].

# Download

The Gradle dependency is available via [jitpack.io][jitpack].
To be able to load this library, you have to add the repository to your project's gradle file:

```gradle
allprojects {
Expand All @@ -19,67 +28,131 @@ allprojects {
maven { url 'https://jitpack.io' }
}
}
```

Then, in your app's directory, you can include it the same way like other libraries:

```gradle
dependencies {
implementation 'com.github.vkay94:DoubleTapPlayerView:0.6.0'
implementation 'com.github.vkay94:DoubleTapPlayerView:0.7.0'
}
```

How to use
-------------------
The minimum API level supported by this library is API 21 (Lollipop 5.0+).

In the following I describe how to implement and configure the YouTube-alike behavior
([see the sample app for a possible implementation][MainActivity]).

#### Basic usage
# Getting started

Layout:
In order to start using the YouTube overlay, the easiest way is to include it directly
into your XML layout, e.g. on top of `DoubleTapPlayerView` or inside ExoPlayer's controller:

```xml
<FrameLayout>

<!-- Replace ExoPlayer's PlayerView -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.github.vkay94.dtpv.DoubleTapPlayerView
android:id="@+id/doubleTapPlayerView"
app:player_layout_id="@layout/exo_simple_player_view"
app:use_controller="true"
...
/>

<!-- Other views e.g. ProgressBar etc -->

<!-- Add the overlay on top of PlayerView -->
<com.github.vkay94.dtpv.YouTubeDoubleTap
android:background="@color/dtp_overlay_dim"
android:id="@+id/youTubeDoubleTap"
android:layout_width="match_parent"
android:layout_height="match_parent" />

android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<com.github.vkay94.dtpv.youtube.YouTubeOverlay
android:id="@+id/youtube_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"

app:yt_playerview="@+id/playerView" />
</FrameLayout>
```

Activity (Kotlin):
Then, inside your `Activity` or `Fragment`, you can specify which preparations should be done
before and after the animation, but at least, you have got to toggle the visibility of the overlay
and reference the (Simple)ExoPlayer to it:

```kotlin
// Link the PlayerView to the overlay to pass increment to the Player (seekTo)
// Important: set the (Simple)ExoPlayer to the PlayerView before this call
youTubeDoubleTap
.setPlayer(doubletapplayerview)
.setForwardRewindIncrementMs(5000)

// Set YouTube overlay to the PlayerView and double tapping enabled (false by default)
doubleTapPlayerView
.activateDoubleTap(true)
.setDoubleTapDelay(500)
.setDoubleTapListener(youTubeDoubleTap)
youtube_overlay.apply {
performListener = object : YouTubeOverlay.PerformListener {
override fun onAnimationStart() {
// Do UI changes when circle scaling animation starts (e.g. hide controller views)
youtube_overlay.visibility = View.VISIBLE
}

override fun onAnimationEnd() {
// Do UI changes when circle scaling animation starts (e.g. show controller views)
youtube_overlay.visibility = View.GONE
}
}
}

// Call this method whenever the player is released and recreated
youtube_overlay.setPlayer(simpleExoPlayer)
```

#### Additional features
This way, you have more control about the appearance, for example you could apply a fading animation to it.

---

# API documentation

The following sections provide detailed documentation for the components of the library.

## DoubleTapPlayerView

`DoubleTapPlayerView` is the core of this library. It recognizes specific gestures
which provides more control for the double tapping gesture.
An overview about the added methods can be found in the [PlayerDoubleTapListener][PlayerDoubleTapListener] interface.

You can adjust how long the double tap mode remains after the last action,
the default value is 650 milliseconds.

## YouTubeOverlay

`YouTubeOverlay` is the reason for this library. It provides nearly the
same experience like the fast forward/rewind feature which is used by YouTube's
Android app. It is highly modifiable.

### XML attributes

If you add the view to your XML layout you can set some custom attributes
to customize the view's look and behavior.
Every attributes value can also be get and set programmatically.


| Attribute name | Description | Type |
| ------------- | ------------| ------|
| `yt_ffrDuration` | Fast forward/rewind duration skip per tap. The text *xx seconds* will also be changed where xx is `value/1000`. | `int` |
| `yt_animationDuration` | Speed of the circle scaling / time to expand completely. When this time has passed, YouTubeOverlay's `PerformListener.onAnimationEnd()` will be called. | `int` |
| `yt_arcSize` | Arc of the background circle. The higher the value the more roundish the shape becomes. | `dimen` |
| `yt_tapCircleColor` | Color of the scaling circle after tap. | `color` |
| `yt_backgroundCircleColor` | Color of the background shape. | `color` |

### YouTubeOverlay.PerformListener

This interface listens to the *lifecycle* of the overlay.

**onAnimationStart()** *(obligatory)*

Called when the overlay is not visible and the first valid double tap event occurred.
Visibility of the overlay should be set to VISIBLE within this interface method.

**onAnimationEnd()** *(obligatory)*

Called when the circle animation is finished.
Visibility of the overlay should be set to GONE within this interface method.

### SeekListener

This interface reacts to the events during rewinding/forwarding.

* **SeekListener**: By implementing this interface you can react to the
events *onVideoStartReached* and *onVideoEndReached*
* **Toogle via code**: You can simulate a double tap programmatically e.g.
when a button clicked
`onVideoStartReached()` is called when the start of the video is reached and
`onVideoEndReached()` is called when the end of the video is reached.

[videolist]: https://gist.github.com/jsturgis/3b19447b304616f18657
[demoapp]: https://
[jitpack]: https://jitpack.io/#vkay94/DoubleTapPlayerView
[PlayerDoubleTapListener]: https://github.com/vkay94/DoubleTapPlayerView/blob/master/doubletapplayerview/src/main/java/com/github/vkay94/dtpv/PlayerDoubleTapListener.java
[MainActivity]: https://github.com/vkay94/DoubleTapPlayerView/blob/master/app/src/main/java/com/github/vkay94/doubletapplayerviewexample/MainActivity.kt
[MainActivity]: https://github.com/vkay94/DoubleTapPlayerView/blob/master/app/src/main/java/com/github/vkay94/doubletapplayerviewexample/MainActivity.kt
[VideoActivity]: https://github.com/vkay94/DoubleTapPlayerView/blob/dev/app/src/main/java/com/github/vkay94/doubletapplayerviewexample/VideoActivity.kt
21 changes: 12 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.github.vkay94.doubletapplayerviewexample"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 29
versionCode 60
versionName "0.6.0"
versionCode 70
versionName "0.7.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand All @@ -30,16 +31,18 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation 'androidx.core:core-ktx:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation "com.google.android.exoplayer:exoplayer-core:2.10.6"
implementation "com.google.android.exoplayer:exoplayer-ui:2.10.6"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'

// ExoPlayer2
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"

implementation 'com.github.QuadFlask:colorpicker:0.0.15'
implementation project(path: ':doubletapplayerview')
}
29 changes: 8 additions & 21 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
# 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
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
9 changes: 4 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity"
android:screenOrientation="landscape"
>
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity
android:name=".VideoActivity"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Loading

0 comments on commit df0950e

Please sign in to comment.