Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a413b478
authored
Oct 24, 2022
by
Rohit Singh
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #10618 from vishnuchilakala:fix/do_not_send_content_complete_if_midroll_skipped
PiperOrigin-RevId: 482481703
parents
0eb30eac
b9b30c46
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
17 deletions
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java
View file @
a413b478
...
...
@@ -22,6 +22,7 @@ import static com.google.android.exoplayer2.ext.ima.ImaUtil.getAdGroupTimesUsFor
import
static
com
.
google
.
android
.
exoplayer2
.
ext
.
ima
.
ImaUtil
.
getImaLooper
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Util
.
msToUs
;
import
static
java
.
lang
.
Math
.
max
;
import
static
java
.
lang
.
annotation
.
ElementType
.
TYPE_USE
;
...
...
@@ -50,6 +51,7 @@ import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
import
com.google.ads.interactivemedia.v3.api.player.AdMediaInfo
;
import
com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider
;
import
com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer
;
import
com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback
;
import
com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
...
...
@@ -355,7 +357,7 @@ import java.util.Map;
long
contentPositionMs
=
getContentPeriodPositionMs
(
player
,
timeline
,
period
);
int
adGroupForPositionIndex
=
adPlaybackState
.
getAdGroupIndexForPositionUs
(
Util
.
msToUs
(
contentPositionMs
),
Util
.
msToUs
(
contentDurationMs
));
msToUs
(
contentPositionMs
),
msToUs
(
contentDurationMs
));
if
(
adGroupForPositionIndex
!=
C
.
INDEX_UNSET
&&
imaAdInfo
!=
null
&&
imaAdInfo
.
adGroupIndex
!=
adGroupForPositionIndex
)
{
...
...
@@ -379,7 +381,7 @@ import java.util.Map;
}
adPlaybackState
=
adPlaybackState
.
withAdResumePositionUs
(
playingAd
?
Util
.
msToUs
(
player
.
getCurrentPosition
())
:
0
);
playingAd
?
msToUs
(
player
.
getCurrentPosition
())
:
0
);
}
lastVolumePercent
=
getPlayerVolumePercent
();
lastAdProgress
=
getAdVideoProgressUpdate
();
...
...
@@ -609,11 +611,10 @@ import java.util.Map;
// Skip ads based on the start position as required.
int
adGroupForPositionIndex
=
adPlaybackState
.
getAdGroupIndexForPositionUs
(
Util
.
msToUs
(
contentPositionMs
),
Util
.
msToUs
(
contentDurationMs
));
msToUs
(
contentPositionMs
),
msToUs
(
contentDurationMs
));
if
(
adGroupForPositionIndex
!=
C
.
INDEX_UNSET
)
{
boolean
playAdWhenStartingPlayback
=
adPlaybackState
.
getAdGroup
(
adGroupForPositionIndex
).
timeUs
==
Util
.
msToUs
(
contentPositionMs
)
adPlaybackState
.
getAdGroup
(
adGroupForPositionIndex
).
timeUs
==
msToUs
(
contentPositionMs
)
||
configuration
.
playAdBeforeStartPosition
;
if
(!
playAdWhenStartingPlayback
)
{
adGroupForPositionIndex
++;
...
...
@@ -865,7 +866,7 @@ import java.util.Map;
if
(!
sentContentComplete
&&
!
timeline
.
isEmpty
())
{
long
positionMs
=
getContentPeriodPositionMs
(
player
,
timeline
,
period
);
timeline
.
getPeriod
(
player
.
getCurrentPeriodIndex
(),
period
);
int
newAdGroupIndex
=
period
.
getAdGroupIndexForPositionUs
(
Util
.
msToUs
(
positionMs
));
int
newAdGroupIndex
=
period
.
getAdGroupIndexForPositionUs
(
msToUs
(
positionMs
));
if
(
newAdGroupIndex
!=
C
.
INDEX_UNSET
)
{
sentPendingContentPositionMs
=
false
;
pendingContentPositionMs
=
positionMs
;
...
...
@@ -1157,14 +1158,26 @@ import java.util.Map;
}
private
void
ensureSentContentCompleteIfAtEndOfStream
()
{
if
(!
sentContentComplete
&&
contentDurationMs
!=
C
.
TIME_UNSET
&&
pendingContentPositionMs
==
C
.
TIME_UNSET
&&
getContentPeriodPositionMs
(
checkNotNull
(
player
),
timeline
,
period
)
+
THRESHOLD_END_OF_CONTENT_MS
>=
contentDurationMs
)
{
sendContentComplete
();
if
(
sentContentComplete
||
contentDurationMs
==
C
.
TIME_UNSET
||
pendingContentPositionMs
!=
C
.
TIME_UNSET
)
{
return
;
}
long
contentPeriodPositionMs
=
getContentPeriodPositionMs
(
checkNotNull
(
player
),
timeline
,
period
);
if
(
contentPeriodPositionMs
+
THRESHOLD_END_OF_CONTENT_MS
<
contentDurationMs
)
{
return
;
}
int
pendingAdGroupIndex
=
adPlaybackState
.
getAdGroupIndexForPositionUs
(
msToUs
(
contentPeriodPositionMs
),
msToUs
(
contentDurationMs
));
if
(
pendingAdGroupIndex
!=
C
.
INDEX_UNSET
&&
adPlaybackState
.
getAdGroup
(
pendingAdGroupIndex
).
timeUs
!=
C
.
TIME_END_OF_SOURCE
&&
adPlaybackState
.
getAdGroup
(
pendingAdGroupIndex
).
shouldPlayAdGroup
())
{
// Pending mid-roll ad that needs to be played before marking the content complete.
return
;
}
sendContentComplete
();
}
private
void
sendContentComplete
()
{
...
...
@@ -1233,14 +1246,13 @@ import java.util.Map;
if
(
player
==
null
)
{
return
C
.
INDEX_UNSET
;
}
long
playerPositionUs
=
Util
.
msToUs
(
getContentPeriodPositionMs
(
player
,
timeline
,
period
));
long
playerPositionUs
=
msToUs
(
getContentPeriodPositionMs
(
player
,
timeline
,
period
));
int
adGroupIndex
=
adPlaybackState
.
getAdGroupIndexForPositionUs
(
playerPositionUs
,
Util
.
msToUs
(
contentDurationMs
));
adPlaybackState
.
getAdGroupIndexForPositionUs
(
playerPositionUs
,
msToUs
(
contentDurationMs
));
if
(
adGroupIndex
==
C
.
INDEX_UNSET
)
{
adGroupIndex
=
adPlaybackState
.
getAdGroupIndexAfterPositionUs
(
playerPositionUs
,
Util
.
msToUs
(
contentDurationMs
));
playerPositionUs
,
msToUs
(
contentDurationMs
));
}
return
adGroupIndex
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment