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
99054325
authored
Jun 21, 2019
by
andrewlewis
Committed by
Oliver Woodman
Jun 21, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix ad pod index offset calculation without preroll
Issue: #5928 PiperOrigin-RevId: 254379085
parent
88f1dfcb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
RELEASENOTES.md
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
RELEASENOTES.md
View file @
99054325
...
...
@@ -47,6 +47,8 @@
(
[
#5807
](
https://github.com/google/ExoPlayer/pull/5807
)
).
*
TTML: Fix bitmap rendering
(
[
#5633
](
https://github.com/google/ExoPlayer/pull/5633
)
).
*
IMA: Fix ad pod index offset calculation without preroll
(
[
#5928
](
https://github.com/google/ExoPlayer/issues/5928
)
).
*
Add a
`playWhenReady`
flag to MediaSessionConnector.PlaybackPreparer methods
to indicate whether a controller sent a play or only a prepare command. This
allows to take advantage of decoder reuse with the MediaSessionConnector
...
...
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
View file @
99054325
...
...
@@ -1054,13 +1054,8 @@ public final class ImaAdsLoader
long
contentPositionMs
=
player
.
getCurrentPosition
();
int
adGroupIndexForPosition
=
adPlaybackState
.
getAdGroupIndexForPositionUs
(
C
.
msToUs
(
contentPositionMs
));
if
(
adGroupIndexForPosition
==
0
)
{
podIndexOffset
=
0
;
}
else
if
(
adGroupIndexForPosition
==
C
.
INDEX_UNSET
)
{
// There is no preroll and midroll pod indices start at 1.
podIndexOffset
=
-
1
;
}
else
/* adGroupIndexForPosition > 0 */
{
// Skip ad groups before the one at or immediately before the playback position.
if
(
adGroupIndexForPosition
>
0
&&
adGroupIndexForPosition
!=
C
.
INDEX_UNSET
)
{
// Skip any ad groups before the one at or immediately before the playback position.
for
(
int
i
=
0
;
i
<
adGroupIndexForPosition
;
i
++)
{
adPlaybackState
=
adPlaybackState
.
withSkippedAdGroup
(
i
);
}
...
...
@@ -1070,9 +1065,18 @@ public final class ImaAdsLoader
long
adGroupBeforeTimeUs
=
adGroupTimesUs
[
adGroupIndexForPosition
-
1
];
double
midpointTimeUs
=
(
adGroupForPositionTimeUs
+
adGroupBeforeTimeUs
)
/
2
d
;
adsRenderingSettings
.
setPlayAdsAfterTime
(
midpointTimeUs
/
C
.
MICROS_PER_SECOND
);
}
// We're removing one or more ads, which means that the earliest ad (if any) will be a
// midroll/postroll. Midroll pod indices start at 1.
// IMA indexes any remaining midroll ad pods from 1. A preroll (if present) has index 0.
// Store an index offset as we want to index all ads (including skipped ones) from 0.
if
(
adGroupIndexForPosition
==
0
&&
adGroupTimesUs
[
0
]
==
0
)
{
// We are playing a preroll.
podIndexOffset
=
0
;
}
else
if
(
adGroupIndexForPosition
==
C
.
INDEX_UNSET
)
{
// There's no ad to play which means there's no preroll.
podIndexOffset
=
-
1
;
}
else
{
// We are playing a midroll and any ads before it were skipped.
podIndexOffset
=
adGroupIndexForPosition
-
1
;
}
...
...
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