Skip to content

Commit

Permalink
actions: bump com.google.android.exoplayer:exoplayer to 2.19.1 (fixes
Browse files Browse the repository at this point in the history
open-learning-exchange#2975) (open-learning-exchange#2967)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gideon Okuro <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2024
1 parent 23643d7 commit 1366b21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1272
versionName "0.12.72"
versionCode 1273
versionName "0.12.73"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -121,7 +121,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.16.0'
kapt 'com.github.bumptech.glide:compiler:4.16.0'
implementation 'com.opencsv:opencsv:5.9'
implementation 'com.google.android.exoplayer:exoplayer:2.12.1'
implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'org.osmdroid:osmdroid-android:6.1.18'
implementation 'com.github.clans:fab:1.6.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
import androidx.appcompat.app.AppCompatActivity;

import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
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.DataSpec;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.FileDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.gson.Gson;
Expand All @@ -30,6 +28,7 @@
import org.ole.planet.myplanet.utilities.AuthSessionUpdater;
import org.ole.planet.myplanet.utilities.Utilities;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -76,14 +75,20 @@ public void onError(String s) {
}

public void streamVideoFromUrl(String videoUrl, String auth) {
TrackSelector trackSelectorDef = new DefaultTrackSelector();
exoPlayer= ExoPlayerFactory.newSimpleInstance(this, trackSelectorDef);
TrackSelector trackSelectorDef = new DefaultTrackSelector(this);
exoPlayer = new SimpleExoPlayer.Builder(this).setTrackSelector(trackSelectorDef).build();

Uri videoUri = Uri.parse(videoUrl);

HttpDataSource.Factory defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory("ExoPlayer", null);
defaultHttpDataSourceFactory.setDefaultRequestProperty("Cookie", auth);
MediaSource mediaSource = new ProgressiveMediaSource.Factory(defaultHttpDataSourceFactory).createMediaSource(videoUri);
Map<String, String> requestProperties = new HashMap<>();
requestProperties.put("Cookie", auth);

HttpDataSource.Factory defaultHttpDataSourceFactory = new DefaultHttpDataSource.Factory()
.setUserAgent("ExoPlayer")
.setAllowCrossProtocolRedirects(true)
.setDefaultRequestProperties(requestProperties);

MediaSource mediaSource = new ProgressiveMediaSource.Factory(defaultHttpDataSourceFactory).createMediaSource(MediaItem.fromUri(videoUri));

activityExoPlayerVideoBinding.exoPlayerSimple.setPlayer(exoPlayer);
exoPlayer.prepare(mediaSource);
Expand All @@ -92,7 +97,10 @@ public void streamVideoFromUrl(String videoUrl, String auth) {

public void prepareExoPlayerFromFileUri(String uristring) {
Uri uri = Uri.parse(uristring);
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, new DefaultTrackSelector(), new DefaultLoadControl());
exoPlayer = new SimpleExoPlayer.Builder(this)
.setTrackSelector(new DefaultTrackSelector(this))
.setLoadControl(new DefaultLoadControl())
.build();

DataSpec dataSpec = new DataSpec(uri);
final FileDataSource fileDataSource = new FileDataSource();
Expand All @@ -103,7 +111,7 @@ public void prepareExoPlayerFromFileUri(String uristring) {
}

DataSource.Factory factory = () -> fileDataSource;
MediaSource audioSource = new ExtractorMediaSource(fileDataSource.getUri(), factory, new DefaultExtractorsFactory(), null, null);
MediaSource audioSource = new ProgressiveMediaSource.Factory(factory).createMediaSource(MediaItem.fromUri(fileDataSource.getUri()));

activityExoPlayerVideoBinding.exoPlayerSimple.setPlayer(exoPlayer);
exoPlayer.prepare(audioSource);
Expand Down

0 comments on commit 1366b21

Please sign in to comment.