From 2b2e954b84e2f2ccb78a293ccfc674d4d4cf3375 Mon Sep 17 00:00:00 2001 From: John Zhen M Date: Fri, 18 Aug 2017 11:07:57 -0700 Subject: [PATCH] -Updated ExoPlayer to r2.5.1. -Fixes some more deprecations due to Exoplayer and Android O notification updates. --- app/build.gradle | 2 +- .../newpipe/player/BackgroundPlayer.java | 5 ++++ .../org/schabi/newpipe/player/BasePlayer.java | 23 +++++++++++-------- .../newpipe/player/MainVideoPlayer.java | 5 ++++ .../newpipe/player/PopupVideoPlayer.java | 6 ++++- .../schabi/newpipe/player/VideoPlayer.java | 3 ++- .../giga/service/DownloadManagerService.java | 2 +- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a110e36e2..bfd37e542 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,7 +67,7 @@ dependencies { compile 'de.hdodenhof:circleimageview:2.0.0' compile 'com.github.nirhart:parallaxscroll:1.0' compile 'com.nononsenseapps:filepicker:3.0.0' - compile 'com.google.android.exoplayer:exoplayer:r2.4.2' + compile 'com.google.android.exoplayer:exoplayer:r2.5.1' debugCompile 'com.facebook.stetho:stetho:1.5.0' debugCompile 'com.facebook.stetho:stetho-urlconnection:1.5.0' diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index 2d11b355c..b52c2e09d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -342,6 +342,11 @@ public class BackgroundPlayer extends Service { // Disable default behavior } + @Override + public void onRepeatModeChanged(int i) { + + } + @Override public void destroy() { super.destroy(); 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 8c2e5c6b8..2b837cc7e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -19,10 +19,12 @@ import android.view.View; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLoadControl; +import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; -import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.PlaybackParameters; +import com.google.android.exoplayer2.Player; +import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; @@ -62,7 +64,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @author mauriciocolli */ @SuppressWarnings({"WeakerAccess", "unused"}) -public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManager.OnAudioFocusChangeListener { +public abstract class BasePlayer implements Player.EventListener, AudioManager.OnAudioFocusChangeListener { public static final boolean DEBUG = false; public static final String TAG = "BasePlayer"; @@ -158,7 +160,8 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage DefaultTrackSelector defaultTrackSelector = new DefaultTrackSelector(trackSelectionFactory); DefaultLoadControl loadControl = new DefaultLoadControl(); - simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(context, defaultTrackSelector, loadControl); + final RenderersFactory renderFactory = new DefaultRenderersFactory(context); + simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(renderFactory, defaultTrackSelector, loadControl); simpleExoPlayer.addListener(this); } @@ -220,7 +223,7 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage isPrepared = false; mediaSource = buildMediaSource(url, format); - if (simpleExoPlayer.getPlaybackState() != ExoPlayer.STATE_IDLE) simpleExoPlayer.stop(); + if (simpleExoPlayer.getPlaybackState() != Player.STATE_IDLE) simpleExoPlayer.stop(); if (videoStartPos > 0) simpleExoPlayer.seekTo(videoStartPos); simpleExoPlayer.prepare(mediaSource); simpleExoPlayer.setPlayWhenReady(autoPlay); @@ -477,13 +480,13 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage } switch (playbackState) { - case ExoPlayer.STATE_IDLE: // 1 + case Player.STATE_IDLE: // 1 isPrepared = false; break; - case ExoPlayer.STATE_BUFFERING: // 2 + case Player.STATE_BUFFERING: // 2 if (isPrepared && getCurrentState() != STATE_LOADING) changeState(STATE_BUFFERING); break; - case ExoPlayer.STATE_READY: //3 + case Player.STATE_READY: //3 if (!isPrepared) { isPrepared = true; onPrepared(playWhenReady); @@ -492,7 +495,7 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage if (currentState == STATE_PAUSED_SEEK) break; changeState(playWhenReady ? STATE_PLAYING : STATE_PAUSED); break; - case ExoPlayer.STATE_ENDED: // 4 + case Player.STATE_ENDED: // 4 changeState(STATE_COMPLETED); isPrepared = false; break; @@ -569,7 +572,7 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage } public boolean isPlaying() { - return simpleExoPlayer.getPlaybackState() == ExoPlayer.STATE_READY && simpleExoPlayer.getPlayWhenReady(); + return simpleExoPlayer.getPlaybackState() == Player.STATE_READY && simpleExoPlayer.getPlayWhenReady(); } /*////////////////////////////////////////////////////////////////////////// @@ -715,7 +718,7 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage } public boolean isCompleted() { - return simpleExoPlayer != null && simpleExoPlayer.getPlaybackState() == ExoPlayer.STATE_ENDED; + return simpleExoPlayer != null && simpleExoPlayer.getPlaybackState() == Player.STATE_ENDED; } public boolean isPrepared() { diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 547d6447e..6706ab4ef 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -422,6 +422,11 @@ public class MainVideoPlayer extends Activity { public ImageButton getPlayPauseButton() { return playPauseButton; } + + @Override + public void onRepeatModeChanged(int i) { + + } } private class MySimpleOnGestureListener extends GestureDetector.SimpleOnGestureListener implements View.OnTouchListener { diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 7fb497447..f40843726 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -431,7 +431,7 @@ public class PopupVideoPlayer extends Service { hideControls(100, 0); } } -/*////////////////////////////////////////////////////////////////////////// + /*////////////////////////////////////////////////////////////////////////// // Broadcast Receiver //////////////////////////////////////////////////////////////////////////*/ @@ -511,6 +511,10 @@ public class PopupVideoPlayer extends Service { public TextView getResizingIndicator() { return resizingIndicator; } + + @Override + public void onRepeatModeChanged(int i) { + } } private class MySimpleOnGestureListener extends GestureDetector.SimpleOnGestureListener implements View.OnTouchListener { diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index c16acd766..39e94471f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -27,6 +27,7 @@ import android.widget.SeekBar; import android.widget.TextView; import com.google.android.exoplayer2.ExoPlayer; +import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.source.ExtractorMediaSource; import com.google.android.exoplayer2.source.MediaSource; @@ -52,7 +53,7 @@ import static org.schabi.newpipe.util.AnimationUtils.animateView; * @author mauriciocolli */ @SuppressWarnings({"WeakerAccess", "unused"}) -public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.VideoListener, SeekBar.OnSeekBarChangeListener, View.OnClickListener, ExoPlayer.EventListener, PopupMenu.OnMenuItemClickListener, PopupMenu.OnDismissListener { +public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.VideoListener, SeekBar.OnSeekBarChangeListener, View.OnClickListener, Player.EventListener, PopupMenu.OnMenuItemClickListener, PopupMenu.OnDismissListener { public static final boolean DEBUG = BasePlayer.DEBUG; public final String TAG; diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index 81d23a0ae..d60ae86ab 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -98,7 +98,7 @@ public class DownloadManagerService extends Service { Drawable icon = ContextCompat.getDrawable(this, R.mipmap.ic_launcher); - Builder builder = new Builder(this) + Builder builder = new Builder(this, getString(R.string.notification_channel_id)) .setContentIntent(pendingIntent) .setSmallIcon(android.R.drawable.stat_sys_download) .setLargeIcon(((BitmapDrawable) icon).getBitmap())