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
This commit is contained in:
tonihei 2020-01-08 17:20:19 +00:00 committed by Oliver Woodman
parent e1a110e651
commit 6395d44bfa
2 changed files with 16 additions and 2 deletions

View File

@ -30,6 +30,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) ###

View File

@ -927,7 +927,18 @@ public class PlayerNotificationManager {
}
/**
* Sets whether the elapsed time of the media playback should be displayed
* Sets whether the elapsed time of the media playback should be displayed.
*
* <p>Note that this setting only works if all of the following are true:
*
* <ul>
* <li>The media is {@link Player#isPlaying() actively playing}.
* <li>The media is not {@link Player#isCurrentWindowDynamic() dynamically changing its
* duration} (like for example a live stream).
* <li>The media is not {@link Player#isPlayingAd() interrupted by an ad}.
* <li>The media is played at {@link Player#getPlaybackParameters() regular speed}.
* <li>The device is running at least API 21 (Lollipop).
* </ul>
*
* <p>See {@link NotificationCompat.Builder#setUsesChronometer(boolean)}.
*
@ -1084,7 +1095,8 @@ public class PlayerNotificationManager {
&& useChronometer
&& player.isPlaying()
&& !player.isPlayingAd()
&& !player.isCurrentWindowDynamic()) {
&& !player.isCurrentWindowDynamic()
&& player.getPlaybackParameters().speed == 1f) {
builder
.setWhen(System.currentTimeMillis() - player.getContentPosition())
.setShowWhen(true)