diff --git a/build.gradle b/build.gradle index a9bc046..8145dd4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,19 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.10' + ext.kotlin_version = '1.5.31' + ext.exo_player_version = '2.15.1' + ext.app_compat_version = '1.3.1' + ext.constraint_layout_version = '2.1.1' + ext.glide_version = '4.12.0' + repositories { google() - jcenter() + mavenCentral() } + dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:4.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong @@ -18,7 +24,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/gpuv/build.gradle b/gpuv/build.gradle index 6e39dc1..f605bec 100644 --- a/gpuv/build.gradle +++ b/gpuv/build.gradle @@ -23,6 +23,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - compileOnly 'com.google.android.exoplayer:exoplayer-core:2.9.3' + compileOnly "com.google.android.exoplayer:exoplayer-core:$exo_player_version" } diff --git a/gpuv/src/main/java/com/daasuu/gpuv/player/GPUPlayerRenderer.java b/gpuv/src/main/java/com/daasuu/gpuv/player/GPUPlayerRenderer.java index 8ff983e..afc6977 100644 --- a/gpuv/src/main/java/com/daasuu/gpuv/player/GPUPlayerRenderer.java +++ b/gpuv/src/main/java/com/daasuu/gpuv/player/GPUPlayerRenderer.java @@ -3,6 +3,8 @@ import android.graphics.SurfaceTexture; import android.opengl.GLES20; import android.opengl.Matrix; +import android.os.Handler; +import android.os.Looper; import android.util.Log; import android.view.Surface; import com.daasuu.gpuv.egl.*; @@ -41,11 +43,13 @@ public class GPUPlayerRenderer extends GlFrameBufferObjectRenderer implements Su private float aspectRatio = 1f; private SimpleExoPlayer simpleExoPlayer; + private Handler uiHandler; GPUPlayerRenderer(GPUPlayerView glPreview) { super(); Matrix.setIdentityM(STMatrix, 0); this.glPreview = glPreview; + this.uiHandler = new Handler(Looper.getMainLooper()); } void setGlFilter(final GlFilter filter) { @@ -91,7 +95,7 @@ public void onSurfaceCreated(final EGLConfig config) { previewFilter.setup(); Surface surface = new Surface(previewTexture.getSurfaceTexture()); - this.simpleExoPlayer.setVideoSurface(surface); + uiHandler.post(() -> simpleExoPlayer.setVideoSurface(surface)); Matrix.setLookAtM(VMatrix, 0, 0.0f, 0.0f, 5.0f, diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9a4163a..1f3fdbc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sample/build.gradle b/sample/build.gradle index 566c1bf..4fee2d5 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -27,17 +27,17 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0-alpha01' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "androidx.appcompat:appcompat:$app_compat_version" + implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version" + implementation "com.google.android.exoplayer:exoplayer-core:$exo_player_version" + implementation "com.github.bumptech.glide:glide:$glide_version" - implementation 'com.google.android.exoplayer:exoplayer-core:2.9.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' - implementation 'com.github.bumptech.glide:glide:4.8.0' implementation project(':gpuv') } diff --git a/sample/src/main/java/com/daasuu/gpuvideoandroid/PlayerActivity.java b/sample/src/main/java/com/daasuu/gpuvideoandroid/PlayerActivity.java index 33cd08e..021eee9 100644 --- a/sample/src/main/java/com/daasuu/gpuvideoandroid/PlayerActivity.java +++ b/sample/src/main/java/com/daasuu/gpuvideoandroid/PlayerActivity.java @@ -4,31 +4,29 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import androidx.appcompat.app.AppCompatActivity; import android.view.View; import android.view.ViewGroup; -import android.widget.*; +import android.widget.AdapterView; +import android.widget.Button; +import android.widget.ListView; +import android.widget.RelativeLayout; +import android.widget.SeekBar; + +import androidx.appcompat.app.AppCompatActivity; import com.daasuu.gpuv.egl.filter.GlFilter; import com.daasuu.gpuv.player.GPUPlayerView; import com.daasuu.gpuvideoandroid.widget.MovieWrapperView; import com.daasuu.gpuvideoandroid.widget.PlayerTimer; -import com.google.android.exoplayer2.ExoPlayerFactory; +import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.SimpleExoPlayer; -import com.google.android.exoplayer2.source.ExtractorMediaSource; -import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; -import com.google.android.exoplayer2.trackselection.TrackSelector; -import com.google.android.exoplayer2.upstream.DataSource; -import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; -import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; -import com.google.android.exoplayer2.util.Util; import java.util.List; public class PlayerActivity extends AppCompatActivity { - private static final String STREAM_URL_MP4_VOD_LONG = "https://www.radiantmediaplayer.com/media/bbb-360p.mp4"; + private static final String STREAM_URL_MP4_VOD_LONG = "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4"; public static void startActivity(Activity activity) { Intent intent = new Intent(activity, PlayerActivity.class); @@ -152,21 +150,14 @@ public void onItemClick(AdapterView parent, View view, int position, long id) private void setUpSimpleExoPlayer() { - - TrackSelector trackSelector = new DefaultTrackSelector(); - - // Measures bandwidth during playback. Can be null if not required. - DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter(); - // Produces DataSource instances through which media data is loaded. - DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "yourApplicationName"), defaultBandwidthMeter); - MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(STREAM_URL_MP4_VOD_LONG)); - // SimpleExoPlayer - player = ExoPlayerFactory.newSimpleInstance(this, trackSelector); - // Prepare the player with the source. - player.prepare(mediaSource); - player.setPlayWhenReady(true); + player = new SimpleExoPlayer.Builder(this) + .setTrackSelector(new DefaultTrackSelector(this)) + .build(); + player.addMediaItem(MediaItem.fromUri(Uri.parse(STREAM_URL_MP4_VOD_LONG))); + player.prepare(); + player.setPlayWhenReady(true); }