Upgrade ExoPlayer to media3 version (#6971)
This commit is contained in:
parent
39e2d6e230
commit
755ccc42ec
|
@ -34,7 +34,7 @@ project.ext {
|
||||||
rxJavaVersion = "2.2.2"
|
rxJavaVersion = "2.2.2"
|
||||||
iconifyVersion = "2.2.2"
|
iconifyVersion = "2.2.2"
|
||||||
annimonStreamVersion = "1.2.2"
|
annimonStreamVersion = "1.2.2"
|
||||||
exoPlayerVersion = "2.14.2"
|
exoPlayerVersion = "1.1.1"
|
||||||
|
|
||||||
// Google Play build
|
// Google Play build
|
||||||
wearableSupportVersion = "2.6.0"
|
wearableSupportVersion = "2.6.0"
|
||||||
|
|
|
@ -66,9 +66,9 @@ dependencies {
|
||||||
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
|
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
|
||||||
implementation "com.annimon:stream:$annimonStreamVersion"
|
implementation "com.annimon:stream:$annimonStreamVersion"
|
||||||
|
|
||||||
implementation "com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion"
|
implementation "androidx.media3:media3-exoplayer:$exoPlayerVersion"
|
||||||
implementation "com.google.android.exoplayer:exoplayer-ui:$exoPlayerVersion"
|
implementation "androidx.media3:media3-ui:$exoPlayerVersion"
|
||||||
implementation "com.google.android.exoplayer:extension-okhttp:$exoPlayerVersion"
|
implementation "androidx.media3:media3-datasource-okhttp:$exoPlayerVersion"
|
||||||
|
|
||||||
// Non-free dependencies:
|
// Non-free dependencies:
|
||||||
playApi "com.google.android.support:wearable:$wearableSupportVersion"
|
playApi "com.google.android.support:wearable:$wearableSupportVersion"
|
||||||
|
|
|
@ -11,38 +11,37 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.util.Consumer;
|
import androidx.core.util.Consumer;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import androidx.media3.common.C;
|
||||||
import com.google.android.exoplayer2.DefaultLoadControl;
|
import androidx.media3.common.PlaybackException;
|
||||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
import androidx.media3.database.ExoDatabaseProvider;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import androidx.media3.datasource.DataSource;
|
||||||
import com.google.android.exoplayer2.Format;
|
import androidx.media3.datasource.DefaultDataSourceFactory;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import androidx.media3.datasource.HttpDataSource;
|
||||||
import com.google.android.exoplayer2.PlaybackParameters;
|
import androidx.media3.datasource.cache.CacheDataSource;
|
||||||
import com.google.android.exoplayer2.Player;
|
import androidx.media3.datasource.cache.LeastRecentlyUsedCacheEvictor;
|
||||||
import com.google.android.exoplayer2.SeekParameters;
|
import androidx.media3.datasource.cache.SimpleCache;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import androidx.media3.datasource.okhttp.OkHttpDataSource;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import androidx.media3.exoplayer.DefaultLoadControl;
|
||||||
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
|
import androidx.media3.exoplayer.DefaultRenderersFactory;
|
||||||
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource;
|
import androidx.media3.common.Format;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import androidx.media3.common.MediaItem;
|
||||||
import com.google.android.exoplayer2.extractor.mp3.Mp3Extractor;
|
import androidx.media3.common.PlaybackParameters;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import androidx.media3.common.Player;
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
import androidx.media3.exoplayer.SeekParameters;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import androidx.media3.common.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
import androidx.media3.exoplayer.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
|
import androidx.media3.exoplayer.source.ProgressiveMediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import androidx.media3.exoplayer.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.ui.DefaultTrackNameProvider;
|
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.ui.TrackNameProvider;
|
import androidx.media3.exoplayer.trackselection.ExoTrackSelection;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import androidx.media3.exoplayer.trackselection.MappingTrackSelector;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
import androidx.media3.exoplayer.trackselection.TrackSelectionArray;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.upstream.HttpDataSource;
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
|
||||||
|
|
||||||
|
import androidx.media3.extractor.DefaultExtractorsFactory;
|
||||||
|
import androidx.media3.extractor.mp3.Mp3Extractor;
|
||||||
|
import androidx.media3.ui.DefaultTrackNameProvider;
|
||||||
|
import androidx.media3.ui.TrackNameProvider;
|
||||||
import de.danoeh.antennapod.core.ClientConfig;
|
import de.danoeh.antennapod.core.ClientConfig;
|
||||||
import de.danoeh.antennapod.core.R;
|
import de.danoeh.antennapod.core.R;
|
||||||
import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
|
import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
|
||||||
|
@ -69,7 +68,7 @@ public class ExoPlayerWrapper {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final Disposable bufferingUpdateDisposable;
|
private final Disposable bufferingUpdateDisposable;
|
||||||
private SimpleExoPlayer exoPlayer;
|
private ExoPlayer exoPlayer;
|
||||||
private MediaSource mediaSource;
|
private MediaSource mediaSource;
|
||||||
private Runnable audioSeekCompleteListener;
|
private Runnable audioSeekCompleteListener;
|
||||||
private Runnable audioCompletionListener;
|
private Runnable audioCompletionListener;
|
||||||
|
@ -101,7 +100,7 @@ public class ExoPlayerWrapper {
|
||||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS);
|
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS);
|
||||||
loadControl.setBackBuffer(UserPreferences.getRewindSecs() * 1000 + 500, true);
|
loadControl.setBackBuffer(UserPreferences.getRewindSecs() * 1000 + 500, true);
|
||||||
trackSelector = new DefaultTrackSelector(context);
|
trackSelector = new DefaultTrackSelector(context);
|
||||||
exoPlayer = new SimpleExoPlayer.Builder(context, new DefaultRenderersFactory(context))
|
exoPlayer = new ExoPlayer.Builder(context, new DefaultRenderersFactory(context))
|
||||||
.setTrackSelector(trackSelector)
|
.setTrackSelector(trackSelector)
|
||||||
.setLoadControl(loadControl.build())
|
.setLoadControl(loadControl.build())
|
||||||
.build();
|
.build();
|
||||||
|
@ -119,7 +118,7 @@ public class ExoPlayerWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerError(@NonNull ExoPlaybackException error) {
|
public void onPlayerError(@NonNull PlaybackException error) {
|
||||||
if (audioErrorListener != null) {
|
if (audioErrorListener != null) {
|
||||||
if (NetworkUtils.wasDownloadBlocked(error)) {
|
if (NetworkUtils.wasDownloadBlocked(error)) {
|
||||||
audioErrorListener.accept(context.getString(R.string.download_error_blocked));
|
audioErrorListener.accept(context.getString(R.string.download_error_blocked));
|
||||||
|
@ -233,7 +232,7 @@ public class ExoPlayerWrapper {
|
||||||
throws IllegalArgumentException, IllegalStateException {
|
throws IllegalArgumentException, IllegalStateException {
|
||||||
Log.d(TAG, "setDataSource: " + s);
|
Log.d(TAG, "setDataSource: " + s);
|
||||||
final OkHttpDataSource.Factory httpDataSourceFactory =
|
final OkHttpDataSource.Factory httpDataSourceFactory =
|
||||||
new OkHttpDataSource.Factory(AntennapodHttpClient.getHttpClient())
|
new OkHttpDataSource.Factory((okhttp3.Call.Factory) AntennapodHttpClient.getHttpClient())
|
||||||
.setUserAgent(ClientConfig.USER_AGENT);
|
.setUserAgent(ClientConfig.USER_AGENT);
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(user) && !TextUtils.isEmpty(password)) {
|
if (!TextUtils.isEmpty(user) && !TextUtils.isEmpty(password)) {
|
||||||
|
@ -326,8 +325,8 @@ public class ExoPlayerWrapper {
|
||||||
}
|
}
|
||||||
TrackGroupArray trackGroups = trackInfo.getTrackGroups(getAudioRendererIndex());
|
TrackGroupArray trackGroups = trackInfo.getTrackGroups(getAudioRendererIndex());
|
||||||
DefaultTrackSelector.SelectionOverride override = new DefaultTrackSelector.SelectionOverride(track, 0);
|
DefaultTrackSelector.SelectionOverride override = new DefaultTrackSelector.SelectionOverride(track, 0);
|
||||||
DefaultTrackSelector.ParametersBuilder params = trackSelector.buildUponParameters()
|
DefaultTrackSelector.Parameters params = trackSelector.buildUponParameters()
|
||||||
.setSelectionOverride(getAudioRendererIndex(), trackGroups, override);
|
.setSelectionOverride(getAudioRendererIndex(), trackGroups, override).build();
|
||||||
trackSelector.setParameters(params);
|
trackSelector.setParameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package de.danoeh.antennapod.core.util.download;
|
package de.danoeh.antennapod.core.util.download;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import com.google.android.exoplayer2.util.Log;
|
import android.util.Log;
|
||||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||||
|
|
||||||
public abstract class NetworkConnectionChangeHandler {
|
public abstract class NetworkConnectionChangeHandler {
|
||||||
private static final String TAG = "NetworkConnectionChangeHandler";
|
private static final String TAG = "NetConnChangeHandler";
|
||||||
private static Context context;
|
private static Context context;
|
||||||
|
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
|
|
Loading…
Reference in New Issue