Skip to content

Commit

Permalink
Merge pull request #86 from kifio/Update_ExoPlayer_To_Actual_Version
Browse files Browse the repository at this point in the history
Update ExoPlayer and other dependencies; Dependencies refactoring;
  • Loading branch information
MasayukiSuda authored Sep 27, 2021
2 parents 8174141 + bb6cd5d commit ec42066
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 36 deletions.
14 changes: 10 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +24,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gpuv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
39 changes: 15 additions & 24 deletions sample/src/main/java/com/daasuu/gpuvideoandroid/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit ec42066

Please sign in to comment.