From 87eab2a9b0f0b17bc078c0f37a452fe51b7a6243 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 7 Oct 2019 09:41:44 +0200 Subject: [PATCH] Fixed deprecations --- .../main/java/org/schabi/newpipe/player/BasePlayer.java | 7 ++++--- .../org/schabi/newpipe/player/helper/CacheFactory.java | 6 ++++-- .../schabi/newpipe/player/helper/PlayerDataSource.java | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 71a8ae7b1..4f7ae4e2c 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -28,12 +28,13 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.AudioManager; import android.preference.PreferenceManager; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.util.Log; import android.view.View; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayerFactory; @@ -209,7 +210,7 @@ public abstract class BasePlayer implements this.databaseUpdateReactor = new CompositeDisposable(); final String userAgent = Downloader.USER_AGENT; - final DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); + final DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter.Builder(context).build(); this.dataSource = new PlayerDataSource(context, userAgent, bandwidthMeter); final TrackSelection.Factory trackSelectionFactory = PlayerHelper.getQualitySelector(context); diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/CacheFactory.java b/app/src/main/java/org/schabi/newpipe/player/helper/CacheFactory.java index 605228099..8160640cb 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/CacheFactory.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/CacheFactory.java @@ -1,9 +1,11 @@ package org.schabi.newpipe.player.helper; import android.content.Context; -import androidx.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; + +import com.google.android.exoplayer2.database.ExoDatabaseProvider; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; @@ -54,7 +56,7 @@ import java.io.File; if (cache == null) { final LeastRecentlyUsedCacheEvictor evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize); - cache = new SimpleCache(cacheDir, evictor); + cache = new SimpleCache(cacheDir, evictor, new ExoDatabaseProvider(context)); } } diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java index 4602e83b8..5aa331dc5 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java @@ -1,9 +1,10 @@ package org.schabi.newpipe.player.helper; import android.content.Context; + import androidx.annotation.NonNull; -import com.google.android.exoplayer2.source.ExtractorMediaSource; +import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.SingleSampleMediaSource; import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource; @@ -64,12 +65,12 @@ public class PlayerDataSource { cacheDataSourceFactory), cacheDataSourceFactory); } - public ExtractorMediaSource.Factory getExtractorMediaSourceFactory() { - return new ExtractorMediaSource.Factory(cacheDataSourceFactory) + public ProgressiveMediaSource.Factory getExtractorMediaSourceFactory() { + return new ProgressiveMediaSource.Factory(cacheDataSourceFactory) .setLoadErrorHandlingPolicy(new DefaultLoadErrorHandlingPolicy(EXTRACTOR_MINIMUM_RETRY)); } - public ExtractorMediaSource.Factory getExtractorMediaSourceFactory(@NonNull final String key) { + public ProgressiveMediaSource.Factory getExtractorMediaSourceFactory(@NonNull final String key) { return getExtractorMediaSourceFactory().setCustomCacheKey(key); }