From 216518eb0ea1beaf567ae14eae00c0d19055c9cf Mon Sep 17 00:00:00 2001 From: tonihei Date: Wed, 8 Jan 2020 17:20:19 +0000 Subject: [PATCH] Disable chronometer for playback speeds != 1.0 This doesn't work because the Chronometer text layout can only count in realtime. Issue:#6816 PiperOrigin-RevId: 288711702 --- RELEASENOTES.md | 2 ++ .../exoplayer2/ui/PlayerNotificationManager.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ac0fb108b9e..bdef903be1c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -54,6 +54,8 @@ * OkHttp extension: Upgrade OkHttp dependency to 3.12.7, which fixes a class of `SocketTimeoutException` issues when using HTTP/2 ([#4078](https://github.com/google/ExoPlayer/issues/4078)). +* Don't use notification chronometer if playback speed is != 1.0 + ([#6816](https://github.com/google/ExoPlayer/issues/6816)). ### 2.11.1 (2019-12-20) ### diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java index e572bc5a112..9f0c8280c41 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java @@ -927,7 +927,18 @@ public final void setSmallIcon(@DrawableRes int smallIconResourceId) { } /** - * Sets whether the elapsed time of the media playback should be displayed + * Sets whether the elapsed time of the media playback should be displayed. + * + *

Note that this setting only works if all of the following are true: + * + *

* *

See {@link NotificationCompat.Builder#setUsesChronometer(boolean)}. * @@ -1082,7 +1093,8 @@ protected NotificationCompat.Builder createNotification( && useChronometer && player.isPlaying() && !player.isPlayingAd() - && !player.isCurrentWindowDynamic()) { + && !player.isCurrentWindowDynamic() + && player.getPlaybackParameters().speed == 1f) { builder .setWhen(System.currentTimeMillis() - player.getContentPosition()) .setShowWhen(true)