Fix some Media3 deprecations (#6980)

This commit is contained in:
Taco 2024-03-10 01:59:53 -05:00 committed by GitHub
parent f1fe1b573f
commit b18e5f0de6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 9 deletions

View File

@ -15,6 +15,7 @@ project.ext {
coreVersion = "1.8.0" coreVersion = "1.8.0"
fragmentVersion = "1.5.5" fragmentVersion = "1.5.5"
mediaVersion = "1.6.0" mediaVersion = "1.6.0"
media3Version = "1.1.1"
paletteVersion = "1.0.0" paletteVersion = "1.0.0"
preferenceVersion = "1.1.1" preferenceVersion = "1.1.1"
recyclerViewVersion = "1.2.1" recyclerViewVersion = "1.2.1"
@ -33,7 +34,6 @@ 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 = "1.1.1"
// Google Play build // Google Play build
wearableSupportVersion = "2.6.0" wearableSupportVersion = "2.6.0"

View File

@ -48,6 +48,9 @@ dependencies {
implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.documentfile:documentfile:1.0.1'
implementation "androidx.fragment:fragment:$fragmentVersion" implementation "androidx.fragment:fragment:$fragmentVersion"
implementation "androidx.media:media:$mediaVersion" implementation "androidx.media:media:$mediaVersion"
implementation "androidx.media3:media3-datasource-okhttp:$media3Version"
implementation "androidx.media3:media3-exoplayer:$media3Version"
implementation "androidx.media3:media3-ui:$media3Version"
implementation "androidx.preference:preference:$preferenceVersion" implementation "androidx.preference:preference:$preferenceVersion"
implementation "androidx.work:work-runtime:$workManagerVersion" implementation "androidx.work:work-runtime:$workManagerVersion"
implementation "com.google.android.material:material:$googleMaterialVersion" implementation "com.google.android.material:material:$googleMaterialVersion"
@ -65,10 +68,6 @@ dependencies {
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "com.annimon:stream:$annimonStreamVersion" implementation "com.annimon:stream:$annimonStreamVersion"
implementation "androidx.media3:media3-exoplayer:$exoPlayerVersion"
implementation "androidx.media3:media3-ui:$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"
compileOnly "com.google.android.wearable:wearable:$wearableSupportVersion" compileOnly "com.google.android.wearable:wearable:$wearableSupportVersion"

View File

@ -13,9 +13,9 @@ import androidx.core.util.Consumer;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.PlaybackException; import androidx.media3.common.PlaybackException;
import androidx.media3.database.ExoDatabaseProvider; import androidx.media3.database.StandaloneDatabaseProvider;
import androidx.media3.datasource.DataSource; import androidx.media3.datasource.DataSource;
import androidx.media3.datasource.DefaultDataSourceFactory; import androidx.media3.datasource.DefaultDataSource;
import androidx.media3.datasource.HttpDataSource; import androidx.media3.datasource.HttpDataSource;
import androidx.media3.datasource.cache.CacheDataSource; import androidx.media3.datasource.cache.CacheDataSource;
import androidx.media3.datasource.cache.LeastRecentlyUsedCacheEvictor; import androidx.media3.datasource.cache.LeastRecentlyUsedCacheEvictor;
@ -153,7 +153,7 @@ public class ExoPlayerWrapper {
} }
}); });
simpleCache = new SimpleCache(new File(context.getCacheDir(), "streaming"), simpleCache = new SimpleCache(new File(context.getCacheDir(), "streaming"),
new LeastRecentlyUsedCacheEvictor(50 * 1024 * 1024), new ExoDatabaseProvider(context)); new LeastRecentlyUsedCacheEvictor(50 * 1024 * 1024), new StandaloneDatabaseProvider(context));
initLoudnessEnhancer(exoPlayer.getAudioSessionId()); initLoudnessEnhancer(exoPlayer.getAudioSessionId());
} }
@ -244,7 +244,7 @@ public class ExoPlayerWrapper {
); );
httpDataSourceFactory.setDefaultRequestProperties(requestProperties); httpDataSourceFactory.setDefaultRequestProperties(requestProperties);
} }
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, null, httpDataSourceFactory); DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context, httpDataSourceFactory);
if (s.startsWith("http")) { if (s.startsWith("http")) {
dataSourceFactory = new CacheDataSource.Factory() dataSourceFactory = new CacheDataSource.Factory()
.setCache(simpleCache) .setCache(simpleCache)