Hide player controls when an ad is playing

Also fix an issue where ad timelines with unknown ad period durations
would not be shown in multi-window mode. (The time bar doesn't use the
duration of ad periods, but shows a fix-size indicator instead.)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152666055
This commit is contained in:
andrewlewis 2017-04-10 02:17:35 -07:00 committed by Oliver Woodman
parent d8c71df255
commit 147020f816

View file

@ -508,6 +508,10 @@ public class PlaybackControlView extends FrameLayout {
isSeekable = window.isSeekable;
enablePrevious = windowIndex > 0 || isSeekable || !window.isDynamic;
enableNext = (windowIndex < timeline.getWindowCount() - 1) || window.isDynamic;
if (timeline.getPeriod(player.getCurrentPeriodIndex(), period).isAd) {
// Always hide player controls during ads.
hide();
}
}
setButtonEnabled(enablePrevious, previousButton);
setButtonEnabled(enableNext, nextButton);
@ -800,7 +804,8 @@ public class PlaybackControlView extends FrameLayout {
}
int periodCount = timeline.getPeriodCount();
for (int i = 0; i < periodCount; i++) {
if (timeline.getPeriod(i, period).durationUs == C.TIME_UNSET) {
timeline.getPeriod(i, period);
if (!period.isAd && period.durationUs == C.TIME_UNSET) {
return false;
}
}