mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Fix condition for detecting that an ad has ended
onEnded was being called also for content finishing, as in this case the playing ad index changed (from INDEX_UNSET to 0). Fix this test so we only detect ads finishing. Also add logging for onEnded callbacks. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179167737
This commit is contained in:
parent
65360760c2
commit
e913ede77e
1 changed files with 9 additions and 3 deletions
|
|
@ -703,6 +703,9 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
|
|||
for (int i = 0; i < adCallbacks.size(); i++) {
|
||||
adCallbacks.get(i).onEnded();
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "VideoAdPlayerCallback.onEnded in onPlayerStateChanged");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -798,16 +801,20 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
|
|||
|
||||
private void updateImaStateForPlayerState() {
|
||||
boolean wasPlayingAd = playingAd;
|
||||
int oldPlayingAdIndexInAdGroup = playingAdIndexInAdGroup;
|
||||
playingAd = player.isPlayingAd();
|
||||
playingAdIndexInAdGroup = playingAd ? player.getCurrentAdIndexInAdGroup() : C.INDEX_UNSET;
|
||||
if (!sentContentComplete) {
|
||||
boolean adFinished = (wasPlayingAd && !playingAd)
|
||||
|| playingAdIndexInAdGroup != player.getCurrentAdIndexInAdGroup();
|
||||
boolean adFinished = wasPlayingAd && playingAdIndexInAdGroup != oldPlayingAdIndexInAdGroup;
|
||||
if (adFinished) {
|
||||
// IMA is waiting for the ad playback to finish so invoke the callback now.
|
||||
// Either CONTENT_RESUME_REQUESTED will be passed next, or playAd will be called again.
|
||||
for (int i = 0; i < adCallbacks.size(); i++) {
|
||||
adCallbacks.get(i).onEnded();
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "VideoAdPlayerCallback.onEnded in onTimelineChanged/onPositionDiscontinuity");
|
||||
}
|
||||
}
|
||||
if (!wasPlayingAd && playingAd) {
|
||||
int adGroupIndex = player.getCurrentAdGroupIndex();
|
||||
|
|
@ -819,7 +826,6 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
|
|||
}
|
||||
}
|
||||
}
|
||||
playingAdIndexInAdGroup = playingAd ? player.getCurrentAdIndexInAdGroup() : C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
private void resumeContentInternal() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue