15023 Commits

Author SHA1 Message Date
christosts
92686b3377 Minor fix in transforming-media.md
PiperOrigin-RevId: 504281747
(cherry picked from commit 4c1be4c7a1eed2eec714cfaf854683c21dbfec93)
2023-01-26 14:27:46 +00:00
kimvde
128fed81ca Undo unreleased changes from transforming-media.md
The "Transforming media" page has been updated with changes that won't
be part of the next release. Undo these changes so that this page is
consistent with the latest release.

PiperOrigin-RevId: 503917637
(cherry picked from commit fdf866617f39261f6b619dd69f56279505ae7466)
2023-01-25 18:29:36 +00:00
ibaker
197109eb69 Explicitly document most Player.Listener methods in terms of getters
This makes it implicitly clear that if the value of a getter changes due
to a change in command availability then the listener will be invoked,
without needing to explicitly document every command on every listener
method.

#minor-release

PiperOrigin-RevId: 503178383
(cherry picked from commit aa23920e148191f36b4d9f9d1fd9924e13855762)
2023-01-25 18:29:36 +00:00
tonihei
b1693860fa Extend command GET_CURRENT_MEDIA_ITEM to more methods.
We currently only document it for the getCurrentMediaItem(), but
the command was always meant to cover all information about the
current media item and the position therein.

To correctly hide information for controllers, we need to filter
the Timeline when bundling the PlayerInfo class if only this
command is available.

PiperOrigin-RevId: 503098124
(cherry picked from commit 5e9c9ed2346d7fcb10bfa0ffa5f253d7fdc7acc8)
2023-01-25 18:29:36 +00:00
tonihei
ea1301a531 Correctly filter PlayerInfo by available getter commands.
When bundling PlayerInfo, we need to remove information if the
controller is not allowed to access it. This was only partially
done at the moment.

PiperOrigin-RevId: 502852798
(cherry picked from commit 50f066d63425f44f51108d654006f470d76fb042)
2023-01-25 18:29:36 +00:00
rohks
31aae7782e Fix javadoc references to writeSampleData
PiperOrigin-RevId: 502821506
(cherry picked from commit 8fcd6bbffc6d67cf007d09f0230256b3ed551fd8)
2023-01-25 18:29:36 +00:00
tonihei
7f20729117 Make availableCommands known when bundling PlayerInfo
When bundling PlayerInfo, we remove data when the controller is not
allowed to access this data via getters. We also remove data for
performance reasons. In the toBundle() method, it's currently hard to
make the connection between allowed commands and filtering, because
the values are checked at a different place. This can be made more
readable by forwarding the applicable Commands directly.

The only functional fix is to filter the Timeline when sending the
first PlayerInfo after a connecting a controller if the command to
get the Timeline is not available. This also allows us to remove a
path to filter MediaItems from Timelines as it isn't used.

PiperOrigin-RevId: 502607391
(cherry picked from commit 5461d5cbf1cee5bf85bb3b7ae4f4f22c2c2538b8)
2023-01-25 18:29:36 +00:00
Googler
cebc0fa374 Disables play/pause button when there's nothing to play
PiperOrigin-RevId: 502571320
(cherry picked from commit 345f2345c74ccbbf3dd49f125b1b81938b0a9995)
2023-01-25 18:29:36 +00:00
bachinger
4b3c74fb37 Clarify what default settings are being used for SSAI AdsLoader
PiperOrigin-RevId: 502388865
(cherry picked from commit 26e1a28176d8520890802c0a50aec8bc710eb2c3)
2023-01-25 18:29:36 +00:00
bachinger
8f37ad6bf8 Add AdsLoader.focusSkipButton()
This method allows to call through to `StreamManager.focus()` of the currently playing SSAI stream.

PiperOrigin-RevId: 501399144
(cherry picked from commit 0ba0c0ed43fbcf4a57f6fc91829ba00d72e3672f)
2023-01-25 18:29:36 +00:00
bachinger
fc4415bab4 Document that DownloadService needs notification permissions
Starting with Android 13 (API 33) an app needs to request the
permission to post notifications or notifications are suppressed.
This change documents this in the class level JavaDoc of the
`DownloadService`.

Issue: google/ExoPlayer#10884
PiperOrigin-RevId: 501346908
(cherry picked from commit 055ed77433944fc31d431d65e09514e8b3e250f1)
2023-01-25 18:29:36 +00:00
bachinger
b1b9c1207b Request notification permission in demo app for API 33+
Starting with API 33 the POST_NOTIFICATION permission needs to be
requested at runtime or the notification is not shown.

Note that with an app with targetSdkVersion < 33
but on a device with API 33 the notification permission is automatically
requested when the app starts for the first time. If the user does not
grant the permission, requesting the permission at runtime result in
an empty array of grant results.

Issue: google/ExoPlayer#10884
PiperOrigin-RevId: 501320632
(cherry picked from commit 6bacbaac548d612e85647b4d13c22dae0401447e)
2023-01-25 18:29:36 +00:00
bachinger
61eeb8b15e Add focusSkipButtonWhenAvailable to focus UI on ATV
For TV devices the skip button needs to have the focus to be accessible with
the remote control. This property makes this configurable while being set to
true by default.

PiperOrigin-RevId: 501077608
(cherry picked from commit d2898b70ead3b2ad1244a730c3b456146755c138)
2023-01-25 18:29:36 +00:00
tonihei
f4386071d7 Update bandwidth meter estimates
PiperOrigin-RevId: 501010994
(cherry picked from commit 09a15fb73103c406965856de4d120a5028bb37b5)
2023-01-25 18:29:36 +00:00
rohks
0b95e2ca01 Initialise fields used for bundling as String directly
Initialising the fields as Integer and then getting a String on compute
time is slow. Instead we directly initialise these fields as String.
Improves the time taken in bundling PlayerInfo further to less than
200ms from ~300ms.

Also modified a test to improve productive coverage.

PiperOrigin-RevId: 500003935
(cherry picked from commit d49437c6e112e60e9c85edeef73a73bce7de939a)
2023-01-25 18:29:35 +00:00
rohks
f9ae0a6298 Fix typo in DefaultTrackSelector.Parameters field
PiperOrigin-RevId: 499905136
(cherry picked from commit bdd6818c14f97ba305d008c963fd2c369fab312c)
2023-01-25 18:29:35 +00:00
Googler
25e6f628d3 Throw a ParserException instead of a NullPointerException if the sample table (stbl) is missing a required sample description (stsd).
As per the javadoc for AtomParsers.parseTrack, ParserException should be "thrown if the trak atom can't be parsed."

PiperOrigin-RevId: 499522748
(cherry picked from commit bbe78b10c125529d039fea9bf0117cc04d2a3532)
2023-01-25 18:29:35 +00:00
rohks
f3a1f2fa15 Optimise bundling for Timeline.Window and Timeline.Period
Improves the time taken to construct playerInfo from its bundle from ~400 ms to ~300 ms.

Also made `Timeline.Window.toBundle(boolean excludeMediaItem)` public as it was required to assert a condition in tests.

PiperOrigin-RevId: 499512353
(cherry picked from commit 2a77f1e2f96684c8c2e0b27e4118635af0724811)
2023-01-25 18:29:35 +00:00
rohks
fea5eea687 Check bundles in MediaItem to verify keys are skipped
Added another check in each of these tests to make sure we don't add keys to bundle for fields with default values.

Also fixed comments of similar changes in `AdPlaybackStateTest` and `MediaMetadataTest`.

PiperOrigin-RevId: 499463581
(cherry picked from commit 9d431a52ef7a39772f65b8de170a225848be5251)
2023-01-25 18:29:35 +00:00
bachinger
25c964d71d Remove player listener on the application thread of the player
PiperOrigin-RevId: 497183220
(cherry picked from commit 965606f7a7626b95087845191f9b6d4c33ced2e7)
2023-01-25 18:29:35 +00:00
ibaker
1e97da9472 Enable RTL support in the demo app
We might as well keep this enabled by default, rather than having to
manually toggle it on to investigate RTL issues like Issue: androidx/media#227.

PiperOrigin-RevId: 497159744
(cherry picked from commit 010c6b96e74979370f139f8126c176ea7b279313)
2023-01-25 18:29:35 +00:00
ibaker
ee72778a42 Fix order of playback controls in RTL layout
Issue: androidx/media#227

#minor-release

PiperOrigin-RevId: 497159283
(cherry picked from commit 8313af1677507fb0cc51d53e81bf930f1a954c87)
2023-01-25 18:29:35 +00:00
rohks
9b11686ef6 Optimise bundling for AdPlaybackState using AdPlaybackState.NONE
Did not do this optimisation for `AdPlaybackState.AdGroup` as its length is zero for `AdPlaybackState` with no ads.

No need to pass default values while fetching keys, which we always set in `AdPlaybackState.AdGroup.toBundle()`.

PiperOrigin-RevId: 496995048
(cherry picked from commit f2eac2df711cad579f3042568a24c1f51a119428)
2023-01-25 18:29:35 +00:00
rohks
e4fa94abe3 Check MediaMetadata bundle to verify keys are skipped
Added another check in test to make sure we don't add keys to bundle for fields with `null` values.

PiperOrigin-RevId: 496948705
(cherry picked from commit 890fd0a9fb135e938dc465d936b24065c65dbb98)
2023-01-25 18:29:35 +00:00
bachinger
0417dbae78 Bump IMA SDK version to 3.29.0
Issue: google/ExoPlayer#10845
PiperOrigin-RevId: 496947392
(cherry picked from commit 8ed515880a0b6c05b766e868e2ef931b886925cc)
2023-01-25 18:29:35 +00:00
bachinger
a212bc9bb1 Update migration script
Issue: google/ExoPlayer#10854
PiperOrigin-RevId: 496922055
(cherry picked from commit 8e9f83867b5c9536488cf74f06c4cf2535ef848f)
2023-01-25 18:29:35 +00:00
ibaker
3cb0195c18 Fix recursive loop when registering controller visibility listeners
There are two overloads of this method due to a type 'rename' from
`PlayerControlView.VisibilityListener` to
`PlayerView.ControllerVisibilityListener`. Currently when you call one
overload it passes `null` to the other one (to clear the other listener).
Unfortunately this results in it clearing itself, because it receives
a null call back!

This change tweaks the documentation to clarify that the 'other'
listener is only cleared if you pass a non-null listener in. This solves
the recursive problem, and allows the 'legacy' visibility listener to be
successfully registered.

Issue: androidx/media#229

#minor-release

PiperOrigin-RevId: 496876397
(cherry picked from commit 37fd65a8e51ddba92584109217114d9f2c2f009d)
2023-01-25 18:29:35 +00:00
tonihei
7afdc9edae Add error messages to correctness assertions in SimpleBasePlayer
Users of this class may run into these assertions when creating the
State and they need to check the source code to understand why
the State is invalid. Adding error messages to all our correctness
assertions helps to understand the root cause more easily.

PiperOrigin-RevId: 496875109
(cherry picked from commit b7e887a58dff7615926f8002ee3210b3071c5537)
2023-01-25 18:29:35 +00:00
ibaker
de203fe084 Document the relationship between Player methods and available commands
#minor-release

PiperOrigin-RevId: 496668378
(cherry picked from commit 54e79689e925a2a18bc02522d4f7f73dcfb35d83)
2023-01-25 18:29:35 +00:00
ibaker
730f3a3a64 Clarify some Player command and method javadoc
#minor-release

PiperOrigin-RevId: 496661152
(cherry picked from commit f47ad3c2d097a557bd2222a5b104e7867aef585d)
2023-01-25 18:29:35 +00:00
ibaker
beeb6e7eed Fix Dackka error due to param name mismatch
https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter#seekTo(long)

#minor-release

PiperOrigin-RevId: 496378709
(cherry picked from commit d2a3d8f6fabb6d22ac28a76379725d0915344cba)
2023-01-25 18:29:35 +00:00
ibaker
65daec3596 Remove ellipsis from Player javadoc
PiperOrigin-RevId: 496377192
(cherry picked from commit 844428ea329754118b8c0a2d58373415f539d725)
2023-01-25 18:29:35 +00:00
tonihei
2c17c6ef04 Add playlist and seek operations to SimpleBasePlayer
These are the remaining setter operations. They all share the same
logic that handles playlist and/or position changes. The logic to
create the placeholder state is mostly copied from ExoPlayerImpl's
maskTimelineAndPosition and getPeriodPositonUsAfterTimelineChanged.

PiperOrigin-RevId: 496364712
(cherry picked from commit 09d37641d1ef3b8cf26dc39cfcd317ebe3ef5c79)
2023-01-25 18:29:35 +00:00
tonihei
0ab7c752d7 Check if codec still exists before handling tunneling events
The tunneling callbacks are sent via Handler messages and may be
handled after the codec/surface was changed or released.

We already guard against the codec/surface change condition by
creating a new listener and verifying that the current callback
happens for the correct listener instance, but we don't guard
against a released codec yet.

PiperOrigin-RevId: 495882353
(cherry picked from commit 5e23b8bfd5a9a9542c2ab8d23ae51c1689d8ff51)
2023-01-25 18:29:34 +00:00
tonihei
f1784862e0 Clarify behavior for out-of-bounds indices and align implementations
Some Player methods operate relative to existing indices in the
playlist (add,remove,move,seek). As these operations may be issued
from a place with a stale playlist (e.g. a controller that sends
a command while the playlist is changing), we have to handle out-
of-bounds indices gracefully. In most cases this is already
documented and implemented correctly. However, some cases are not
documented and the existing player implementations don't handle
these cases consistently (or in some cases not even correctly).

PiperOrigin-RevId: 495856295
(cherry picked from commit a1c0b10482baffc3721561446ee4bb788d8a1231)
2023-01-25 18:29:34 +00:00
rohks
4b7a005340 Rename EMPTY_MEDIA_ITEM to PLACEHOLDER_MEDIA_ITEM
The `MediaItem` instances in the following cases are not actually empty but acts as a placeholder. `EMPTY_MEDIA_ITEM` can also be confused with `MediaItem.EMPTY`.

PiperOrigin-RevId: 495843012
(cherry picked from commit 74559b4a188e476378f3f0df908598ce763d909a)
2023-01-25 18:29:34 +00:00
bachinger
5ff90692b6 Use theme when loading drawables on API 21+
Issue: androidx/media#220
PiperOrigin-RevId: 495642588
(cherry picked from commit 33f8f406929c739e98bbea475b3609beb7db2b5f)
2023-01-25 18:29:34 +00:00
rohks
b9fd7fd431 Remove parameters with null values from bundle in MediaMetadata
Improves the time taken to construct `playerInfo` from its bundle from ~450 ms to ~400 ms. Each `MediaItem` inside `Timeline.Window` contains `MediaMetadata` and hence is a good candidate for bundling optimisations. There already exists a test to check all parameters for null values when unset.

PiperOrigin-RevId: 495614719
(cherry picked from commit 8dea624c980ff65aece63c6aeecdeef894470231)
2023-01-25 18:29:34 +00:00
tonihei
8e2692dc9c Allow unset index and position values + remove period index
This simplifies some position tracking needs for an app implementing
SimpleBasePlayer.
 - The period index can always be derived from the media item index
   and the position. So there is no need to set it separately.
 - The media item index can be left unset in the State in case the app
   doesn't care about the value or wants to set it the default start
   index (e.g. while the playlist is still empty where UNSET is
   different from zero).
 - Similarly, we should allow to set the content position (and buffered
   position) to C.TIME_UNSET to let the app ignore it or indicate the
   default position explictly.

PiperOrigin-RevId: 495352633
(cherry picked from commit 91557ac9d4eaf83e68f563373541dc8e12043e00)
2023-01-25 18:29:34 +00:00
tonihei
0e921d1a7a Clear one-off events from state as soon as they are triggered.
This ensures they are not accidentally triggered again when
the state is rebuilt with a buildUpon method.

PiperOrigin-RevId: 495280711
(cherry picked from commit fa5aaf958d616d831d50fdaceb02d3ff3cbad0fa)
2023-01-25 18:29:34 +00:00
rohks
951fea231d Remove parameters with default values from bundle in MediaItem
This improves the time taken to construct PlayerInfo from bundle from ~600ms to ~450ms.

PiperOrigin-RevId: 495055355
(cherry picked from commit 7de47fe2a1493da1b0720ddeb357052d2b1dc5bb)
2023-01-25 18:29:34 +00:00
rohks
aa2158d5c8 Document the reason for defining private method defaultIfNull
PiperOrigin-RevId: 495004732
(cherry picked from commit c3ca71fda738772dccc5a5e07293c884d2194f0a)
2023-01-25 18:29:34 +00:00
tonihei
47b811e3b9 Reset isLoading when calling SimpleBasePlayer.stop/release
isLoading is not allowed to be true when IDLE, so we have to set to
false when stopping in case it was set to true before.

PiperOrigin-RevId: 494975405
(cherry picked from commit e4f0b73aa325d096b493bd646c63bc6a4bf5880b)
2023-01-25 18:29:34 +00:00
tonihei
b9365f5563 Forward seek command details to seekTo method in BasePlayer
BasePlayer simplifies implementations by handling all the various
seek methods and forwarding to a single method that can then be
implemented by subclasses. However, this loses the information about
the concrete entry point used for seeking, which is relevant when
the subclass wants to verify or filter by Player.Command. This
can be improved by adding the command as a new parameter. Since
we have to change the method anyway, we can also incorporate the
boolean flag about whether the current item is repeated to avoid
the separate method.

PiperOrigin-RevId: 494948094
(cherry picked from commit 6e0f1f10b3666e6c2c74fc5a154dec3f0e03fecb)
2023-01-25 18:29:34 +00:00
tonihei
3dfbfd3f05 Clarify and correct allowed multi-threading for some Player methods
Some Player methods like getting the Looper and adding listeners
were always allowed to be called from any thread, but this is
undocumented. This change makes the threading rules of these
methods more explicit.

Removing listeners was never meant to be called from another thread
and we also don't support it safely because final callbacks may
be triggered from the wrong thread. To find potential issues, we
can assert the correct thread when releasing listeners.

Finally, there is a potential race condition when calling addListener
from a different thread at the same time as release, which may lead to
a registered listener that could receive callbacks after the player is
released.

PiperOrigin-RevId: 493843981
(cherry picked from commit e9364b0f6e1a104de9cf4393daab521edc4eccf4)
2023-01-25 18:29:34 +00:00
tonihei
45664162d9 Remove debug timeout multiplier.
It looks like this was added accidentally in <unknown commit>.

PiperOrigin-RevId: 493834134
(cherry picked from commit f8e4e1765f3bc956e1e6e9eb17d72cb6c152282c)
2023-01-25 18:29:34 +00:00
tonihei
a599289bdc Replace MediaMetadata folderType by isBrowsable
The folder type has a mix of information about the item. It shows
whether the item is browsable (type != FOLDER_TYPE_NONE) and
which Bluetooth folder type to set for legacy session information.

It's a lot clearer to split this into a boolean isBrowsable and
use the existing mediaType to map back to the bluetooth folder type
where required.

folderType is not marked as deprecated yet as this would be an API
change, which will be done later.

PiperOrigin-RevId: 493544589
(cherry picked from commit 9d059352cff0a75f0f9c4e37010bbfa2fc6079fd)
2023-01-25 18:29:34 +00:00
tonihei
a65d9e956d Support release in SimpleBasePlayer
This adds support for the release handling. To align with the
established behavior in ExoPlayer, the player can only call
listeners from within the release methods (and not afterwards)
and automatically enforces an IDLE state (without listener call)
in case getters of the player are used after release.

PiperOrigin-RevId: 493543958
(cherry picked from commit 3a66c28d4f0fc6bbd7af3f5846a5645aa3ccf778)
2023-01-25 18:29:34 +00:00
ibaker
d2d45dbe17 Add javadoc links to README files
Fix some other link titles and destinations spotted along the way.

#minor-release

PiperOrigin-RevId: 493276172
(cherry picked from commit c006575d4306f9bfad9c6f27d964fab00a6e1718)
2023-01-25 18:29:34 +00:00
tonihei
5fd6ce5e2e Fix threading of onFallbackApplied callback
The callback is currently triggered on the ExoPlayer playback thread
instead of the app thread that added the listener.

PiperOrigin-RevId: 492474405
(cherry picked from commit f3fc4fb9735a4b67a3740b3796495017eb5c978c)
2023-01-25 18:29:03 +00:00