15163 Commits

Author SHA1 Message Date
bachinger
bfc4ed4dd4 Inline method in PlayerService that is used from on call site only
#cleanup
#minor-release

PiperOrigin-RevId: 505146915
(cherry picked from commit d7ef1ab5bd5a4508c0913011f5990bb03a57585a)
2023-02-02 13:22:38 +00:00
tonihei
631ff809f5 Fix timestamp comparison for seeks in fMP4
When seeking in fMP4, we try to extract as little samples as possible
by only starting at the preceding sync frame. This comparison should
use <= to allow sync frames at exactly the seek position.

Issue: google/ExoPlayer#10941

PiperOrigin-RevId: 505098172
(cherry picked from commit 00436a04a4f0fec8ee9154fc1568ca4013ca5c7d)
2023-02-02 13:22:33 +00:00
bachinger
bcdedb719d Double tap detection for Bluetooth media button events only
Issue: androidx/media#233
#minor-release
PiperOrigin-RevId: 505078751
(cherry picked from commit 5c82d6bc18429842160bb64a851bb1ab5c89ec39)
2023-02-02 13:18:30 +00:00
michaelkatz
c37442b24d Match MergingMediaPeriod track selection by period index in id
MergingMediaPeriod creates its track groups with ids concatenating position in its periods array and the underlying child track group id. The ids can be used in selectTracks for matching to periods list.

Issue: google/ExoPlayer#10930
PiperOrigin-RevId: 505074653
(cherry picked from commit 542a1ef03f361b29ec731a7334b2922cb54ef4c9)
2023-02-02 13:18:30 +00:00
tonihei
5e6f79ae63 Tweak UI behavior when commands are missing.
For most missing commands, we already disable the corresponding
controls. This change extends this to more UI elements that are
disabled in case the corresponding action is unavailable.

#minor-release

PiperOrigin-RevId: 505057751
(cherry picked from commit b3e7696ba7d66a2d3c477858194a20789f4d75c7)
2023-02-02 13:18:29 +00:00
tonihei
55312e1257 Add missing command checks in UI module
The commands are partly checked already before enabling
features or calling player methods, but the checks were
still missing in many places.

#minor-release

PiperOrigin-RevId: 504589888
(cherry picked from commit e2ece2f5bcda0cea436d782d58fa6f1d9a4d1f99)
2023-01-26 14:26:00 +00:00
ibaker
d6c9fdb210 Add missing } to publish.gradle
This was missed in 47349b8c4b

#minor-release

PiperOrigin-RevId: 504548659
(cherry picked from commit 50beec56f4188e46f67e561ac4bb4ace5bb95089)
2023-01-26 14:26:00 +00:00
ibaker
3708e7529a Publish gradle attributes for AndroidX compatibility
These attributes are required when importing our artifacts into
androidx-main in order to generate reference documentation (JavaDoc and
KDoc).

#minor-release

PiperOrigin-RevId: 504502555
(cherry picked from commit 47349b8c4bd69415da8895061be71ef748c4a2d3)
2023-01-26 14:26:00 +00:00
tonihei
c357e67dd1 Filter available commands based on PlaybackStateCompat actions
This allows a MediaController to understand which methods calls
are available on a legacy session.

PiperOrigin-RevId: 504306806
(cherry picked from commit 067340cb0a03dede0f51425de00643fe3789baf2)
2023-01-26 14:26:00 +00:00
christosts
207d67b7af Suppress warnings in ImaUtil
ImaUtil calls VideoProgressUpdate.equals() which is annotated as hidden,
which causes lint errors with gradle.

#minor-release

PiperOrigin-RevId: 504306210
(cherry picked from commit 5f6e172c8fce652adf2c05e8f2d041c793e900ea)
2023-01-26 14:26:00 +00:00
michaelkatz
846258b69c Deduplicate onSetMediaItem handler logic
Created unified MediaUtils method to handle various logic for calling Player.setMediaItems from MediaSessionStub and MediaSessionLegacyStub

PiperOrigin-RevId: 504271877
(cherry picked from commit 7fbdbeb6cafe075f04b6a4321ef826643b3482e1)
2023-01-26 14:26:00 +00:00
christosts
2adcfd9b15 Add missing # in release notes
PiperOrigin-RevId: 504013985
(cherry picked from commit 5147011772286778e84410012a24e329fde12040)
2023-01-26 14:25:34 +00:00
michaelkatz
e266051fbe Add onSetMediaItems listener with access to start index and position
Added onSetMediaItems callback listener to allow the session to modify/set MediaItem list, starting index and position before call to Player.setMediaItem(s).

Added conditional check in MediaSessionStub.setMediaItem methods to only call player.setMediaItem rather than setMediaItems if player does not support COMMAND_CHANGE_MEDIA_ITEMS

PiperOrigin-RevId: 503427927
(cherry picked from commit bb11e0286eaa49b4178dfa29ebaea5dafba8fc39)
2023-01-25 18:18:42 +00:00
bachinger
107a481356 Add the MediaSession as an argument to getMediaButtons()
Issue: androidx/media#216
#minor-release
PiperOrigin-RevId: 503406474
(cherry picked from commit e690802e9ecf96dfbb972864819a45ae92c47c90)
2023-01-25 18:18:42 +00:00
ibaker
967224c1aa 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 280889bc4a5b7ddc1b1c9fe15e222cad7f2e548a)
2023-01-25 18:18:42 +00:00
tonihei
43677b95eb Add command check for metadata in DefaultMediaNotificationProvider
PiperOrigin-RevId: 503172986
(cherry picked from commit 052c4b3c1a6b72efd7fcbf433c646fed9ea91748)
2023-01-25 18:18:42 +00:00
tonihei
28e37808ed Update media controller position before pausing.
We stop estimating new position when pausing until we
receive a new position from the player. However, this
means that we will continue to return a possible stale
previous position. Updating the current position before
pausing solves this issue.

PiperOrigin-RevId: 503153982
(cherry picked from commit e961c1b5e9bb4a6f63458b1bdcb49e97f415fabf)
2023-01-25 18:18:42 +00:00
tonihei
5b18c2d89f 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 f15b7525436b45694b5e1971dac922adff48b5ae)
2023-01-25 18:18:42 +00:00
tonihei
b8b6ddf347 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 69cfba7c53b563577390e4074fd270f078bf6069)
2023-01-25 18:18:42 +00:00
rohks
0606ab0cbb Fix javadoc references to writeSampleData
PiperOrigin-RevId: 502821506
(cherry picked from commit 6c14ffc1ecd13393930b9f5ee7ad7a52391d0f65)
2023-01-25 18:18:42 +00:00
tonihei
2eab93d5c5 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 c90ca7ba5fb9e83956e9494a584ae6b0620e3b14)
2023-01-25 18:18:42 +00:00
Googler
d41eedecb4 Disables play/pause button when there's nothing to play
PiperOrigin-RevId: 502571320
(cherry picked from commit d49a16e094d6d4bde0d1dc1ec42876c156b9c55a)
2023-01-25 18:18:42 +00:00
christosts
dd462e8cdb Filter what PlaybackStateCompat actions are advertised
PlayerWrapper advertises PlaybackStateCompat actions to the legacy
MediaSession based on the player's available commands.

PiperOrigin-RevId: 502559162
(cherry picked from commit 39f4a17ad4ac3863af22e12711247c7a87b8613e)
2023-01-25 18:18:42 +00:00
tianyifeng
79fd80f8b0 Post notification for session app when FgS starting exception is caught
PiperOrigin-RevId: 502407886
(cherry picked from commit 6ce3421ca750109acfea35029260dc3f169a1a40)
2023-01-25 18:18:42 +00:00
bachinger
818ce7271e Clarify what default settings are being used for SSAI AdsLoader
PiperOrigin-RevId: 502388865
(cherry picked from commit abe11c88ecdfe56ca31d3bffe1dd8fce6fb293af)
2023-01-25 18:18:42 +00:00
tonihei
903915de3d Fix command check in MediaControllerImplBase
The command check for setDeviceMuted was wrong.

PiperOrigin-RevId: 502355332
(cherry picked from commit cfcce9aec9d92a7067f07b2d9c00d705df0368ac)
2023-01-25 18:18:42 +00:00
tonihei
24b0367374 Add missing command checks to MediaSessionLegacyStub and PlayerWrapper
This player didn't fully check all player commands before calling the
respective methods.

PiperOrigin-RevId: 502353704
(cherry picked from commit a2a44cdc02abadd473e26e1fd9f973210d4c5f0e)
2023-01-25 18:18:42 +00:00
tonihei
55903af2f8 Remove unneccesary parameter taking Player.Command
The method to dispatch actions in MediaControllerImplBase takes
a Player.Command, but the value is only used to check if we
are setting a surface and need to handle the special blocking
call. This can be cleaned up by removing the parameter and calling
a dedicated blocking method where needed. This also ensures we
have to mention the relevant Player.Command only once in each
method.

PiperOrigin-RevId: 502341862
(cherry picked from commit 664ab72d090196625b5f533e9f0a2112951c5741)
2023-01-25 18:18:41 +00:00
tonihei
13dc59fc0f Correctly map deprecated methods in MediaController to replacement
This avoids throwing exceptions for correct (but deprecated) Player
method invocations.

PiperOrigin-RevId: 502341428
(cherry picked from commit 86a95c2a4afd861986376f9dc31e0d65910e6e74)
2023-01-25 18:18:41 +00:00
tianyifeng
a2aaad65a8 Catch FgSStartNotAllowedException when playback resumes
This fix applies to Android 12 and above.

In this fix, the `MediaSessionService` will try to start in the foreground before the session playback resumes, if ForegroundServiceStartNotAllowedException is thrown, then the app can handle the exception with their customized implementation of MediaSessionService.Listener.onForegroundServiceStartNotAllowedException. If no exception thrown, the a media notification corresponding to paused state will be sent as the consequence of successfully starting in the foreground. And when the player actually resumes, another media notification corresponding to playing state will be sent.

PiperOrigin-RevId: 501803930
(cherry picked from commit 0d0cd786264aa82bf9301d4bcde6e5c78e332340)
2023-01-25 18:18:41 +00:00
bachinger
b644c67924 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 16285ca5dfd4461334f5e97d4de47ae07e49e883)
2023-01-25 18:18:41 +00:00
bachinger
2c088269c6 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 20aa5bd9263f594e4f1f8029c5b80e9f204bff3a)
2023-01-25 18:18:41 +00:00
bachinger
1b8608f179 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 6484c14acd4197d335cab0b5f2ab9d3eba8c2b39)
2023-01-25 18:18:41 +00:00
bachinger
764daff417 Improve Java doc about how to override notification drawables
Issue: androidx/media#140
PiperOrigin-RevId: 501288267
(cherry picked from commit a2cf2221170e333d1d1883e0e86c5efca32f55ba)
2023-01-25 18:18:41 +00:00
bachinger
5d84804070 Use onMediaMetadataChanged for updating the legacy session
Issue: androidx/media#219
PiperOrigin-RevId: 501080612
(cherry picked from commit 375299bf364041ccef17b81020a13af7db997433)
2023-01-25 18:18:41 +00:00
bachinger
84545e0e47 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 9882a207836bdc089796bde7238f5357b0c23e76)
2023-01-25 18:18:41 +00:00
tonihei
b6970c09b8 Update bandwidth meter estimates
PiperOrigin-RevId: 501010994
(cherry picked from commit 2c7e9ca8237e39bde686dd635699778aa8c6b96e)
2023-01-25 18:18:41 +00:00
rohks
96eb8968a8 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 578f2de48f795ad90aafdad645c62fcdbd686e0a)
2023-01-25 18:18:20 +00:00
rohks
2cfd05f125 Fix typo in DefaultTrackSelector.Parameters field
PiperOrigin-RevId: 499905136
(cherry picked from commit b63e1da861d662f02d9a5888aaefb4a1b3347e40)
2023-01-25 18:17:17 +00:00
Googler
4e7ccd7ffd 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 d8ea770e9ba6eed0bdce0b359c54a55be0844fd3)
2023-01-25 18:17:17 +00:00
rohks
21996be448 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 790e27d929906a36438af5b42ef62a13e4719045)
2023-01-25 18:17:16 +00:00
rohks
7da071ad37 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 0512164fdd570a2047f51be719aae75ebcbf9255)
2023-01-25 18:17:16 +00:00
bachinger
d67df79d1e Remove player listener on the application thread of the player
PiperOrigin-RevId: 497183220
(cherry picked from commit fc22f89fdea4aad4819a59d4819f0857a5596869)
2023-01-25 18:17:16 +00:00
ibaker
70156dce4f 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 69583d0ac1fa1ab1a1e250774fc1414550625967)
2023-01-25 18:17:16 +00:00
ibaker
a94aa8dbd9 Fix order of playback controls in RTL layout
Issue: androidx/media#227

#minor-release

PiperOrigin-RevId: 497159283
(cherry picked from commit 80603427abbd0da09f21e381cc10a5d47fb6d780)
2023-01-25 18:17:16 +00:00
rohks
0f8b861923 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 7fc2cdbe1bdf9968a1e73a670e5e32454090e1bd)
2023-01-25 18:17:16 +00:00
rohks
e07c887bcd 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 13c93a3dd693e86e6d5208aff45105000858363f)
2023-01-25 18:17:16 +00:00
bachinger
13b72c478a Bump IMA SDK version to 3.29.0
Issue: google/ExoPlayer#10845
PiperOrigin-RevId: 496947392
(cherry picked from commit 63352e97e99cc6ab2e063906be63392ea8b984b3)
2023-01-25 18:17:16 +00:00
bachinger
11b0baa140 Update migration script
Issue: google/ExoPlayer#10854
PiperOrigin-RevId: 496922055
(cherry picked from commit 50090e39273356bee9b8da6b2f4a4dba1206f9a8)
2023-01-25 18:17:16 +00:00
ibaker
7d3375c6ec 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 4087a011e21aba2c27e3ae890f74a65812c6f4ce)
2023-01-25 18:17:16 +00:00