1<!DOCTYPE HTML>
2<!-- NewPage -->
3<html lang="en">
4<head><!-- start favicons snippet, use https://realfavicongenerator.net/ --><link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png"><link rel="manifest" href="/assets/site.webmanifest"><link rel="mask-icon" href="/assets/safari-pinned-tab.svg" color="#fc4d50"><link rel="shortcut icon" href="/assets/favicon.ico"><meta name="msapplication-TileColor" content="#ffc40d"><meta name="msapplication-config" content="/assets/browserconfig.xml"><meta name="theme-color" content="#ffffff"><!-- end favicons snippet -->
5<title>ServerSideAdInsertionUtil (ExoPlayer library)</title>
6<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
8<link rel="stylesheet" type="text/css" href="../../../../../../jquery/jquery-ui.css" title="Style">
9<script type="text/javascript" src="../../../../../../script.js"></script>
10<script type="text/javascript" src="../../../../../../jquery/jszip/dist/jszip.min.js"></script>
11<script type="text/javascript" src="../../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
12<!--[if IE]>
13<script type="text/javascript" src="../../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
14<![endif]-->
15<script type="text/javascript" src="../../../../../../jquery/jquery-3.5.1.js"></script>
16<script type="text/javascript" src="../../../../../../jquery/jquery-ui.js"></script>
17</head>
18<body>
19<script type="text/javascript"><!--
20    try {
21        if (location.href.indexOf('is-external=true') == -1) {
22            parent.document.title="ServerSideAdInsertionUtil (ExoPlayer library)";
23        }
24    }
25    catch(err) {
26    }
27//-->
28var data = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9};
29var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
30var altColor = "altColor";
31var rowColor = "rowColor";
32var tableTab = "tableTab";
33var activeTableTab = "activeTableTab";
34var pathtoroot = "../../../../../../";
35var useModuleDirectories = false;
36loadScripts(document, 'script');</script>
37<noscript>
38<div>JavaScript is disabled on your browser.</div>
39</noscript>
40<header role="banner">
41<nav role="navigation">
42<div class="fixedNav">
43<!-- ========= START OF TOP NAVBAR ======= -->
44<div class="topNav"><a id="navbar.top">
45<!--   -->
46</a>
47<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
48<a id="navbar.top.firstrow">
49<!--   -->
50</a>
51<ul class="navList" title="Navigation">
52<li><a href="../../../../../../index.html">Overview</a></li>
53<li><a href="package-summary.html">Package</a></li>
54<li class="navBarCell1Rev">Class</li>
55<li><a href="package-tree.html">Tree</a></li>
56<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
57<li><a href="../../../../../../index-all.html">Index</a></li>
58<li><a href="../../../../../../help-doc.html">Help</a></li>
59</ul>
60</div>
61<div class="subNav">
62<ul class="navList" id="allclasses_navbar_top">
63<li><a href="../../../../../../allclasses.html">All&nbsp;Classes</a></li>
64</ul>
65<ul class="navListSearch">
66<li><label for="search">SEARCH:</label>
67<input type="text" id="search" value="search" disabled="disabled">
68<input type="reset" id="reset" value="reset" disabled="disabled">
69</li>
70</ul>
71<div>
72<script type="text/javascript"><!--
73  allClassesLink = document.getElementById("allclasses_navbar_top");
74  if(window==top) {
75    allClassesLink.style.display = "block";
76  }
77  else {
78    allClassesLink.style.display = "none";
79  }
80  //-->
81</script>
82<noscript>
83<div>JavaScript is disabled on your browser.</div>
84</noscript>
85</div>
86<div>
87<ul class="subNavList">
88<li>Summary:&nbsp;</li>
89<li>Nested&nbsp;|&nbsp;</li>
90<li>Field&nbsp;|&nbsp;</li>
91<li>Constr&nbsp;|&nbsp;</li>
92<li><a href="#method.summary">Method</a></li>
93</ul>
94<ul class="subNavList">
95<li>Detail:&nbsp;</li>
96<li>Field&nbsp;|&nbsp;</li>
97<li>Constr&nbsp;|&nbsp;</li>
98<li><a href="#method.detail">Method</a></li>
99</ul>
100</div>
101<a id="skip.navbar.top">
102<!--   -->
103</a></div>
104<!-- ========= END OF TOP NAVBAR ========= -->
105</div>
106<div class="navPadding">&nbsp;</div>
107<script type="text/javascript"><!--
108$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
109//-->
110</script>
111</nav>
112</header>
113<!-- ======== START OF CLASS DATA ======== -->
114<main role="main">
115<div class="header">
116<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">com.google.android.exoplayer2.source.ads</a></div>
117<h2 title="Class ServerSideAdInsertionUtil" class="title">Class ServerSideAdInsertionUtil</h2>
118</div>
119<div class="contentContainer">
120<ul class="inheritance">
121<li><a href="https://developer.android.com/reference/java/lang/Object.html" title="class or interface in java.lang" class="externalLink" target="_top">java.lang.Object</a></li>
122<li>
123<ul class="inheritance">
124<li>com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil</li>
125</ul>
126</li>
127</ul>
128<div class="description">
129<ul class="blockList">
130<li class="blockList">
131<hr>
132<pre>public final class <span class="typeNameLabel">ServerSideAdInsertionUtil</span>
133extends <a href="https://developer.android.com/reference/java/lang/Object.html" title="class or interface in java.lang" class="externalLink" target="_top">Object</a></pre>
134<div class="block">A static utility class with methods to work with server-side inserted ads.</div>
135</li>
136</ul>
137</div>
138<div class="summary">
139<ul class="blockList">
140<li class="blockList">
141<!-- ========== METHOD SUMMARY =========== -->
142<section role="region">
143<ul class="blockList">
144<li class="blockList"><a id="method.summary">
145<!--   -->
146</a>
147<h3>Method Summary</h3>
148<table class="memberSummary">
149<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
150<tr>
151<th class="colFirst" scope="col">Modifier and Type</th>
152<th class="colSecond" scope="col">Method</th>
153<th class="colLast" scope="col">Description</th>
154</tr>
155<tr id="i0" class="altColor">
156<td class="colFirst"><code>static <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a></code></td>
157<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#addAdGroupToAdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState,long,long,long...)">addAdGroupToAdPlaybackState</a></span>&#8203;(<a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState,
158                           long&nbsp;fromPositionUs,
159                           long&nbsp;contentResumeOffsetUs,
160                           long...&nbsp;adDurationsUs)</code></th>
161<td class="colLast">
162<div class="block">Adds a new server-side inserted ad group to an <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a>.</div>
163</td>
164</tr>
165<tr id="i1" class="rowColor">
166<td class="colFirst"><code>static int</code></td>
167<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getAdCountInGroup(com.google.android.exoplayer2.source.ads.AdPlaybackState,int)">getAdCountInGroup</a></span>&#8203;(<a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState,
168                 int&nbsp;adGroupIndex)</code></th>
169<td class="colLast">
170<div class="block">Returns the number of ads in an ad group, treating an unknown number as zero ads.</div>
171</td>
172</tr>
173<tr id="i2" class="altColor">
174<td class="colFirst"><code>static long</code></td>
175<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getMediaPeriodPositionUs(long,com.google.android.exoplayer2.source.MediaPeriodId,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getMediaPeriodPositionUs</a></span>&#8203;(long&nbsp;positionUs,
176                        <a href="../MediaPeriodId.html" title="class in com.google.android.exoplayer2.source">MediaPeriodId</a>&nbsp;mediaPeriodId,
177                        <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
178<td class="colLast">
179<div class="block">Returns the position in a <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a> for a position in the underlying server-side
180 inserted ads stream.</div>
181</td>
182</tr>
183<tr id="i3" class="rowColor">
184<td class="colFirst"><code>static long</code></td>
185<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getMediaPeriodPositionUsForAd(long,int,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getMediaPeriodPositionUsForAd</a></span>&#8203;(long&nbsp;positionUs,
186                             int&nbsp;adGroupIndex,
187                             int&nbsp;adIndexInAdGroup,
188                             <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
189<td class="colLast">
190<div class="block">Returns the position in an ad <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a> for a position in the underlying server-side
191 inserted ads stream.</div>
192</td>
193</tr>
194<tr id="i4" class="altColor">
195<td class="colFirst"><code>static long</code></td>
196<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getMediaPeriodPositionUsForContent(long,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getMediaPeriodPositionUsForContent</a></span>&#8203;(long&nbsp;positionUs,
197                                  int&nbsp;nextAdGroupIndex,
198                                  <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
199<td class="colLast">
200<div class="block">Returns the position in a content <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a> for a position in the underlying
201 server-side inserted ads stream.</div>
202</td>
203</tr>
204<tr id="i5" class="rowColor">
205<td class="colFirst"><code>static long</code></td>
206<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getStreamPositionUs(long,com.google.android.exoplayer2.source.MediaPeriodId,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getStreamPositionUs</a></span>&#8203;(long&nbsp;positionUs,
207                   <a href="../MediaPeriodId.html" title="class in com.google.android.exoplayer2.source">MediaPeriodId</a>&nbsp;mediaPeriodId,
208                   <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
209<td class="colLast">
210<div class="block">Returns the position in the underlying server-side inserted ads stream for a position in a
211 <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</div>
212</td>
213</tr>
214<tr id="i6" class="altColor">
215<td class="colFirst"><code>static long</code></td>
216<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getStreamPositionUs(com.google.android.exoplayer2.Player,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getStreamPositionUs</a></span>&#8203;(<a href="../../Player.html" title="interface in com.google.android.exoplayer2">Player</a>&nbsp;player,
217                   <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
218<td class="colLast">
219<div class="block">Returns the position in the underlying server-side inserted ads stream for the current playback
220 position in the <a href="../../Player.html" title="interface in com.google.android.exoplayer2"><code>Player</code></a>.</div>
221</td>
222</tr>
223<tr id="i7" class="rowColor">
224<td class="colFirst"><code>static long</code></td>
225<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getStreamPositionUsForAd(long,int,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getStreamPositionUsForAd</a></span>&#8203;(long&nbsp;positionUs,
226                        int&nbsp;adGroupIndex,
227                        int&nbsp;adIndexInAdGroup,
228                        <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
229<td class="colLast">
230<div class="block">Returns the position in the underlying server-side inserted ads stream for a position in an ad
231 <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</div>
232</td>
233</tr>
234<tr id="i8" class="altColor">
235<td class="colFirst"><code>static long</code></td>
236<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getStreamPositionUsForContent(long,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">getStreamPositionUsForContent</a></span>&#8203;(long&nbsp;positionUs,
237                             int&nbsp;nextAdGroupIndex,
238                             <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</code></th>
239<td class="colLast">
240<div class="block">Returns the position in the underlying server-side inserted ads stream for a position in a
241 content <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</div>
242</td>
243</tr>
244</table>
245<ul class="blockList">
246<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
247<!--   -->
248</a>
249<h3>Methods inherited from class&nbsp;java.lang.<a href="https://developer.android.com/reference/java/lang/Object.html" title="class or interface in java.lang" class="externalLink" target="_top">Object</a></h3>
250<code><a href="https://developer.android.com/reference/java/lang/Object.html#clone()" title="class or interface in java.lang" class="externalLink">clone</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang" class="externalLink">equals</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang" class="externalLink">finalize</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang" class="externalLink">getClass</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang" class="externalLink">hashCode</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang" class="externalLink">notify</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang" class="externalLink">notifyAll</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang" class="externalLink">toString</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://developer.android.com/reference/java/lang/Object.html?is-external=true#wait(long,int)" title="class or interface in java.lang" class="externalLink" target="_top">wait</a></code></li>
251</ul>
252</li>
253</ul>
254</section>
255</li>
256</ul>
257</div>
258<div class="details">
259<ul class="blockList">
260<li class="blockList">
261<!-- ============ METHOD DETAIL ========== -->
262<section role="region">
263<ul class="blockList">
264<li class="blockList"><a id="method.detail">
265<!--   -->
266</a>
267<h3>Method Detail</h3>
268<a id="addAdGroupToAdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState,long,long,long...)">
269<!--   -->
270</a>
271<ul class="blockList">
272<li class="blockList">
273<h4>addAdGroupToAdPlaybackState</h4>
274<pre class="methodSignature">@CheckResult
275public static&nbsp;<a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;addAdGroupToAdPlaybackState&#8203;(<a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState,
276                                                          long&nbsp;fromPositionUs,
277                                                          long&nbsp;contentResumeOffsetUs,
278                                                          long...&nbsp;adDurationsUs)</pre>
279<div class="block">Adds a new server-side inserted ad group to an <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a>.
280
281 <p>If the first ad with a non-zero duration is not the first ad in the group, all ads before
282 that ad are marked as skipped.</div>
283<dl>
284<dt><span class="paramLabel">Parameters:</span></dt>
285<dd><code>adPlaybackState</code> - The existing <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a>.</dd>
286<dd><code>fromPositionUs</code> - The position in the underlying server-side inserted ads stream at which
287     the ad group starts, in microseconds.</dd>
288<dd><code>contentResumeOffsetUs</code> - The timestamp offset which should be added to the content stream
289     when resuming playback after the ad group. An offset of 0 collapses the ad group to a
290     single insertion point, an offset of <code>toPositionUs-fromPositionUs</code> keeps the original
291     stream timestamps after the ad group.</dd>
292<dd><code>adDurationsUs</code> - The durations of the ads to be added to the group, in microseconds.</dd>
293<dt><span class="returnLabel">Returns:</span></dt>
294<dd>The updated <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a>.</dd>
295</dl>
296</li>
297</ul>
298<a id="getStreamPositionUs(com.google.android.exoplayer2.Player,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
299<!--   -->
300</a>
301<ul class="blockList">
302<li class="blockList">
303<h4>getStreamPositionUs</h4>
304<pre class="methodSignature">public static&nbsp;long&nbsp;getStreamPositionUs&#8203;(<a href="../../Player.html" title="interface in com.google.android.exoplayer2">Player</a>&nbsp;player,
305                                       <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
306<div class="block">Returns the position in the underlying server-side inserted ads stream for the current playback
307 position in the <a href="../../Player.html" title="interface in com.google.android.exoplayer2"><code>Player</code></a>.</div>
308<dl>
309<dt><span class="paramLabel">Parameters:</span></dt>
310<dd><code>player</code> - The <a href="../../Player.html" title="interface in com.google.android.exoplayer2"><code>Player</code></a>.</dd>
311<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
312<dt><span class="returnLabel">Returns:</span></dt>
313<dd>The position in the underlying server-side inserted ads stream, in microseconds, or
314     <a href="../../C.html#TIME_UNSET"><code>C.TIME_UNSET</code></a> if it can't be determined.</dd>
315</dl>
316</li>
317</ul>
318<a id="getStreamPositionUs(long,com.google.android.exoplayer2.source.MediaPeriodId,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
319<!--   -->
320</a>
321<ul class="blockList">
322<li class="blockList">
323<h4>getStreamPositionUs</h4>
324<pre class="methodSignature">public static&nbsp;long&nbsp;getStreamPositionUs&#8203;(long&nbsp;positionUs,
325                                       <a href="../MediaPeriodId.html" title="class in com.google.android.exoplayer2.source">MediaPeriodId</a>&nbsp;mediaPeriodId,
326                                       <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
327<div class="block">Returns the position in the underlying server-side inserted ads stream for a position in a
328 <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</div>
329<dl>
330<dt><span class="paramLabel">Parameters:</span></dt>
331<dd><code>positionUs</code> - The position in the <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>, in microseconds.</dd>
332<dd><code>mediaPeriodId</code> - The <a href="../MediaPeriodId.html" title="class in com.google.android.exoplayer2.source"><code>MediaPeriodId</code></a> of the <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</dd>
333<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
334<dt><span class="returnLabel">Returns:</span></dt>
335<dd>The position in the underlying server-side inserted ads stream, in microseconds.</dd>
336</dl>
337</li>
338</ul>
339<a id="getMediaPeriodPositionUs(long,com.google.android.exoplayer2.source.MediaPeriodId,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
340<!--   -->
341</a>
342<ul class="blockList">
343<li class="blockList">
344<h4>getMediaPeriodPositionUs</h4>
345<pre class="methodSignature">public static&nbsp;long&nbsp;getMediaPeriodPositionUs&#8203;(long&nbsp;positionUs,
346                                            <a href="../MediaPeriodId.html" title="class in com.google.android.exoplayer2.source">MediaPeriodId</a>&nbsp;mediaPeriodId,
347                                            <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
348<div class="block">Returns the position in a <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a> for a position in the underlying server-side
349 inserted ads stream.</div>
350<dl>
351<dt><span class="paramLabel">Parameters:</span></dt>
352<dd><code>positionUs</code> - The position in the underlying server-side inserted ads stream, in
353     microseconds.</dd>
354<dd><code>mediaPeriodId</code> - The <a href="../MediaPeriodId.html" title="class in com.google.android.exoplayer2.source"><code>MediaPeriodId</code></a> of the <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</dd>
355<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
356<dt><span class="returnLabel">Returns:</span></dt>
357<dd>The position in the <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>, in microseconds.</dd>
358</dl>
359</li>
360</ul>
361<a id="getStreamPositionUsForAd(long,int,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
362<!--   -->
363</a>
364<ul class="blockList">
365<li class="blockList">
366<h4>getStreamPositionUsForAd</h4>
367<pre class="methodSignature">public static&nbsp;long&nbsp;getStreamPositionUsForAd&#8203;(long&nbsp;positionUs,
368                                            int&nbsp;adGroupIndex,
369                                            int&nbsp;adIndexInAdGroup,
370                                            <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
371<div class="block">Returns the position in the underlying server-side inserted ads stream for a position in an ad
372 <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</div>
373<dl>
374<dt><span class="paramLabel">Parameters:</span></dt>
375<dd><code>positionUs</code> - The position in the ad <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>, in microseconds.</dd>
376<dd><code>adGroupIndex</code> - The ad group index of the ad.</dd>
377<dd><code>adIndexInAdGroup</code> - The index of the ad in the ad group.</dd>
378<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
379<dt><span class="returnLabel">Returns:</span></dt>
380<dd>The position in the underlying server-side inserted ads stream, in microseconds.</dd>
381</dl>
382</li>
383</ul>
384<a id="getMediaPeriodPositionUsForAd(long,int,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
385<!--   -->
386</a>
387<ul class="blockList">
388<li class="blockList">
389<h4>getMediaPeriodPositionUsForAd</h4>
390<pre class="methodSignature">public static&nbsp;long&nbsp;getMediaPeriodPositionUsForAd&#8203;(long&nbsp;positionUs,
391                                                 int&nbsp;adGroupIndex,
392                                                 int&nbsp;adIndexInAdGroup,
393                                                 <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
394<div class="block">Returns the position in an ad <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a> for a position in the underlying server-side
395 inserted ads stream.</div>
396<dl>
397<dt><span class="paramLabel">Parameters:</span></dt>
398<dd><code>positionUs</code> - The position in the underlying server-side inserted ads stream, in
399     microseconds.</dd>
400<dd><code>adGroupIndex</code> - The ad group index of the ad.</dd>
401<dd><code>adIndexInAdGroup</code> - The index of the ad in the ad group.</dd>
402<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
403<dt><span class="returnLabel">Returns:</span></dt>
404<dd>The position in the ad <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>, in microseconds.</dd>
405</dl>
406</li>
407</ul>
408<a id="getStreamPositionUsForContent(long,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
409<!--   -->
410</a>
411<ul class="blockList">
412<li class="blockList">
413<h4>getStreamPositionUsForContent</h4>
414<pre class="methodSignature">public static&nbsp;long&nbsp;getStreamPositionUsForContent&#8203;(long&nbsp;positionUs,
415                                                 int&nbsp;nextAdGroupIndex,
416                                                 <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
417<div class="block">Returns the position in the underlying server-side inserted ads stream for a position in a
418 content <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>.</div>
419<dl>
420<dt><span class="paramLabel">Parameters:</span></dt>
421<dd><code>positionUs</code> - The position in the content <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>, in microseconds.</dd>
422<dd><code>nextAdGroupIndex</code> - The next ad group index after the content, or <a href="../../C.html#INDEX_UNSET"><code>C.INDEX_UNSET</code></a> if
423     there is no following ad group. Ad groups from this index are not used to adjust the
424     position.</dd>
425<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
426<dt><span class="returnLabel">Returns:</span></dt>
427<dd>The position in the underlying server-side inserted ads stream, in microseconds.</dd>
428</dl>
429</li>
430</ul>
431<a id="getMediaPeriodPositionUsForContent(long,int,com.google.android.exoplayer2.source.ads.AdPlaybackState)">
432<!--   -->
433</a>
434<ul class="blockList">
435<li class="blockList">
436<h4>getMediaPeriodPositionUsForContent</h4>
437<pre class="methodSignature">public static&nbsp;long&nbsp;getMediaPeriodPositionUsForContent&#8203;(long&nbsp;positionUs,
438                                                      int&nbsp;nextAdGroupIndex,
439                                                      <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState)</pre>
440<div class="block">Returns the position in a content <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a> for a position in the underlying
441 server-side inserted ads stream.</div>
442<dl>
443<dt><span class="paramLabel">Parameters:</span></dt>
444<dd><code>positionUs</code> - The position in the underlying server-side inserted ads stream, in
445     microseconds.</dd>
446<dd><code>nextAdGroupIndex</code> - The next ad group index after the content, or <a href="../../C.html#INDEX_UNSET"><code>C.INDEX_UNSET</code></a> if
447     there is no following ad group. Ad groups from this index are not used to adjust the
448     position.</dd>
449<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a> defining the ad groups.</dd>
450<dt><span class="returnLabel">Returns:</span></dt>
451<dd>The position in the content <a href="../MediaPeriod.html" title="interface in com.google.android.exoplayer2.source"><code>MediaPeriod</code></a>, in microseconds.</dd>
452</dl>
453</li>
454</ul>
455<a id="getAdCountInGroup(com.google.android.exoplayer2.source.ads.AdPlaybackState,int)">
456<!--   -->
457</a>
458<ul class="blockListLast">
459<li class="blockList">
460<h4>getAdCountInGroup</h4>
461<pre class="methodSignature">public static&nbsp;int&nbsp;getAdCountInGroup&#8203;(<a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads">AdPlaybackState</a>&nbsp;adPlaybackState,
462                                    int&nbsp;adGroupIndex)</pre>
463<div class="block">Returns the number of ads in an ad group, treating an unknown number as zero ads.</div>
464<dl>
465<dt><span class="paramLabel">Parameters:</span></dt>
466<dd><code>adPlaybackState</code> - The <a href="AdPlaybackState.html" title="class in com.google.android.exoplayer2.source.ads"><code>AdPlaybackState</code></a>.</dd>
467<dd><code>adGroupIndex</code> - The index of the ad group.</dd>
468<dt><span class="returnLabel">Returns:</span></dt>
469<dd>The number of ads in the ad group.</dd>
470</dl>
471</li>
472</ul>
473</li>
474</ul>
475</section>
476</li>
477</ul>
478</div>
479</div>
480</main>
481<!-- ========= END OF CLASS DATA ========= -->
482<footer role="contentinfo">
483<nav role="navigation">
484<!-- ======= START OF BOTTOM NAVBAR ====== -->
485<div class="bottomNav"><a id="navbar.bottom">
486<!--   -->
487</a>
488<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
489<a id="navbar.bottom.firstrow">
490<!--   -->
491</a>
492<ul class="navList" title="Navigation">
493<li><a href="../../../../../../index.html">Overview</a></li>
494<li><a href="package-summary.html">Package</a></li>
495<li class="navBarCell1Rev">Class</li>
496<li><a href="package-tree.html">Tree</a></li>
497<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
498<li><a href="../../../../../../index-all.html">Index</a></li>
499<li><a href="../../../../../../help-doc.html">Help</a></li>
500</ul>
501</div>
502<div class="subNav">
503<ul class="navList" id="allclasses_navbar_bottom">
504<li><a href="../../../../../../allclasses.html">All&nbsp;Classes</a></li>
505</ul>
506<div>
507<script type="text/javascript"><!--
508  allClassesLink = document.getElementById("allclasses_navbar_bottom");
509  if(window==top) {
510    allClassesLink.style.display = "block";
511  }
512  else {
513    allClassesLink.style.display = "none";
514  }
515  //-->
516</script>
517<noscript>
518<div>JavaScript is disabled on your browser.</div>
519</noscript>
520</div>
521<div>
522<ul class="subNavList">
523<li>Summary:&nbsp;</li>
524<li>Nested&nbsp;|&nbsp;</li>
525<li>Field&nbsp;|&nbsp;</li>
526<li>Constr&nbsp;|&nbsp;</li>
527<li><a href="#method.summary">Method</a></li>
528</ul>
529<ul class="subNavList">
530<li>Detail:&nbsp;</li>
531<li>Field&nbsp;|&nbsp;</li>
532<li>Constr&nbsp;|&nbsp;</li>
533<li><a href="#method.detail">Method</a></li>
534</ul>
535</div>
536<a id="skip.navbar.bottom">
537<!--   -->
538</a></div>
539<!-- ======== END OF BOTTOM NAVBAR ======= -->
540</nav>
541</footer>
542</body>
543</html>
544