From b999977c9d024ac54d5b770185eaa72828cd7cec Mon Sep 17 00:00:00 2001 From: olly Date: Sat, 12 Sep 2020 22:57:39 +0100 Subject: [PATCH] Dev guide: Copy editing Also changed the links that describe configuring the player for ad insertion to link to the ads page. PiperOrigin-RevId: 331349846 --- extensions/ima/README.md | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/extensions/ima/README.md b/extensions/ima/README.md index 54a70bd5fb..c67dfdbb5d 100644 --- a/extensions/ima/README.md +++ b/extensions/ima/README.md @@ -26,39 +26,30 @@ locally. Instructions for doing this can be found in ExoPlayer's ## Using the extension ## -To play a media item with an ad tag URI, you need to customize the -`DefaultMediaSourceFactory` as -[documented in the Developer Guide](https://exoplayer.dev/media-sources.html#customizing-media-source-creation). -This way the player will build an `AdsMediaSource` and configure it with the -`ImaAdsLoader` and an `AdViewProvider` automatically. - -[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 +To use the extension, follow the instructions on the +[Ad insertion page](https://exoplayer.dev/ad-insertion.html#declarative-ad-support) +of the developer guide. The `AdsLoaderProvider` passed to the player's +`DefaultMediaSourceFactory` should return an `ImaAdsLoader`. 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 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 -playing ads it is necessary to persist ad playback state while in the background -by keeping a reference to the `ImaAdsLoader`. Reuse this instance when your -callback `AdsLoaderProvider.getAdsLoader(Uri adTagUri)` is called by the player -to get an `ImaAdsLoader` for the same content/ads to be resumed. It is also -important to persist the player position when entering the background by storing -the value of `player.getContentPosition()`. On returning to the foreground, seek -to that position before preparing the new player instance. Finally, it is -important to call `ImaAdsLoader.release()` when playback of the content/ads has -finished and will not be resumed. +background, and are recreated when returning to the foreground. When playing ads +it is necessary to persist ad playback state while in the background by keeping +a reference to the `ImaAdsLoader`. When re-entering the foreground, pass the +same instance back when `AdsLoaderProvider.getAdsLoader(Uri adTagUri)` is called +to restore the state. It is also important to persist the player position when +entering the background by storing the value of `player.getContentPosition()`. +On returning to the foreground, seek to that position before preparing the new +player instance. Finally, it is important to call `ImaAdsLoader.release()` when +playback has finished and will not be resumed. 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 `PlayerActivity` also shows how to persist the `ImaAdsLoader` instance and the 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 ## * [ExoPlayer documentation on ad insertion][]