提交 3f8f7ba9 编写于 作者: K kimvde 提交者: marcbaechinger

Fix conditions to enable UI actions

- Ensure consistency between (Styled)PlayerControlView,
  PlayerNotificationManager, TimelineQueueNavigator and
  DefaultControlDispatcher.
- Handle the case where a live stream has ended when enabling previous
  and next actions (window.isLive() is true and window.isDynamic is
  false in that case)

PiperOrigin-RevId: 359063793
上级 abf65e27
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
* Extractors: * Extractors:
* Add support for MP4 and QuickTime meta atoms that are not full atoms. * Add support for MP4 and QuickTime meta atoms that are not full atoms.
* UI:
* Make conditions to enable UI actions consistent in
`DefaultControlDispatcher`, `PlayerControlView`,
`StyledPlayerControlView`, `PlayerNotificationManager` and
`TimelineQueueNavigator`
* Fix conditions to enable seeking to next/previous media item to handle
the case where a live stream has ended.
* Audio: * Audio:
* Fix `SimpleExoPlayer` reporting audio session ID as 0 in some cases * Fix `SimpleExoPlayer` reporting audio session ID as 0 in some cases
([#8585](https://github.com/google/ExoPlayer/issues/8585)). ([#8585](https://github.com/google/ExoPlayer/issues/8585)).
......
...@@ -98,8 +98,8 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu ...@@ -98,8 +98,8 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu
if (!timeline.isEmpty() && !player.isPlayingAd()) { if (!timeline.isEmpty() && !player.isPlayingAd()) {
timeline.getWindow(player.getCurrentWindowIndex(), window); timeline.getWindow(player.getCurrentWindowIndex(), window);
enableSkipTo = timeline.getWindowCount() > 1; enableSkipTo = timeline.getWindowCount() > 1;
enablePrevious = window.isSeekable || !window.isDynamic || player.hasPrevious(); enablePrevious = window.isSeekable || !window.isLive() || player.hasPrevious();
enableNext = window.isDynamic || player.hasNext(); enableNext = (window.isLive() && window.isDynamic) || player.hasNext();
} }
long actions = 0; long actions = 0;
......
...@@ -79,11 +79,12 @@ public class DefaultControlDispatcher implements ControlDispatcher { ...@@ -79,11 +79,12 @@ public class DefaultControlDispatcher implements ControlDispatcher {
int windowIndex = player.getCurrentWindowIndex(); int windowIndex = player.getCurrentWindowIndex();
timeline.getWindow(windowIndex, window); timeline.getWindow(windowIndex, window);
int previousWindowIndex = player.getPreviousWindowIndex(); int previousWindowIndex = player.getPreviousWindowIndex();
boolean isUnseekableLiveStream = window.isLive() && !window.isSeekable;
if (previousWindowIndex != C.INDEX_UNSET if (previousWindowIndex != C.INDEX_UNSET
&& (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS
|| (window.isDynamic && !window.isSeekable))) { || isUnseekableLiveStream)) {
player.seekTo(previousWindowIndex, C.TIME_UNSET); player.seekTo(previousWindowIndex, C.TIME_UNSET);
} else { } else if (!isUnseekableLiveStream) {
player.seekTo(windowIndex, /* positionMs= */ 0); player.seekTo(windowIndex, /* positionMs= */ 0);
} }
return true; return true;
...@@ -96,10 +97,11 @@ public class DefaultControlDispatcher implements ControlDispatcher { ...@@ -96,10 +97,11 @@ public class DefaultControlDispatcher implements ControlDispatcher {
return true; return true;
} }
int windowIndex = player.getCurrentWindowIndex(); int windowIndex = player.getCurrentWindowIndex();
timeline.getWindow(windowIndex, window);
int nextWindowIndex = player.getNextWindowIndex(); int nextWindowIndex = player.getNextWindowIndex();
if (nextWindowIndex != C.INDEX_UNSET) { if (nextWindowIndex != C.INDEX_UNSET) {
player.seekTo(nextWindowIndex, C.TIME_UNSET); player.seekTo(nextWindowIndex, C.TIME_UNSET);
} else if (timeline.getWindow(windowIndex, window).isLive()) { } else if (window.isLive() && window.isDynamic) {
player.seekTo(windowIndex, C.TIME_UNSET); player.seekTo(windowIndex, C.TIME_UNSET);
} }
return true; return true;
......
...@@ -913,10 +913,10 @@ public class PlayerControlView extends FrameLayout { ...@@ -913,10 +913,10 @@ public class PlayerControlView extends FrameLayout {
timeline.getWindow(player.getCurrentWindowIndex(), window); timeline.getWindow(player.getCurrentWindowIndex(), window);
boolean isSeekable = window.isSeekable; boolean isSeekable = window.isSeekable;
enableSeeking = isSeekable; enableSeeking = isSeekable;
enablePrevious = isSeekable || !window.isDynamic || player.hasPrevious(); enablePrevious = isSeekable || !window.isLive() || player.hasPrevious();
enableRewind = isSeekable && controlDispatcher.isRewindEnabled(); enableRewind = isSeekable && controlDispatcher.isRewindEnabled();
enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled(); enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled();
enableNext = window.isLive() || player.hasNext(); enableNext = (window.isLive() && window.isDynamic) || player.hasNext();
} }
} }
......
...@@ -1227,10 +1227,11 @@ public class PlayerNotificationManager { ...@@ -1227,10 +1227,11 @@ public class PlayerNotificationManager {
Timeline timeline = player.getCurrentTimeline(); Timeline timeline = player.getCurrentTimeline();
if (!timeline.isEmpty() && !player.isPlayingAd()) { if (!timeline.isEmpty() && !player.isPlayingAd()) {
timeline.getWindow(player.getCurrentWindowIndex(), window); timeline.getWindow(player.getCurrentWindowIndex(), window);
enablePrevious = window.isSeekable || !window.isDynamic || player.hasPrevious(); boolean isSeekable = window.isSeekable;
enableRewind = controlDispatcher.isRewindEnabled(); enablePrevious = isSeekable || !window.isLive() || player.hasPrevious();
enableFastForward = controlDispatcher.isFastForwardEnabled(); enableRewind = isSeekable && controlDispatcher.isRewindEnabled();
enableNext = window.isDynamic || player.hasNext(); enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled();
enableNext = (window.isLive() && window.isDynamic) || player.hasNext();
} }
List<String> stringActions = new ArrayList<>(); List<String> stringActions = new ArrayList<>();
......
...@@ -1141,10 +1141,10 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -1141,10 +1141,10 @@ public class StyledPlayerControlView extends FrameLayout {
timeline.getWindow(player.getCurrentWindowIndex(), window); timeline.getWindow(player.getCurrentWindowIndex(), window);
boolean isSeekable = window.isSeekable; boolean isSeekable = window.isSeekable;
enableSeeking = isSeekable; enableSeeking = isSeekable;
enablePrevious = isSeekable || !window.isDynamic || player.hasPrevious(); enablePrevious = isSeekable || !window.isLive() || player.hasPrevious();
enableRewind = isSeekable && controlDispatcher.isRewindEnabled(); enableRewind = isSeekable && controlDispatcher.isRewindEnabled();
enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled(); enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled();
enableNext = window.isLive() || player.hasNext(); enableNext = (window.isLive() && window.isDynamic) || player.hasNext();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册