Skip to content

Commit

Permalink
Merge pull request #53 from rubensousa/media3
Browse files Browse the repository at this point in the history
Media3 extension
  • Loading branch information
rubensousa authored Sep 9, 2023
2 parents 7db1cf2 + 49db55d commit cfd1ade
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 113 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.1.1

- Bumped `androidx.appcompat:appcompat` to 1.6.1

# 3.1.0

- Bumped `androidx.appcompat:appcompat` to 1.5.1
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG_MEDIA3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.1.1.0

- Initial support for media3
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ Add the following to your app's build.gradle:
```groovy
dependencies {
// Base implementation with a standard SeekBar
implementation 'com.github.rubensousa:previewseekbar:3.1.0'
// ExoPlayer extension that contains a TimeBar.
// Grab this one if you're going to integrate with ExoPlayer
implementation 'com.github.rubensousa:previewseekbar-exoplayer:2.18.1.0'
implementation 'com.github.rubensousa:previewseekbar:3.1.1'
// Media3 extension that contains a TimeBar.
implementation 'com.github.rubensousa:previewseekbar-media3:1.1.1.0'
}
```

## How to use with ExoPlayer
## How to use with Media3

### Add a custom controller to your PlayerView

```xml
<com.google.android.exoplayer2.ui.PlayerView
<androidx.media3.ui.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
18 changes: 5 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
buildscript {
apply from: 'versions.gradle'

repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
}
}

Expand All @@ -15,18 +19,6 @@ allprojects {
}
}

ext {
compileSdkVersion = 33
minSdkVersion = 19
targetSdkVersion = 31
coreVersion = '1.10.1'
appcompatVersion = '1.6.1'
materialVersion = '1.9.0'
constraintLayoutVersion = '2.1.4'
glideVersion = '4.14.2'
media3Version = '1.1.1'
annotationVersion = '1.3.0'
}

task clean(type: Delete) {
delete rootProject.buildDir
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true

LIBRARY_GROUP=com.github.rubensousa
LIBRARY_VERSION=3.1.0
LIBRARY_VERSION=3.1.1
LIBRARY_ARTIFACT=previewseekbar
POM_NAME=PreviewSeekBar
POM_DESCRIPTION=A SeekBar suited for showing a preview of something
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 16 20:54:49 CET 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
26 changes: 0 additions & 26 deletions previewseekbar-exoplayer/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions previewseekbar-exoplayer/gradle.properties

This file was deleted.

1 change: 0 additions & 1 deletion previewseekbar-exoplayer/src/main/AndroidManifest.xml

This file was deleted.

File renamed without changes.
27 changes: 27 additions & 0 deletions previewseekbar-media3/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.library'
apply from: rootProject.file('gradle/publish.gradle')

android {
compileSdk versions.compileSdk
namespace 'com.github.rubensousa.previewseekbar.media3'

defaultConfig {
minSdk versions.minSdk
targetSdk versions.targetSdk
}

publishing {
singleVariant('release') {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {
api project(':previewseekbar')
implementation "androidx.core:core:$versions.core"
implementation "androidx.media3:media3-exoplayer:$versions.media3"
implementation "androidx.media3:media3-ui:$versions.media3"
implementation "androidx.annotation:annotation:$versions.annotation"
}
3 changes: 3 additions & 0 deletions previewseekbar-media3/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBRARY_VERSION=1.1.1.0
LIBRARY_ARTIFACT=previewseekbar-media3
POM_DESCRIPTION="Media3 components for PreviewSeekBar"
File renamed without changes.
1 change: 1 addition & 0 deletions previewseekbar-media3/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="com.github.rubensousa.previewseekbar.media3"/>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.rubensousa.previewseekbar.exoplayer;
package com.github.rubensousa.previewseekbar.media3;

import android.content.Context;
import android.content.res.TypedArray;
Expand Down Expand Up @@ -43,7 +43,6 @@
* <p>
* When the user scrubs this TimeBar, a preview will appear above the scrubber.
*/

@OptIn(markerClass = UnstableApi.class)
public class PreviewTimeBar extends DefaultTimeBar implements PreviewBar {

Expand Down
13 changes: 9 additions & 4 deletions previewseekbar/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
apply plugin: 'com.android.library'
plugins {
id 'com.android.library'
}

apply from: rootProject.file('gradle/publish.gradle')

android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileSdk versions.compileSdk
namespace 'com.github.rubensousa.previewseekbar'

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
minSdk versions.minSdk
targetSdk versions.targetSdk
}

publishing {
Expand All @@ -18,6 +23,6 @@ android {
}

dependencies {
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.appcompat:appcompat:$versions.appcompat"
}

2 changes: 1 addition & 1 deletion previewseekbar/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.github.rubensousa.previewseekbar"/>
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ public PreviewDelegate(PreviewBar previewBar) {
this.previewBar = previewBar;
this.animationEnabled = true;
this.previewAutoHide = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator = new PreviewMorphAnimator();
} else {
animator = new PreviewFadeAnimator();
}
animator = new PreviewMorphAnimator();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public PreviewSeekBar(Context context) {
}

public PreviewSeekBar(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.seekBarStyle);
this(context, attrs, androidx.appcompat.R.attr.seekBarStyle);
}

public PreviewSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
Expand All @@ -47,7 +47,7 @@ private void init(Context context, AttributeSet attrs) {
R.styleable.PreviewSeekBar, 0, 0);

TypedArray themeTypedArray = context.getTheme().obtainStyledAttributes(
new int[]{R.attr.colorAccent});
new int[]{androidx.appcompat.R.attr.colorAccent});

final int defaultThumbColor = themeTypedArray.getColor(0, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
Expand All @@ -38,7 +36,6 @@
* A {@link PreviewAnimator} that morphs the {@link PreviewBar} thumb
* into the preview view.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class PreviewMorphAnimator implements PreviewAnimator {

private static final int MORPH_SHOW_DURATION = 125;
Expand Down
33 changes: 17 additions & 16 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
apply plugin: 'com.android.application'

android {
compileSdk rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdk versions.compileSdk
namespace "com.github.rubensousa.previewseekbar.sample"

defaultConfig {
applicationId "com.github.rubensousa.previewseekbar.sample"
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
minSdk versions.minSdk
targetSdk versions.targetSdk
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -25,13 +26,13 @@ android {
}

dependencies {
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.annotation:annotation:$annotationVersion"
implementation "com.google.android.material:material:$materialVersion"
implementation "androidx.media3:media3-ui:$media3Version"
implementation "androidx.media3:media3-exoplayer:$media3Version"
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
implementation "com.github.bumptech.glide:glide:$glideVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin"
implementation "androidx.appcompat:appcompat:$versions.appcompat"
implementation "com.google.android.material:material:$versions.material"
implementation "androidx.media3:media3-ui:$versions.media3"
implementation "androidx.media3:media3-exoplayer:$versions.media3"
implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
implementation "com.github.bumptech.glide:glide:$versions.glide"
implementation project(':previewseekbar')
implementation project(':previewseekbar-exoplayer')
implementation project(':previewseekbar-media3')
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.github.rubensousa.previewseekbar.sample.exoplayer;
package com.github.rubensousa.previewseekbar.sample;

import android.net.Uri;
import android.widget.ImageView;
Expand All @@ -32,9 +32,7 @@
import com.bumptech.glide.request.target.Target;
import com.github.rubensousa.previewseekbar.PreviewBar;
import com.github.rubensousa.previewseekbar.PreviewLoader;
import com.github.rubensousa.previewseekbar.exoplayer.PreviewTimeBar;
import com.github.rubensousa.previewseekbar.sample.R;
import com.github.rubensousa.previewseekbar.sample.glide.GlideThumbnailTransformation;
import com.github.rubensousa.previewseekbar.media3.PreviewTimeBar;

@OptIn(markerClass = UnstableApi.class)
public class ExoPlayerManager implements PreviewLoader, PreviewBar.OnScrubListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.rubensousa.previewseekbar.sample.glide;
package com.github.rubensousa.previewseekbar.sample;

import android.graphics.Bitmap;
import androidx.annotation.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.github.rubensousa.previewseekbar.sample;

import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
Expand All @@ -34,8 +33,7 @@
import com.github.rubensousa.previewseekbar.PreviewSeekBar;
import com.github.rubensousa.previewseekbar.animator.PreviewFadeAnimator;
import com.github.rubensousa.previewseekbar.animator.PreviewMorphAnimator;
import com.github.rubensousa.previewseekbar.exoplayer.PreviewTimeBar;
import com.github.rubensousa.previewseekbar.sample.exoplayer.ExoPlayerManager;
import com.github.rubensousa.previewseekbar.media3.PreviewTimeBar;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -145,7 +143,7 @@ private void setupOptions() {
if (checkedId == R.id.fadeAnimationRadioButton) {
previewTimeBar.setPreviewAnimator(new PreviewFadeAnimator());
previewSeekBar.setPreviewAnimator(new PreviewFadeAnimator());
} else if (Build.VERSION.SDK_INT >= 21) {
} else {
previewTimeBar.setPreviewAnimator(new PreviewMorphAnimator());
previewSeekBar.setPreviewAnimator(new PreviewMorphAnimator());
}
Expand Down
20 changes: 3 additions & 17 deletions sample/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
android:background="@android:color/black"
tools:context="com.github.rubensousa.previewseekbar.sample.MainActivity">


<com.google.android.exoplayer2.ui.StyledPlayerView
<androidx.media3.ui.PlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:controller_layout_id="@layout/exoplayer_controls" />
app:controller_layout_id="@layout/exoplayer_controls"
app:layout_constraintTop_toBottomOf="@id/timeBarSampleTextView" />

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
Expand Down Expand Up @@ -67,18 +67,4 @@

</androidx.core.widget.NestedScrollView>

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/app_name" />

</com.google.android.material.appbar.AppBarLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading

0 comments on commit cfd1ade

Please sign in to comment.