[Video_player] Upgraded to exoPlayer 2.17.0 (#5011)
diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md
index 774589c..1f0f06f 100644
--- a/packages/video_player/video_player_android/CHANGELOG.md
+++ b/packages/video_player/video_player_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.3.2
+
+* Updates ExoPlayer to 2.17.0.
+
## 2.3.1
* Renames internal method channels to avoid potential confusion with the
diff --git a/packages/video_player/video_player_android/android/build.gradle b/packages/video_player/video_player_android/android/build.gradle
index 6e6e8c7..e565a93 100644
--- a/packages/video_player/video_player_android/android/build.gradle
+++ b/packages/video_player/video_player_android/android/build.gradle
@@ -43,10 +43,10 @@
}
dependencies {
- implementation 'com.google.android.exoplayer:exoplayer-core:2.14.1'
- implementation 'com.google.android.exoplayer:exoplayer-hls:2.14.1'
- implementation 'com.google.android.exoplayer:exoplayer-dash:2.14.1'
- implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.14.1'
+ implementation 'com.google.android.exoplayer:exoplayer-core:2.17.0'
+ implementation 'com.google.android.exoplayer:exoplayer-hls:2.17.0'
+ implementation 'com.google.android.exoplayer:exoplayer-dash:2.17.0'
+ implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.17.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-inline:3.9.0'
}
diff --git a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
index 3359326..dc7c881 100644
--- a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
+++ b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
@@ -12,13 +12,13 @@
import android.view.Surface;
import androidx.annotation.NonNull;
import com.google.android.exoplayer2.C;
-import com.google.android.exoplayer2.ExoPlaybackException;
+import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaItem;
+import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.Listener;
-import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
@@ -28,7 +28,7 @@
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
-import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
+import com.google.android.exoplayer2.upstream.DefaultDataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.util.Util;
import io.flutter.plugin.common.EventChannel;
@@ -45,7 +45,7 @@
private static final String FORMAT_HLS = "hls";
private static final String FORMAT_OTHER = "other";
- private SimpleExoPlayer exoPlayer;
+ private ExoPlayer exoPlayer;
private Surface surface;
@@ -71,10 +71,9 @@
this.textureEntry = textureEntry;
this.options = options;
- exoPlayer = new SimpleExoPlayer.Builder(context).build();
+ exoPlayer = new ExoPlayer.Builder(context).build();
Uri uri = Uri.parse(dataSource);
-
DataSource.Factory dataSourceFactory;
if (isHTTP(uri)) {
DefaultHttpDataSource.Factory httpDataSourceFactory =
@@ -87,7 +86,7 @@
}
dataSourceFactory = httpDataSourceFactory;
} else {
- dataSourceFactory = new DefaultDataSourceFactory(context, "ExoPlayer");
+ dataSourceFactory = new DefaultDataSource.Factory(context);
}
MediaSource mediaSource = buildMediaSource(uri, dataSourceFactory, formatHint, context);
@@ -107,6 +106,7 @@
private MediaSource buildMediaSource(
Uri uri, DataSource.Factory mediaDataSourceFactory, String formatHint, Context context) {
+
int type;
if (formatHint == null) {
type = Util.inferContentType(uri.getLastPathSegment());
@@ -133,12 +133,12 @@
case C.TYPE_SS:
return new SsMediaSource.Factory(
new DefaultSsChunkSource.Factory(mediaDataSourceFactory),
- new DefaultDataSourceFactory(context, null, mediaDataSourceFactory))
+ new DefaultDataSource.Factory(context, mediaDataSourceFactory))
.createMediaSource(MediaItem.fromUri(uri));
case C.TYPE_DASH:
return new DashMediaSource.Factory(
new DefaultDashChunkSource.Factory(mediaDataSourceFactory),
- new DefaultDataSourceFactory(context, null, mediaDataSourceFactory))
+ new DefaultDataSource.Factory(context, mediaDataSourceFactory))
.createMediaSource(MediaItem.fromUri(uri));
case C.TYPE_HLS:
return new HlsMediaSource.Factory(mediaDataSourceFactory)
@@ -207,7 +207,7 @@
}
@Override
- public void onPlayerError(final ExoPlaybackException error) {
+ public void onPlayerError(final PlaybackException error) {
setBuffering(false);
if (eventSink != null) {
eventSink.error("VideoError", "Video player had error " + error, null);
@@ -225,8 +225,7 @@
eventSink.success(event);
}
- @SuppressWarnings("deprecation")
- private static void setAudioAttributes(SimpleExoPlayer exoPlayer, boolean isMixMode) {
+ private static void setAudioAttributes(ExoPlayer exoPlayer, boolean isMixMode) {
exoPlayer.setAudioAttributes(
new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MOVIE).build(), !isMixMode);
}
diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml
index 15c063f..aa288ed 100644
--- a/packages/video_player/video_player_android/pubspec.yaml
+++ b/packages/video_player/video_player_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the video_player plugin.
repository: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
-version: 2.3.1
+version: 2.3.2
environment:
sdk: ">=2.14.0 <3.0.0"