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
cfcbd211
authored
Oct 21, 2018
by
ogaclejapan
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow setting the ad UI elements to be rendered in ImaAdsLoader
parent
861b8169
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
View file @
cfcbd211
...
@@ -40,6 +40,7 @@ import com.google.ads.interactivemedia.v3.api.AdsRequest;
...
@@ -40,6 +40,7 @@ import com.google.ads.interactivemedia.v3.api.AdsRequest;
import
com.google.ads.interactivemedia.v3.api.CompanionAdSlot
;
import
com.google.ads.interactivemedia.v3.api.CompanionAdSlot
;
import
com.google.ads.interactivemedia.v3.api.ImaSdkFactory
;
import
com.google.ads.interactivemedia.v3.api.ImaSdkFactory
;
import
com.google.ads.interactivemedia.v3.api.ImaSdkSettings
;
import
com.google.ads.interactivemedia.v3.api.ImaSdkSettings
;
import
com.google.ads.interactivemedia.v3.api.UiElement
;
import
com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider
;
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
;
import
com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate
;
import
com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate
;
...
@@ -69,6 +70,7 @@ import java.util.Collection;
...
@@ -69,6 +70,7 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
/** Loads ads using the IMA SDK. All methods are called on the main thread. */
/** Loads ads using the IMA SDK. All methods are called on the main thread. */
public
final
class
ImaAdsLoader
public
final
class
ImaAdsLoader
...
@@ -91,6 +93,7 @@ public final class ImaAdsLoader
...
@@ -91,6 +93,7 @@ public final class ImaAdsLoader
private
@Nullable
ImaSdkSettings
imaSdkSettings
;
private
@Nullable
ImaSdkSettings
imaSdkSettings
;
private
@Nullable
AdEventListener
adEventListener
;
private
@Nullable
AdEventListener
adEventListener
;
private
@Nullable
Set
<
UiElement
>
adUiElements
;
private
int
vastLoadTimeoutMs
;
private
int
vastLoadTimeoutMs
;
private
int
mediaLoadTimeoutMs
;
private
int
mediaLoadTimeoutMs
;
private
int
mediaBitrateKbps
;
private
int
mediaBitrateKbps
;
...
@@ -136,6 +139,18 @@ public final class ImaAdsLoader
...
@@ -136,6 +139,18 @@ public final class ImaAdsLoader
}
}
/**
/**
* Sets the ad UI elements to be rendered by the IMA SDK.
*
* @param adUiElements The ad UI elements to be rendered by the IMA SDK.
* @return This builder, for convenience.
* @see AdsRenderingSettings#setUiElements(Set)
*/
public
Builder
setAdUiElements
(
Set
<
UiElement
>
adUiElements
)
{
this
.
adUiElements
=
Assertions
.
checkNotNull
(
adUiElements
);
return
this
;
}
/**
* Sets the VAST load timeout, in milliseconds.
* Sets the VAST load timeout, in milliseconds.
*
*
* @param vastLoadTimeoutMs The VAST load timeout, in milliseconds.
* @param vastLoadTimeoutMs The VAST load timeout, in milliseconds.
...
@@ -197,6 +212,7 @@ public final class ImaAdsLoader
...
@@ -197,6 +212,7 @@ public final class ImaAdsLoader
vastLoadTimeoutMs
,
vastLoadTimeoutMs
,
mediaLoadTimeoutMs
,
mediaLoadTimeoutMs
,
mediaBitrateKbps
,
mediaBitrateKbps
,
adUiElements
,
adEventListener
,
adEventListener
,
imaFactory
);
imaFactory
);
}
}
...
@@ -217,6 +233,7 @@ public final class ImaAdsLoader
...
@@ -217,6 +233,7 @@ public final class ImaAdsLoader
vastLoadTimeoutMs
,
vastLoadTimeoutMs
,
mediaLoadTimeoutMs
,
mediaLoadTimeoutMs
,
mediaBitrateKbps
,
mediaBitrateKbps
,
adUiElements
,
adEventListener
,
adEventListener
,
imaFactory
);
imaFactory
);
}
}
...
@@ -271,6 +288,7 @@ public final class ImaAdsLoader
...
@@ -271,6 +288,7 @@ public final class ImaAdsLoader
private
final
int
vastLoadTimeoutMs
;
private
final
int
vastLoadTimeoutMs
;
private
final
int
mediaLoadTimeoutMs
;
private
final
int
mediaLoadTimeoutMs
;
private
final
int
mediaBitrateKbps
;
private
final
int
mediaBitrateKbps
;
private
final
@Nullable
Set
<
UiElement
>
adUiElements
;
private
final
@Nullable
AdEventListener
adEventListener
;
private
final
@Nullable
AdEventListener
adEventListener
;
private
final
ImaFactory
imaFactory
;
private
final
ImaFactory
imaFactory
;
private
final
Timeline
.
Period
period
;
private
final
Timeline
.
Period
period
;
...
@@ -358,6 +376,7 @@ public final class ImaAdsLoader
...
@@ -358,6 +376,7 @@ public final class ImaAdsLoader
/* vastLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* vastLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* mediaLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* mediaLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* mediaBitrateKpbs= */
BITRATE_UNSET
,
/* mediaBitrateKpbs= */
BITRATE_UNSET
,
/* adUiElements= */
null
,
/* adEventListener= */
null
,
/* adEventListener= */
null
,
/* imaFactory= */
new
DefaultImaFactory
());
/* imaFactory= */
new
DefaultImaFactory
());
}
}
...
@@ -383,6 +402,7 @@ public final class ImaAdsLoader
...
@@ -383,6 +402,7 @@ public final class ImaAdsLoader
/* vastLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* vastLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* mediaLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* mediaLoadTimeoutMs= */
TIMEOUT_UNSET
,
/* mediaBitrateKbps= */
BITRATE_UNSET
,
/* mediaBitrateKbps= */
BITRATE_UNSET
,
/* adUiElements= */
null
,
/* adEventListener= */
null
,
/* adEventListener= */
null
,
/* imaFactory= */
new
DefaultImaFactory
());
/* imaFactory= */
new
DefaultImaFactory
());
}
}
...
@@ -395,6 +415,7 @@ public final class ImaAdsLoader
...
@@ -395,6 +415,7 @@ public final class ImaAdsLoader
int
vastLoadTimeoutMs
,
int
vastLoadTimeoutMs
,
int
mediaLoadTimeoutMs
,
int
mediaLoadTimeoutMs
,
int
mediaBitrateKbps
,
int
mediaBitrateKbps
,
@Nullable
Set
<
UiElement
>
adUiElements
,
@Nullable
AdEventListener
adEventListener
,
@Nullable
AdEventListener
adEventListener
,
ImaFactory
imaFactory
)
{
ImaFactory
imaFactory
)
{
Assertions
.
checkArgument
(
adTagUri
!=
null
||
adsResponse
!=
null
);
Assertions
.
checkArgument
(
adTagUri
!=
null
||
adsResponse
!=
null
);
...
@@ -403,6 +424,7 @@ public final class ImaAdsLoader
...
@@ -403,6 +424,7 @@ public final class ImaAdsLoader
this
.
vastLoadTimeoutMs
=
vastLoadTimeoutMs
;
this
.
vastLoadTimeoutMs
=
vastLoadTimeoutMs
;
this
.
mediaLoadTimeoutMs
=
mediaLoadTimeoutMs
;
this
.
mediaLoadTimeoutMs
=
mediaLoadTimeoutMs
;
this
.
mediaBitrateKbps
=
mediaBitrateKbps
;
this
.
mediaBitrateKbps
=
mediaBitrateKbps
;
this
.
adUiElements
=
adUiElements
;
this
.
adEventListener
=
adEventListener
;
this
.
adEventListener
=
adEventListener
;
this
.
imaFactory
=
imaFactory
;
this
.
imaFactory
=
imaFactory
;
if
(
imaSdkSettings
==
null
)
{
if
(
imaSdkSettings
==
null
)
{
...
@@ -952,6 +974,9 @@ public final class ImaAdsLoader
...
@@ -952,6 +974,9 @@ public final class ImaAdsLoader
if
(
mediaBitrateKbps
!=
BITRATE_UNSET
)
{
if
(
mediaBitrateKbps
!=
BITRATE_UNSET
)
{
adsRenderingSettings
.
setBitrateKbps
(
mediaBitrateKbps
);
adsRenderingSettings
.
setBitrateKbps
(
mediaBitrateKbps
);
}
}
if
(
adUiElements
!=
null
)
{
adsRenderingSettings
.
setUiElements
(
adUiElements
);
}
// Set up the ad playback state, skipping ads based on the start position as required.
// Set up the ad playback state, skipping ads based on the start position as required.
long
[]
adGroupTimesUs
=
getAdGroupTimesUs
(
adsManager
.
getAdCuePoints
());
long
[]
adGroupTimesUs
=
getAdGroupTimesUs
(
adsManager
.
getAdCuePoints
());
...
...
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