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
f24ba73b
authored
Jul 24, 2020
by
andrewlewis
Committed by
Oliver Woodman
Jul 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add setter for companion ad slots
PiperOrigin-RevId: 322965540
parent
6fb28a8d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
RELEASENOTES.md
extensions/ima/build.gradle
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
RELEASENOTES.md
View file @
f24ba73b
...
@@ -252,6 +252,8 @@
...
@@ -252,6 +252,8 @@
*
Migrate to new 'friendly obstruction' IMA SDK APIs, and allow apps to
*
Migrate to new 'friendly obstruction' IMA SDK APIs, and allow apps to
register a purpose and detail reason for overlay views via
register a purpose and detail reason for overlay views via
`AdsLoader.AdViewProvider`
.
`AdsLoader.AdViewProvider`
.
*
Add
`ImaAdsLoader.Builder.setCompanionAdSlots`
so it's possible to set
companion ad slots without accessing the
`AdDisplayContainer`
.
*
Demo app:
*
Demo app:
*
Retain previous position in list of samples.
*
Retain previous position in list of samples.
*
Replace the
`extensions`
variant with
`decoderExtensions`
and make the
*
Replace the
`extensions`
variant with
`decoderExtensions`
and make the
...
...
extensions/ima/build.gradle
View file @
f24ba73b
...
@@ -29,6 +29,7 @@ dependencies {
...
@@ -29,6 +29,7 @@ dependencies {
implementation
project
(
modulePrefix
+
'library-core'
)
implementation
project
(
modulePrefix
+
'library-core'
)
implementation
'androidx.annotation:annotation:'
+
androidxAnnotationVersion
implementation
'androidx.annotation:annotation:'
+
androidxAnnotationVersion
implementation
'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation
'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation
'com.google.guava:guava:'
+
guavaVersion
compileOnly
'org.checkerframework:checker-qual:'
+
checkerframeworkVersion
compileOnly
'org.checkerframework:checker-qual:'
+
checkerframeworkVersion
compileOnly
'org.jetbrains.kotlin:kotlin-annotations-jvm:'
+
kotlinAnnotationsVersion
compileOnly
'org.jetbrains.kotlin:kotlin-annotations-jvm:'
+
kotlinAnnotationsVersion
androidTestImplementation
project
(
modulePrefix
+
'testutils'
)
androidTestImplementation
project
(
modulePrefix
+
'testutils'
)
...
...
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
View file @
f24ba73b
...
@@ -46,6 +46,7 @@ import com.google.ads.interactivemedia.v3.api.AdsManager;
...
@@ -46,6 +46,7 @@ import com.google.ads.interactivemedia.v3.api.AdsManager;
import
com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent
;
import
com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent
;
import
com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
;
import
com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
;
import
com.google.ads.interactivemedia.v3.api.AdsRequest
;
import
com.google.ads.interactivemedia.v3.api.AdsRequest
;
import
com.google.ads.interactivemedia.v3.api.CompanionAdSlot
;
import
com.google.ads.interactivemedia.v3.api.FriendlyObstruction
;
import
com.google.ads.interactivemedia.v3.api.FriendlyObstruction
;
import
com.google.ads.interactivemedia.v3.api.FriendlyObstructionPurpose
;
import
com.google.ads.interactivemedia.v3.api.FriendlyObstructionPurpose
;
import
com.google.ads.interactivemedia.v3.api.ImaSdkFactory
;
import
com.google.ads.interactivemedia.v3.api.ImaSdkFactory
;
...
@@ -67,15 +68,17 @@ import com.google.android.exoplayer2.upstream.DataSpec;
...
@@ -67,15 +68,17 @@ import com.google.android.exoplayer2.upstream.DataSpec;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -122,6 +125,7 @@ public final class ImaAdsLoader
...
@@ -122,6 +125,7 @@ public final class ImaAdsLoader
@Nullable
private
ImaSdkSettings
imaSdkSettings
;
@Nullable
private
ImaSdkSettings
imaSdkSettings
;
@Nullable
private
AdEventListener
adEventListener
;
@Nullable
private
AdEventListener
adEventListener
;
@Nullable
private
Set
<
UiElement
>
adUiElements
;
@Nullable
private
Set
<
UiElement
>
adUiElements
;
@Nullable
private
Collection
<
CompanionAdSlot
>
companionAdSlots
;
private
long
adPreloadTimeoutMs
;
private
long
adPreloadTimeoutMs
;
private
int
vastLoadTimeoutMs
;
private
int
vastLoadTimeoutMs
;
private
int
mediaLoadTimeoutMs
;
private
int
mediaLoadTimeoutMs
;
...
@@ -180,7 +184,19 @@ public final class ImaAdsLoader
...
@@ -180,7 +184,19 @@ public final class ImaAdsLoader
* @see AdsRenderingSettings#setUiElements(Set)
* @see AdsRenderingSettings#setUiElements(Set)
*/
*/
public
Builder
setAdUiElements
(
Set
<
UiElement
>
adUiElements
)
{
public
Builder
setAdUiElements
(
Set
<
UiElement
>
adUiElements
)
{
this
.
adUiElements
=
new
HashSet
<>(
checkNotNull
(
adUiElements
));
this
.
adUiElements
=
ImmutableSet
.
copyOf
(
checkNotNull
(
adUiElements
));
return
this
;
}
/**
* Sets the slots to use for companion ads, if they are present in the loaded ad.
*
* @param companionAdSlots The slots to use for companion ads.
* @return This builder, for convenience.
* @see AdDisplayContainer#setCompanionSlots(Collection)
*/
public
Builder
setCompanionAdSlots
(
Collection
<
CompanionAdSlot
>
companionAdSlots
)
{
this
.
companionAdSlots
=
ImmutableList
.
copyOf
(
checkNotNull
(
companionAdSlots
));
return
this
;
return
this
;
}
}
...
@@ -298,6 +314,7 @@ public final class ImaAdsLoader
...
@@ -298,6 +314,7 @@ public final class ImaAdsLoader
focusSkipButtonWhenAvailable
,
focusSkipButtonWhenAvailable
,
playAdBeforeStartPosition
,
playAdBeforeStartPosition
,
adUiElements
,
adUiElements
,
companionAdSlots
,
adEventListener
,
adEventListener
,
imaFactory
);
imaFactory
);
}
}
...
@@ -322,6 +339,7 @@ public final class ImaAdsLoader
...
@@ -322,6 +339,7 @@ public final class ImaAdsLoader
focusSkipButtonWhenAvailable
,
focusSkipButtonWhenAvailable
,
playAdBeforeStartPosition
,
playAdBeforeStartPosition
,
adUiElements
,
adUiElements
,
companionAdSlots
,
adEventListener
,
adEventListener
,
imaFactory
);
imaFactory
);
}
}
...
@@ -388,6 +406,7 @@ public final class ImaAdsLoader
...
@@ -388,6 +406,7 @@ public final class ImaAdsLoader
private
final
boolean
playAdBeforeStartPosition
;
private
final
boolean
playAdBeforeStartPosition
;
private
final
int
mediaBitrate
;
private
final
int
mediaBitrate
;
@Nullable
private
final
Set
<
UiElement
>
adUiElements
;
@Nullable
private
final
Set
<
UiElement
>
adUiElements
;
@Nullable
private
final
Collection
<
CompanionAdSlot
>
companionAdSlots
;
@Nullable
private
final
AdEventListener
adEventListener
;
@Nullable
private
final
AdEventListener
adEventListener
;
private
final
ImaFactory
imaFactory
;
private
final
ImaFactory
imaFactory
;
private
final
ImaSdkSettings
imaSdkSettings
;
private
final
ImaSdkSettings
imaSdkSettings
;
...
@@ -495,6 +514,7 @@ public final class ImaAdsLoader
...
@@ -495,6 +514,7 @@ public final class ImaAdsLoader
/* focusSkipButtonWhenAvailable= */
true
,
/* focusSkipButtonWhenAvailable= */
true
,
/* playAdBeforeStartPosition= */
true
,
/* playAdBeforeStartPosition= */
true
,
/* adUiElements= */
null
,
/* adUiElements= */
null
,
/* companionAdSlots= */
null
,
/* adEventListener= */
null
,
/* adEventListener= */
null
,
/* imaFactory= */
new
DefaultImaFactory
());
/* imaFactory= */
new
DefaultImaFactory
());
}
}
...
@@ -512,6 +532,7 @@ public final class ImaAdsLoader
...
@@ -512,6 +532,7 @@ public final class ImaAdsLoader
boolean
focusSkipButtonWhenAvailable
,
boolean
focusSkipButtonWhenAvailable
,
boolean
playAdBeforeStartPosition
,
boolean
playAdBeforeStartPosition
,
@Nullable
Set
<
UiElement
>
adUiElements
,
@Nullable
Set
<
UiElement
>
adUiElements
,
@Nullable
Collection
<
CompanionAdSlot
>
companionAdSlots
,
@Nullable
AdEventListener
adEventListener
,
@Nullable
AdEventListener
adEventListener
,
ImaFactory
imaFactory
)
{
ImaFactory
imaFactory
)
{
checkArgument
(
adTagUri
!=
null
||
adsResponse
!=
null
);
checkArgument
(
adTagUri
!=
null
||
adsResponse
!=
null
);
...
@@ -525,6 +546,7 @@ public final class ImaAdsLoader
...
@@ -525,6 +546,7 @@ public final class ImaAdsLoader
this
.
focusSkipButtonWhenAvailable
=
focusSkipButtonWhenAvailable
;
this
.
focusSkipButtonWhenAvailable
=
focusSkipButtonWhenAvailable
;
this
.
playAdBeforeStartPosition
=
playAdBeforeStartPosition
;
this
.
playAdBeforeStartPosition
=
playAdBeforeStartPosition
;
this
.
adUiElements
=
adUiElements
;
this
.
adUiElements
=
adUiElements
;
this
.
companionAdSlots
=
companionAdSlots
;
this
.
adEventListener
=
adEventListener
;
this
.
adEventListener
=
adEventListener
;
this
.
imaFactory
=
imaFactory
;
this
.
imaFactory
=
imaFactory
;
if
(
imaSdkSettings
==
null
)
{
if
(
imaSdkSettings
==
null
)
{
...
@@ -595,6 +617,9 @@ public final class ImaAdsLoader
...
@@ -595,6 +617,9 @@ public final class ImaAdsLoader
}
}
adDisplayContainer
=
adDisplayContainer
=
imaFactory
.
createAdDisplayContainer
(
adViewGroup
,
/* player= */
componentListener
);
imaFactory
.
createAdDisplayContainer
(
adViewGroup
,
/* player= */
componentListener
);
if
(
companionAdSlots
!=
null
)
{
adDisplayContainer
.
setCompanionSlots
(
companionAdSlots
);
}
adsLoader
=
imaFactory
.
createAdsLoader
(
context
,
imaSdkSettings
,
adDisplayContainer
);
adsLoader
=
imaFactory
.
createAdsLoader
(
context
,
imaSdkSettings
,
adDisplayContainer
);
adsLoader
.
addAdErrorListener
(
componentListener
);
adsLoader
.
addAdErrorListener
(
componentListener
);
adsLoader
.
addAdsLoadedListener
(
componentListener
);
adsLoader
.
addAdsLoadedListener
(
componentListener
);
...
...
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