380 Commits

Author SHA1 Message Date
andrewlewis
ac2f6cbf98 Move two further methods from Timeline to AdPlaybackState
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185138158
2018-02-16 11:43:31 +00:00
andrewlewis
6fc70149b5 Fix ad group skipping
Allow skipping an ad group when requested by IMA, even if we aren't currently
playing one, to handle cases where no ads in an ad group will load (so IMA
requests resuming content but we never managed to start playing an ad).

Use the known ad group index (rather than the expected one) when handling ad
group load errors. This ensures we skip the right ad group if we notify IMA of
playback errors for every ad in the ad group, then IMA notifies that the ad
group is empty via a load error.

Also make some other miscellaneous small fixes to ads code:

- Avoid warning about unexpected ad group indices more than once.
- Output a warning if the ad count in an ad group decreases.
- Remove unnecessary assertion.
- Fix getting the ad duration for ad indices that haven't loaded yet.
- Allow setting an ad group state to its current value.
- Fix javadoc for setting the ad resume position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184831495
2018-02-08 14:49:00 +00:00
andrewlewis
165fce4c64 Get the next ad index to play in MediaPeriodQueue
The ad index in the ad group may need to skip over ads that failed to load, so
it can't just be incremented any more.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184812556
2018-02-08 14:49:00 +00:00
andrewlewis
aa63ad3af0 Handle LOG AdEvents for ad group load errors.
If IMA loads an empty VAST document for an ad group it notifies via a LOG
AdEvent. Handle the event by updating the AdPlaybackState accordingly.

The error state will be handled in ExoPlayerImplInternal in a separate change.

Issue: #3584

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184516585
2018-02-08 14:49:00 +00:00
olly
a7d4d2d21c Automated g4 rollback of changelist 184056034.
*** Reason for rollback ***

Broke everything

*** Original change description ***

Clean up message naming in EPII

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184061352
2018-02-01 15:13:51 +00:00
olly
2f932bfaf7 Clean up message naming in EPII
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184056034
2018-02-01 15:11:00 +00:00
andrewlewis
b82178ecb4 Make ad state immutable and store state of each ad
Before this change, the ad playback state stored the number of played ads in
each ad group. There was no way to represent that an ad had failed to load (and
it wouldn't be possible just to increment the played ad count to signal a load
error because there might be an unplayed ad before the ad that failed to load).

Represent the state of each ad (unavailable, available, skipped, played, error)
in each ad group. In a later change the player will use this information to
update its loaded MediaPeriods in response to future ads failing to load.

Also make the AdPlaybackState immutable and remove copying/duplication of its
fields in the ad timeline and period.

Issue: #3584

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183655308
2018-02-01 14:57:45 +00:00
olly
1f6d161d4d Fix proguard configurations
1. When we try and load something via reflection and find the
   class, always throw rather than failing silently if we
   subsequently fail to instantiate an instance. This is
   indicative of a broken proguard setup, and failing silently
   makes it hard to spot.
2. Add library/core proguard configuration to ensure extension
   renderer constructors that we access via reflection are kept.
3. Add demos/main proguard configuration to ensure ImaAdsLoader
   constructor that we access via reflection is kept.
4. Added IMA proguard file to hopefully fix #3723, although I
   wasn't actually able to reproduce the issue.

Issue: #3723

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183648187
2018-02-01 14:52:16 +00:00
tonihei
46c4ca7ddb Add CompositeMediaSource to handle common tasks for composite media sources.
This removes some boiler-plate code for compostite sources and will also
simplify resuing media source in the future (because this class can keep track
of child listeners).

Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183387123
2018-02-01 14:33:15 +00:00
andrewlewis
d240249b6c Work around missed ad LOADED events
Track the expected next ad group index so that it can be used as a fallback if
IMA does not notify the ad index via a LOADED event.

Also do some miscellaneous minor cleanup (including logging all LOG events, and
logging at debug level where appropriate).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183048612
2018-01-24 10:33:29 +00:00
andrewlewis
682953c411 Fix typos
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180778084
2018-01-04 15:54:01 +00:00
andrewlewis
8e35bffcc3 Use playAd/stopAd to control position updates switching
Previously the ad/content progress updates were toggled based on whether the
player was playing ads or content. After this change, we switch based on
whether playAd/stopAd has been called instead.

This seems to resolve an issue where occasionally the player would get stuck at
the start of an ad, but as I don't have a root cause for that issue and it's
only sporadically reproducible I'm not certain this is a reliable fix.

Issue: #3525

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179169296
2017-12-15 12:15:20 +00:00
andrewlewis
e913ede77e Fix condition for detecting that an ad has ended
onEnded was being called also for content finishing, as in this case the playing
ad index changed (from INDEX_UNSET to 0). Fix this test so we only detect ads
finishing.

Also add logging for onEnded callbacks.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179167737
2017-12-15 12:12:32 +00:00
andrewlewis
65360760c2 Pass -1 not C.TIME_UNSET when duration is unknown
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179165479
2017-12-15 12:11:07 +00:00
andrewlewis
e2bba1567e Add Builder for ImaAdsLoader and allow early requestAds
Also fix propagation of ad errors that occur when no player
is attached.

Issue: #3548
Issue: #3556

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178767997
2017-12-12 19:19:27 +00:00
andrewlewis
44a8245a1a Fix ad loading when there is no preroll
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178234009
2017-12-12 19:00:11 +00:00
andrewlewis
8b4b01c7f6 Skip ads before the initial player position
Issue: #3527

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178218391
2017-12-12 18:56:01 +00:00
andrewlewis
59f6b059b0 Make one ad request in ImaAdsLoader
This fixes an issue where quickly detaching and reattaching the player might
cause ads to be requested multiple times with both responses handled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177922167
2017-12-12 18:33:15 +00:00
andrewlewis
7792f667d4 Fix setting supported ad MIME types without preloading
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177810991
2017-12-04 17:39:43 +00:00
andrewlewis
fbccdf594a Use AdaptiveMediaSourceEventListener for ExtractorMediaSource
This is a step towards harmonizing the MediaSource Builders and (potentially)
providing MediaSource factories.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177783157
2017-12-04 17:38:11 +00:00
andrewlewis
2282527821 Allow setting supported formats on AdsLoaders
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177175377
2017-12-04 17:38:11 +00:00
tonihei
aac53cac56 Add reason to onTimelineChanged.
Currently onTimelineChanged doesn't allow to distinguish easily between the
different reasons why it's being called. Especially, finding
out whether a new media source has been prepared or the current source
refreshed dynamically was impossible without tightly coupling the player
operations with the listener.

The new reasons provide this disdinction by either indicating a newly
initialized media source, a dynamic update to an existing timeline
or manifest, or a reset of the player (which usually results in an
empty timeline).

The original onTimelineChanged method without reason is kept in the
DefaultEventListener as deprecated to prevent the need to update all
existing listeners in one go.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176478701
2017-11-21 13:07:46 +00:00
andrewlewis
2a685da4eb Improve robustness of ImaAdsLoader
Remove an assertion that there was a call to pause content between two
content -> ad transitions.

Also, only use the player position for resuming an ad on reattaching if the
player is currently playing an ad, in case IMA pauses content before the player
actually transitions to an ad.

Issue: #3430

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176365842
2017-11-21 13:00:36 +00:00
olly
82d0a27fd9 Fix some lint issues.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176337058
2017-11-20 13:39:03 +00:00
tonihei
4cf90e3223 Fix listener in ImaAdsMediaSource.
As MediaSource listeners now return the MediaSource in on SourceInfoRefreshed,
we need to make sure that media sources wrapping another source don't just
forward the listener, but also provide a listener wrapper. This allows to
inject the wrapper source instance in the callback.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173653307
2017-10-27 16:30:00 +01:00
andrewlewis
fc985fe4da Update IMA documentation for AdsLoader
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171533782
2017-10-11 12:29:39 +01:00
andrewlewis
e887165955 Provide a getter for IMA's AdsLoader
Issue: #3322

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171508635
2017-10-11 12:24:07 +01:00
andrewlewis
20e43ac4f8 Allow ads to be paused/resumed
Controls are still hidden while playing ads, but if the app pauses the player,
controls will be shown. During ads, the player is not seekable.

When the player enters the background then returns to the foreground, the
content period may not be prepared, so also cache the content window duration.
This means that if the app reenters the foreground while an ad is paused the
time bar can be populated.

Issue: #3303

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171123428
2017-10-11 12:18:45 +01:00
andrewlewis
ad500ca871 Replace IMA ad state booleans with an @IntDef
imaPausedInAd could only be true when imaPlayingAd was true, so there are only
three possible states.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170827974
2017-10-11 12:09:15 +01:00
tonihei
52de36c5eb Add abstract, default Player event listener.
This allows simplified listener implementations as most listeners
will not listen to all possible notifications.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170177821
2017-10-03 08:44:33 +01:00
andrewlewis
58293abc11 Remove IMA dependency and add AdsMediaSource
AdsMediaSource lives in the core library so only ImaAdsLoader remains in
the ima extension. AdsMediaSource takes an AdsLoader implementation.

ImaAdsMediaSource is deprecated rather than removed for now.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168707921
2017-09-15 23:41:59 +01:00
andrewlewis
f2aed7186e Workaround the skip ad button not being focused
Issue: #3258

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168669969
2017-09-15 23:39:19 +01:00
tonihei
7d59383cc4 Add reason to onPositionDiscontinuity.
This allows listeners to easily determine the source of the discontinuity.
Reasons can be period transitions, seeks, and internal reasons.

Listeners still using the deprecated ExoPlayer.EventListener interface were
updated to Player.EventListener.

GitHub: #3252

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168549612
2017-09-15 23:36:46 +01:00
olly
75d5adce6f Update dependency versions
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168194589
2017-09-15 23:23:16 +01:00
olly
17232f58a3 Fix position reporting during ads when period has non-zero window offset.
Reporting incorrect positions for ad playbacks was causing IMA to
think the ad wasn't playing, when in fact it was.

Issue: #3180

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167702032
2017-09-06 15:49:34 +01:00
andrewlewis
c9f31a41cd Adding missing license header in IMA build.gradle
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167496569
2017-09-04 16:31:51 +01:00
tonihei
b9a6a40539 Add listener callback for shuffle mode changes.
The listener implementations do not do anything yet.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166056933
2017-08-22 16:23:27 +01:00
olly
34960ad891 Tweak and add READMEs + remove refs to V1
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165578518
2017-08-17 22:59:34 +01:00
aquilescanta
04d76fa8fc Allow easier ExoPlayer/Cast integration
This CL adds the fundamental pieces for ExoPlayer/Cast integration and includes a
demo app to showcase this functionality. However, media queues should be supported
in the first release of this extension.

Issue:#2283

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165576892
2017-08-17 22:56:52 +01:00
andrewlewis
c449bae51a Log IMA LOG AdEvent ad data
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164267555
2017-08-04 18:00:00 +01:00
andrewlewis
287b999723 Fix detection of postroll when seeking to duration
Also mark all ads as played when the postroll plays, in the case the
player is backgrounded then resumed and the user seeks back.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164262738
2017-08-04 17:58:32 +01:00
tonihei
6f7dc974c9 Add forwarding timeline to prevent repetition of boiler-plate code.
Multiple timelines work as a wrapper around another timeline and forward
most of the method calls to the wrapped timeline. Added a base class meant to
be overridden which handles all the boiler-plate forwarding.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164117264
2017-08-04 12:28:19 +01:00
olly
78cdd08684 Add some missing @param Javadoc to extensions
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164105607
2017-08-03 14:45:45 +01:00
olly
147d5bb3b2 Fix targetSdkVersion to be consistent with gradle builds
The manifest value is always overridden in gradle builds,
so this is for internal builds only. The value should be
the same (i.e. 25!).

Also fix IMA build to force the right support library
version, attempt 2!

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164103183
2017-08-03 14:44:26 +01:00
aquilescanta
a5f9f40bf0 Replace README reference to source with reference to javadoc
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164090619
2017-08-03 14:41:48 +01:00
olly
957158b7ff Fix 2.5.0 lint errors
- Publish IMA extension
- Force IMA to use the correct version of the support library
- Add missing sr translations for repeat mode strings

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163705883
2017-07-31 21:19:42 +01:00
andrewlewis
cdeea27973 Handle release() while initializing the ads manager
Also don't detach any attached player in release() to prevent a possible
NullPointerException if ImaAdsLoader.release() runs first, then the MediaSource
is released and detaches the player. This is safe because if the loader was
attached it's guaranteed to be detached.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163673750
2017-07-31 21:13:00 +01:00
andrewlewis
1f0c85bd73 Allow apps to handle ad clicked/tapped events
Issue: #3106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163455563
2017-07-31 21:09:00 +01:00
eguven
9936bc6702 Replace iterable foreach loops with indexed for loops
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163193118
2017-07-31 20:55:34 +01:00
andrewlewis
cdfe57833d Update IMA extension README
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162742982
2017-07-21 17:36:31 +01:00