mirror of
https://github.com/androidx/media.git
synced 2025-05-14 02:59:52 +08: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
b97ce44182
commit
04108eec48
@ -702,6 +702,9 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
|
|||||||
for (int i = 0; i < adCallbacks.size(); i++) {
|
for (int i = 0; i < adCallbacks.size(); i++) {
|
||||||
adCallbacks.get(i).onEnded();
|
adCallbacks.get(i).onEnded();
|
||||||
}
|
}
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "VideoAdPlayerCallback.onEnded in onPlayerStateChanged");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,16 +800,20 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
|
|||||||
|
|
||||||
private void updateImaStateForPlayerState() {
|
private void updateImaStateForPlayerState() {
|
||||||
boolean wasPlayingAd = playingAd;
|
boolean wasPlayingAd = playingAd;
|
||||||
|
int oldPlayingAdIndexInAdGroup = playingAdIndexInAdGroup;
|
||||||
playingAd = player.isPlayingAd();
|
playingAd = player.isPlayingAd();
|
||||||
|
playingAdIndexInAdGroup = playingAd ? player.getCurrentAdIndexInAdGroup() : C.INDEX_UNSET;
|
||||||
if (!sentContentComplete) {
|
if (!sentContentComplete) {
|
||||||
boolean adFinished = (wasPlayingAd && !playingAd)
|
boolean adFinished = wasPlayingAd && playingAdIndexInAdGroup != oldPlayingAdIndexInAdGroup;
|
||||||
|| playingAdIndexInAdGroup != player.getCurrentAdIndexInAdGroup();
|
|
||||||
if (adFinished) {
|
if (adFinished) {
|
||||||
// IMA is waiting for the ad playback to finish so invoke the callback now.
|
// 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.
|
// Either CONTENT_RESUME_REQUESTED will be passed next, or playAd will be called again.
|
||||||
for (int i = 0; i < adCallbacks.size(); i++) {
|
for (int i = 0; i < adCallbacks.size(); i++) {
|
||||||
adCallbacks.get(i).onEnded();
|
adCallbacks.get(i).onEnded();
|
||||||
}
|
}
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "VideoAdPlayerCallback.onEnded in onTimelineChanged/onPositionDiscontinuity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!wasPlayingAd && playingAd) {
|
if (!wasPlayingAd && playingAd) {
|
||||||
int adGroupIndex = player.getCurrentAdGroupIndex();
|
int adGroupIndex = player.getCurrentAdGroupIndex();
|
||||||
@ -818,7 +825,6 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playingAdIndexInAdGroup = playingAd ? player.getCurrentAdIndexInAdGroup() : C.INDEX_UNSET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resumeContentInternal() {
|
private void resumeContentInternal() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user