237 Commits

Author SHA1 Message Date
andrewlewis
1094da2b61 Fix player state transitions for postroll ads
Before this change, the player state would be STATE_ENDED then
STATE_BUFFERING (when the postroll ad was marked as played) then
STATE_ENDED again.

Queueing a final content media period with start point equal to
the content duration after a postroll ensures that the player
state doesn't change to STATE_ENDED transiently.

Switch from using C.TIME_END_OF_SOURCE to C.TIME_UNSET for media
periods that should not have an end point and are not followed
by an ad.

Content media periods before postrolls have end position
C.TIME_END_OF_SOURCE. If the postroll ad loads, its content
position is set to the content duration, which should be known
at the point of loading the postroll, then a final 'empty'
content media period with start position equal to its duration
is queued. If the postroll fails to load, this empty content
media period is queued up directly after the preceding content
media period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219443683
2018-10-31 13:54:15 +00:00
andrewlewis
4b9530c214 Let apps specify whether to focus skip button on ATV
Issue: #5019

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219267048
2018-10-31 13:52:36 +00:00
ogaclejapan
23666e3ac8 Fix adUiElements variables even more robust 2018-10-23 11:44:53 +09:00
ogaclejapan
090a992332 Fix setMediaBitrateKbps naming from consistency point of view 2018-10-23 11:24:41 +09:00
ogaclejapan
cfcbd2114b Allow setting the ad UI elements to be rendered in ImaAdsLoader 2018-10-21 13:54:07 +09:00
ogaclejapan
861b81694d Allow setting the ad media bitrate in ImaAdsLoader 2018-10-21 13:23:53 +09:00
tonihei
a8b851ce34 Add BasePlayer to avoid code duplication for common convenience methods.
A lot of methods just forward to other methods and there is no conceivable
way a player should implement it another way. Moving these methods to a
base player class allows to remove duplicated code across our player
implementations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215374192
2018-10-03 22:02:47 +01:00
tonihei
5c8dabade6 Add @Documented to @IntDef and @StringDef annotations.
This makes the annotations appear in the generated JavaDoc.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214952419
2018-10-01 19:22:34 +01:00
andrewlewis
d0fb4b4729 Add IMA tests to presubmit
Also fix internal build by adding some methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213828434
2018-09-21 12:14:51 +01:00
andrewlewis
e90d36cb69 Fix ImaAdsLoaderTest
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213824217
2018-09-21 12:13:13 +01:00
tonihei
e25b7d2148 Add wrapper for Log messages to allow settig the log level.
Currently there is no way to disable (or reduce) the logcat output generated
by ExoPlayer.

Issue:#4665

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213421072
2018-09-20 12:12:21 +01:00
tonihei
585806de24 Clarify doc of components which only allow a main thread player.
ExoPlayer can be run on a background thread, but some components (UI and IMA)
only support players on the main thread. This adds some documentation and
assertions for that.

To simplify assertions, this also moves the getApplicationLooper method from
ExoPlayer to Player.

Issue:#4439

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213280359
2018-09-17 17:56:36 +01:00
tonihei
d0161ad18b Fix all error-prone, style, optional suggestion, etc. issues.
This fixes or suppresses all reported issues by the code review linter tools.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210107759
2018-08-28 16:37:14 +01:00
andrewlewis
9c36773602 Fix playback of postrolls with multiple ads
At the point of starting to play a postroll, source info refreshes for future
postroll ads in the same ad group would cause a seek that incorrectly identified
the media period to play as the content media period. Fix the logic in
getAdGroupIndexForPositionUs to address this.

Also handle empty postroll ad breaks by resetting the expected ad group index
when we send content complete.

Issue: #4710
Issue: #4681

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210071054
2018-08-24 16:02:38 +01:00
olly
e2ebb78b63 Don't apply dependency check in non-app modules
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209757391
2018-08-24 15:45:57 +01:00
andrewlewis
38ea53fcdc Revert discarding empty ad breaks
The previous change was too aggressive as it would clear future ad breaks.

Still clear the pending content position so the real content position is
reported after an empty ad break.

Issue: #4681
Issue: #4622

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209752306
2018-08-24 15:41:19 +01:00
olly
bac597cb07 Update dependencies + misc fixes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208195761
2018-08-13 14:02:51 +01:00
andrewlewis
5a8af74b4b Improve handling of consecutive empty ad groups
Issue: #4030
Issue: #4280

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208055792
2018-08-13 13:55:03 +01:00
andrewlewis
4d6d7903e0 Enable IMA SDK debug mode if flag is set
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208054150
2018-08-13 13:53:48 +01:00
andrewlewis
27aa39e8c6 Upgrade IMA dependency
The IMA SDK now handles focusing the skip button so remove the workaround.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207515573
2018-08-06 11:37:15 +01:00
eguven
45c1e9eef3 Add missing Nullable annotation Player.EventListener.onTimelineChanged
Issue: #4593

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=206911927
2018-08-01 13:49:21 +01:00
tonihei
ffdc17d0e0 Remove generic type parameter from TransferListener.
All known instances use DataSource as generic type and thus code can be simplified
by removing the generic type altogether.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205798542
2018-07-24 14:56:45 +01:00
andrewlewis
b654806996 Add support for setting companion ad slots
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205373398
2018-07-20 16:07:31 +01:00
andrewlewis
a26bb350ee Add IMA and FLAC tests to the codebase
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204302135
2018-07-17 20:10:20 +01:00
tonihei
abb4d6ff70 Use correct generics type bounds for TransferListener in MediaSources.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203260699
2018-07-06 14:32:46 +01:00
tonihei
98afaa60d0 Forward TransferListener to media sources.
In the future, this allows to register the BandwidthMeter (managed by the player)
as a listener to all media transfers related to this media source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202643946
2018-07-03 11:47:15 +01:00
andrewlewis
f94cef43e8 Fix ImaAdsLoader @Override for unreleased method
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202625377
2018-06-29 12:08:30 +01:00
nickchavez
6b9fb456a1 Roll forward of CL 201223315 with ExoPlayer IMA extension fix
Original change by nickchavez@nickchavez:andcsvol:3257:citc on 2018/06/19 12:41:18.

Add VolumeProvider interface to VideoAdPlayer and VideoStreamPlayer.
  - Send volume on videoDisplay.start so that it can be sent to OMID.
  - Add unit tests for AdPlayerCalback and ExoPlayerVideoAdPlayerImpl.
  - Add functional tests for client side and DAI volume updates.

Add onVolumeChanged() to VideoAdPlayerCallback and VideoStreamPlayerCallback.
  - Implement volume updates for SDK owned video player.
  - Remove mute/unmute events, which are handled in JS instead (like iOS).
  - Collect volume changes from client side and DAI video players.

External: Publisher players will now have to implement getVolume() and onVolumeChanged() for custom video players.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202324636
2018-06-28 16:18:50 +01:00
andrewlewis
9a6a72521f Make ImaAdsLoader robust to calls after it's released
Issue: #3879

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202100576
2018-06-28 16:18:50 +01:00
andrewlewis
57b7e18b23 Add a test for preroll ad playback with ImaAdsLoader
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202080962
2018-06-28 16:18:50 +01:00
tonihei
156e2317cc Deprecate Player.DefaultEventListener in favor of default no-ops in interface.
The DefaultEventListener was added for selective overrides. Now that Java 8
support is enabled, these selective listener overrides can be implemented
more easily and more flexible using default methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201695490
2018-06-22 17:49:25 +01:00
andrewlewis
38096fb734 Add some Robolectric tests for ImaAdsLoader
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201484853
2018-06-22 17:35:22 +01:00
olly
8e65696f02 Update forced dependencies to fix release
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199758072
2018-06-18 10:57:43 +01:00
aquilescanta
17ab9da5b6 Enable java 8 for some missing projects
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199265539
2018-06-05 12:44:56 +01:00
andrewlewis
9852af7372 Don't advertise support for video/mpeg ads
Issue: #4297

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198536888
2018-06-05 12:26:21 +01:00
andrewlewis
c7081ed764 Update IMA and Play Services
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198536438
2018-06-05 12:25:22 +01:00
tonihei
a98d8fedfa Fix nullness errors in at least one file per module to be able to use test.
Some module/extensions couldn't use the static test so far because all files
needed to be put on the blacklist. To ensure the test it set up for all
modules, this fixes at least one file for each of the modules.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197731449
2018-06-05 12:17:54 +01:00
andrewlewis
36d24c7aaa Catch all errors in loadAd
Issue: #4231

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196180271
2018-05-12 18:52:57 +01:00
andrewlewis
2a06e00201 Expose ad load errors via MediaSourceEventListener
The old event listener on AdsMediaSource is deprecated, in favor of
reporting in the normal way (via MediaSourceEventListener).

Add AdLoadException with information on what ad/ads failed to load.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=195426144
2018-05-07 07:08:33 +01:00
andrewlewis
fdbf16ed6d Allow setting the ad media load timeout in ImaAdsLoader
Issue: #3691

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192769801
2018-04-16 10:50:32 +01:00
andrewlewis
ee8fc74d65 Update IMA to 3.8.5 and Play Services to 12.0.0
Issue: #3911

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192404702
2018-04-16 10:29:23 +01:00
tonihei
66d2b76a6c Remove test max SDK version overrides.
These don't seem to be needed anymore. All tests run without them in gradle
and Blaze.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191867518
2018-04-08 16:39:57 +01:00
olly
4c69826b9c Actually use IMA proguard configuration (oops!)
Issue: #3723

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191407560
2018-04-03 15:29:01 +01:00
olly
73048f18c1 Remove "r" from instructions for extension modules
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188038757
2018-03-07 15:24:33 +00:00
tonihei
75c3bfb55c Rename Listener for timeline update to avoid confusion with MediaSourceEventListener.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187313128
2018-03-02 09:21:28 +00:00
hoangtc
fcb796a80c Migrate ExoPlayer Gradle build files.
- Change 'compile' configuration (deprecared) to using 'implementation'
and 'api' configurations instead.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187311778
2018-03-02 09:20:02 +00:00
tonihei
b2c445776a Allow parallel reuse of media sources.
This is achieved by adding a BaseMediaSource which keeps a reference count of the
number of times the source has been prepared and forwards to the actual implementations
only once, such that only minimal changes are needed for each media source.

Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187186691
2018-03-02 09:08:28 +00:00
andrewlewis
c4f82514bf Fix ImaAdsMediaSource isTopLevelSource
AdsMediaSource must be top-level. Currently the (deprecated) ImaAdsMediaSource
can't be used because it prepares its contained AdsMediaSource as a child
source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=186990882
2018-02-26 15:41:18 +00:00
andrewlewis
56c9d023fa Fix content progress updates and position faking
Occasionally the player could transition from playing content to playing an ad
after IMA called playAd. The discontinuity triggered faking the content
position, and the fake position was passed to IMA when content resumed causing
the wrong ad group to be loaded. Fix this by only faking the position if the
player transitions before playAd.

Also fix the calculation of the expected ad group index for a postroll ad, and
wait for the player to transition back from ad to content before passing a
content progress update.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185994229
2018-02-19 13:21:53 +00:00
andrewlewis
6c3b677ddb Catch exceptions in all IMA callbacks
If an exception is thrown in an IMA callback it crashes the process with lots of
logging from WebView (including several stack traces, etc.). This change wraps
ImaAdsLoader code that might throw, skips any remaining ads (as the errors are
not recoverable, in general) and notifies a new load error callback so that the
application can implement its own handling. The intention is to make the loader
robust to unexpected requests from IMA and avoid crashes.

Also handle IMA loading an ad in an ad group that has no available ads. In rare
cases IMA will try to load an ad for which an error was previously notified, so
this drops those load requests allowing playback of the content to continue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185985850
2018-02-19 13:20:15 +00:00