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
99cdf2ca
authored
Sep 11, 2020
by
bachinger
Committed by
Oliver Woodman
Sep 11, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
MediaItemify the IMA extension README and the ads page in dev guide
PiperOrigin-RevId: 331155539
parent
156166f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
extensions/ima/README.md
extensions/ima/README.md
View file @
99cdf2ca
...
@@ -26,25 +26,30 @@ locally. Instructions for doing this can be found in ExoPlayer's
...
@@ -26,25 +26,30 @@ locally. Instructions for doing this can be found in ExoPlayer's
## Using the extension ##
## Using the extension ##
To play ads alongside a single-window content
`MediaSource`
, prepare the player
To play a media item with an ad tag URI, you need to customize the
with an
`AdsMediaSource`
constructed using an
`ImaAdsLoader`
, the content
`DefaultMediaSourceFactory`
as
`MediaSource`
and an overlay
`ViewGroup`
on top of the player. Pass an ad tag
[
documented in the Developer Guide
](
https://exoplayer.dev/media-sources.html#customizing-media-source-creation
)
.
URI from your ad campaign when creating the
`ImaAdsLoader`
. The IMA
This way the player will build an
`AdsMediaSource`
and configure it with the
documentation includes some
[
sample ad tags
][]
for testing. Note that the IMA
`ImaAdsLoader`
and an
`AdViewProvider`
automatically.
extension only supports players which are accessed on the application's main
[
Pass an ad tag URI
](
https://exoplayer.dev/media-items.html#ad-insertion
)
from
your ad campaign to the
`MediaItem.Builder`
when building your media item. The
IMA documentation includes some
[
sample ad tags
][]
for testing. Note that the
IMA extension only supports players which are accessed on the application's main
thread.
thread.
Resuming the player after entering the background requires some special handling
Resuming the player after entering the background requires some special handling
when playing ads. The player and its media source are released on entering the
when playing ads. The player and its media source are released on entering the
background, and are recreated when the player returns to the foreground. When
background, and are recreated when the player returns to the foreground. When
playing ads it is necessary to persist ad playback state while in the background
playing ads it is necessary to persist ad playback state while in the background
by keeping a reference to the
`ImaAdsLoader`
. Reuse it when resuming playback of
by keeping a reference to the
`ImaAdsLoader`
. Reuse this instance when your
the same content/ads by passing it in when constructing the new
callback
`AdsLoaderProvider.getAdsLoader(Uri adTagUri)`
is called by the player
`AdsMediaSource`
. It is also important to persist the player position when
to get an
`ImaAdsLoader`
for the same content/ads to be resumed. It is also
entering the background by storing the value of
`player.getContentPosition()`
.
important to persist the player position when entering the background by storing
On returning to the foreground, seek to that position before preparing the new
the value of
`player.getContentPosition()`
. On returning to the foreground, seek
player instance. Finally, it is important to call
`ImaAdsLoader.release()`
when
to that position before preparing the new player instance. Finally, it is
playback of the content/ads has finished and will not be resumed.
important to call
`ImaAdsLoader.release()`
when playback of the content/ads has
finished and will not be resumed.
You can try the IMA extension in the ExoPlayer demo app, which has test content
You can try the IMA extension in the ExoPlayer demo app, which has test content
in the "IMA sample ad tags" section of the sample chooser. The demo app's
in the "IMA sample ad tags" section of the sample chooser. The demo app's
...
...
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