Skip to content

Commit bb6cd5d

Browse files
author
kifio
committed
Update ExoPlayer and other dependencies; Dependencies refactoring;
1 parent 8174141 commit bb6cd5d

6 files changed

Lines changed: 37 additions & 36 deletions

File tree

build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.10'
4+
ext.kotlin_version = '1.5.31'
5+
ext.exo_player_version = '2.15.1'
6+
ext.app_compat_version = '1.3.1'
7+
ext.constraint_layout_version = '2.1.1'
8+
ext.glide_version = '4.12.0'
9+
510
repositories {
611
google()
7-
jcenter()
12+
mavenCentral()
813
}
14+
915
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.2.1'
16+
classpath 'com.android.tools.build:gradle:4.2.2'
1117
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1218

1319
// NOTE: Do not place your application dependencies here; they belong
@@ -18,7 +24,7 @@ buildscript {
1824
allprojects {
1925
repositories {
2026
google()
21-
jcenter()
27+
mavenCentral()
2228
}
2329
}
2430

gpuv/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ android {
2323
dependencies {
2424
implementation fileTree(dir: 'libs', include: ['*.jar'])
2525

26-
compileOnly 'com.google.android.exoplayer:exoplayer-core:2.9.3'
26+
compileOnly "com.google.android.exoplayer:exoplayer-core:$exo_player_version"
2727

2828
}

gpuv/src/main/java/com/daasuu/gpuv/player/GPUPlayerRenderer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.graphics.SurfaceTexture;
44
import android.opengl.GLES20;
55
import android.opengl.Matrix;
6+
import android.os.Handler;
7+
import android.os.Looper;
68
import android.util.Log;
79
import android.view.Surface;
810
import com.daasuu.gpuv.egl.*;
@@ -41,11 +43,13 @@ public class GPUPlayerRenderer extends GlFrameBufferObjectRenderer implements Su
4143
private float aspectRatio = 1f;
4244

4345
private SimpleExoPlayer simpleExoPlayer;
46+
private Handler uiHandler;
4447

4548
GPUPlayerRenderer(GPUPlayerView glPreview) {
4649
super();
4750
Matrix.setIdentityM(STMatrix, 0);
4851
this.glPreview = glPreview;
52+
this.uiHandler = new Handler(Looper.getMainLooper());
4953
}
5054

5155
void setGlFilter(final GlFilter filter) {
@@ -91,7 +95,7 @@ public void onSurfaceCreated(final EGLConfig config) {
9195
previewFilter.setup();
9296

9397
Surface surface = new Surface(previewTexture.getSurfaceTexture());
94-
this.simpleExoPlayer.setVideoSurface(surface);
98+
uiHandler.post(() -> simpleExoPlayer.setVideoSurface(surface));
9599

96100
Matrix.setLookAtM(VMatrix, 0,
97101
0.0f, 0.0f, 5.0f,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

sample/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ android {
2727

2828
dependencies {
2929
implementation fileTree(dir: 'libs', include: ['*.jar'])
30-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31-
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
32-
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
30+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
31+
implementation "androidx.appcompat:appcompat:$app_compat_version"
32+
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
33+
implementation "com.google.android.exoplayer:exoplayer-core:$exo_player_version"
34+
implementation "com.github.bumptech.glide:glide:$glide_version"
3335

34-
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.3'
3536
testImplementation 'junit:junit:4.12'
3637
androidTestImplementation 'androidx.test:runner:1.1.1'
3738
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
3839

3940

40-
implementation 'com.github.bumptech.glide:glide:4.8.0'
4141

4242
implementation project(':gpuv')
4343
}

sample/src/main/java/com/daasuu/gpuvideoandroid/PlayerActivity.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,29 @@
44
import android.content.Intent;
55
import android.net.Uri;
66
import android.os.Bundle;
7-
import androidx.appcompat.app.AppCompatActivity;
87
import android.view.View;
98
import android.view.ViewGroup;
10-
import android.widget.*;
9+
import android.widget.AdapterView;
10+
import android.widget.Button;
11+
import android.widget.ListView;
12+
import android.widget.RelativeLayout;
13+
import android.widget.SeekBar;
14+
15+
import androidx.appcompat.app.AppCompatActivity;
1116

1217
import com.daasuu.gpuv.egl.filter.GlFilter;
1318
import com.daasuu.gpuv.player.GPUPlayerView;
1419
import com.daasuu.gpuvideoandroid.widget.MovieWrapperView;
1520
import com.daasuu.gpuvideoandroid.widget.PlayerTimer;
16-
import com.google.android.exoplayer2.ExoPlayerFactory;
21+
import com.google.android.exoplayer2.MediaItem;
1722
import com.google.android.exoplayer2.SimpleExoPlayer;
18-
import com.google.android.exoplayer2.source.ExtractorMediaSource;
19-
import com.google.android.exoplayer2.source.MediaSource;
2023
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
21-
import com.google.android.exoplayer2.trackselection.TrackSelector;
22-
import com.google.android.exoplayer2.upstream.DataSource;
23-
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
24-
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
25-
import com.google.android.exoplayer2.util.Util;
2624

2725
import java.util.List;
2826

2927
public class PlayerActivity extends AppCompatActivity {
3028

31-
private static final String STREAM_URL_MP4_VOD_LONG = "https://www.radiantmediaplayer.com/media/bbb-360p.mp4";
29+
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";
3230

3331
public static void startActivity(Activity activity) {
3432
Intent intent = new Intent(activity, PlayerActivity.class);
@@ -152,21 +150,14 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
152150

153151

154152
private void setUpSimpleExoPlayer() {
155-
156-
TrackSelector trackSelector = new DefaultTrackSelector();
157-
158-
// Measures bandwidth during playback. Can be null if not required.
159-
DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();
160-
// Produces DataSource instances through which media data is loaded.
161-
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "yourApplicationName"), defaultBandwidthMeter);
162-
MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(STREAM_URL_MP4_VOD_LONG));
163-
164153
// SimpleExoPlayer
165-
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
166-
// Prepare the player with the source.
167-
player.prepare(mediaSource);
168-
player.setPlayWhenReady(true);
154+
player = new SimpleExoPlayer.Builder(this)
155+
.setTrackSelector(new DefaultTrackSelector(this))
156+
.build();
169157

158+
player.addMediaItem(MediaItem.fromUri(Uri.parse(STREAM_URL_MP4_VOD_LONG)));
159+
player.prepare();
160+
player.setPlayWhenReady(true);
170161
}
171162

172163

0 commit comments

Comments
 (0)