194 Commits

Author SHA1 Message Date
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
andrewlewis
0291bc5e2d Fix content progress reporting if there is no preroll
If there was no preroll and the pending content position was set before the
first midroll, the pending content position was never cleared so loading the ad
was never triggered.

Only set a pending content position if we know that we need to trigger playing
an ad for the current position and IMA will poll for an ad (because there is a
midroll ad group). Clearing the pending content position happens when IMA pauses
content to play the ad.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185818315
2018-02-16 12:09:03 +00:00
andrewlewis
344932af75 Fix handling of ad group load errors
IMA sometimes delivers an ad group load error just after the time of the ad
group, which is problematic now that we set the expected ad group index based on
the last returned content progress.

Only update the expected ad group index once we are within a fixed preloading
threshold of the next ad.

Also fix updating the ad group to use the new ad count, and check for ad group
load errors when we have no expected ad group defensively.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185803086
2018-02-16 12:07:43 +00:00
andrewlewis
da08b65f3b Fix handling of ad tags with only preroll and postroll ads
Content progress is only polled if there are midroll ad groups. If the ad tag
had only preroll/postroll ads, the pending content position was not provided to
IMA, which meant that the postroll ad could never play.

Only set the pending content position if there are midroll ads.

Issue: #3715

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185680803
2018-02-16 12:05:07 +00:00
andrewlewis
43cfb08207 Handle VAST_LINEAR_ASSET_MISMATCH
This error marks the current ad group as unplayable.

Issue: #3801

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185663472
2018-02-16 11:57:22 +00:00
andrewlewis
5b6344a006 Skip ads for which the media failed to prepare
Also make ad group skipping more robust. After calling onError for an ad, IMA
will sometimes trigger an ad group load error, so this needs to be handled in a
way that allows some ads to be loaded already for the ad group.

This change also fixes calculation of the expected ad index to take into account
whether the position is being faked to trigger loading an ad or is the actual
player position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185655844
2018-02-16 11:55:02 +00:00
andrewlewis
4cb2d255ab Fix handling of ad tags where ad groups are out of order
IMA's cue points may not be in order, so sort them. It looks like IMA events use
time ordered ad indices, so it is not necessary to map between the original cue
point order and the time order.

Issue: #3716

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185495798
2018-02-16 11:48:58 +00:00
andrewlewis
b6a46fd3ee Set the expected ad group based on the content position
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185139106
2018-02-16 11:44:29 +00:00
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