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
3f6e5ce6
authored
Sep 12, 2020
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Update IMA readme
parent
a5bf3f41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
24 deletions
extensions/ima/README.md
extensions/ima/README.md
View file @
3f6e5ce6
...
@@ -26,39 +26,30 @@ locally. Instructions for doing this can be found in ExoPlayer's
...
@@ -26,39 +26,30 @@ locally. Instructions for doing this can be found in ExoPlayer's
## Using the extension ##
## Using the extension ##
To play a media item with an ad tag URI, you need to customize the
To use the extension, follow the instructions on the
`DefaultMediaSourceFactory`
as
[
Ad insertion page
](
https://exoplayer.dev//ad-insertion.html#declarative-ad-support
)
[
documented in the Developer Guide
](
https://exoplayer.dev/media-sources.html#customizing-media-source-creation
)
.
of the developer guide, passing an
`AdsLoaderProvider`
that returns an
This way the player will build an
`AdsMediaSource`
and configure it with the
`ImaAdsLoader`
when configuring the player's
`DefaultMediaSourceFactory`
. Note
`ImaAdsLoader`
and an
`AdViewProvider`
automatically.
that the IMA extension only supports players which are accessed on the
application's main thread.
[
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.
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 returning to the foreground. When playing ads
playing ads it is necessary to persist ad playback state while in the background
it is necessary to persist ad playback state while in the background by keeping
by keeping a reference to the
`ImaAdsLoader`
. Reuse this instance when your
a reference to the
`ImaAdsLoader`
. When re-entering the foreground, pass the
callback
`AdsLoaderProvider.getAdsLoader(Uri adTagUri)`
is called by the player
same instance back when
`AdsLoaderProvider.getAdsLoader(Uri adTagUri)`
is called
to get an
`ImaAdsLoader`
for the same content/ads to be resumed. It is also
to restore the state. It is also important to persist the player position when
important to persist the player position when entering the background by storing
entering the background by storing the value of
`player.getContentPosition()`
.
the value of
`player.getContentPosition()`
. On returning to the foreground, seek
On returning to the foreground, seek to that position before preparing the new
to that position before preparing the new player instance. Finally, it is
player instance. Finally, it is important to call
`ImaAdsLoader.release()`
when
important to call
`ImaAdsLoader.release()`
when playback of the content/ads has
playback has finished and will not be resumed.
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
`PlayerActivity`
also shows how to persist the
`ImaAdsLoader`
instance and the
`PlayerActivity`
also shows how to persist the
`ImaAdsLoader`
instance and the
player position when backgrounded during ad playback.
player position when backgrounded during ad playback.
[
top level README
]:
https://github.com/google/ExoPlayer/blob/release-v2/README.md
[
sample ad tags
]:
https://developers.google.com/interactive-media-ads/docs/sdks/android/tags
## Links ##
## Links ##
*
[
ExoPlayer documentation on ad insertion
][]
*
[
ExoPlayer documentation on ad insertion
][]
...
...
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