Skip to content

Commit

Permalink
Remove Exoplayer deprecations
Browse files Browse the repository at this point in the history
- Bump Exoplayer to 2.10.4
- Remove deprecated usages of Exoplayer methdos
- Add `ReactExoplayerConfig` as extension points to configure the Exoplayer instance
  • Loading branch information
Benoit Dion authored and benoitdion committed Sep 23, 2019
1 parent 81cfd4e commit 3e38f88
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 83 deletions.
14 changes: 7 additions & 7 deletions android-exoplayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def safeExtGet(prop, fallback) {
android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -23,18 +23,18 @@ android {

dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation('com.google.android.exoplayer:exoplayer:2.9.3') {
implementation('com.google.android.exoplayer:exoplayer:2.10.4') {
exclude group: 'com.android.support'
}

// All support libs must use the same version
implementation "androidx.annotation:annotation:1.0.0"
implementation "androidx.core:core:1.0.0"
implementation "androidx.media:media:1.0.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.core:core:1.1.0"
implementation "androidx.media:media:1.1.0"

implementation('com.google.android.exoplayer:extension-okhttp:2.9.3') {
implementation('com.google.android.exoplayer:extension-okhttp:2.10.4') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.squareup.okhttp3:okhttp:3.14.3'

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.brentvatne.exoplayer;

import android.content.Context;
import android.content.ContextWrapper;

import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.CookieJarContainer;
import com.facebook.react.modules.network.ForwardingCookieHandler;
Expand All @@ -14,12 +11,10 @@
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.util.Util;

import okhttp3.Cookie;
import okhttp3.JavaNetCookieJar;
import okhttp3.OkHttpClient;
import java.util.Map;


public class DataSourceUtil {

private DataSourceUtil() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.brentvatne.exoplayer;

import android.content.Context;

import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;

public class DefaultReactExoplayerConfig implements ReactExoplayerConfig {

private final DefaultBandwidthMeter bandwidthMeter;

public DefaultReactExoplayerConfig(Context context) {
this.bandwidthMeter = new DefaultBandwidthMeter.Builder(context).build();
}

@Override
public LoadErrorHandlingPolicy buildLoadErrorHandlingPolicy(int minLoadRetryCount) {
return new DefaultLoadErrorHandlingPolicy(minLoadRetryCount);
}

@Override
public DefaultBandwidthMeter getBandwidthMeter() {
return bandwidthMeter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class RawResourceDataSourceFactory implements DataSource.Factory {

@Override
public DataSource createDataSource() {
return new RawResourceDataSource(context, null);
return new RawResourceDataSource(context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.brentvatne.exoplayer;

import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;

/**
* Extension points to configure the Exoplayer instance
*/
public interface ReactExoplayerConfig {
LoadErrorHandlingPolicy buildLoadErrorHandlingPolicy(int minLoadRetryCount);

DefaultBandwidthMeter getBandwidthMeter();
}
Loading

0 comments on commit 3e38f88

Please sign in to comment.