77 Commits

Author SHA1 Message Date
tonihei
5d6d069e4e Set new playlist and start index with one command
PlayableFolderActivity currently uses two seperate commands
to set the playlist and then seek to the requested item.

This is slightly inefficient and also causes analytics
listeners to believe the first item in the playlist was
briefly active.

#minor-release

Issue: androidx/media#180
PiperOrigin-RevId: 480031682
2022-10-17 15:42:30 +00:00
rohks
9a6745431a Use ContextCompat.getMainExecutor when calling MediaBrowser methods
Replacing remaining usage of MoreExecutors.directExecutor. This allows the service to be switched to run in another process and the app still works the same as if it is running in the same process.

Issue: androidx/media#100
PiperOrigin-RevId: 471547177
2022-09-30 17:19:30 +00:00
rohks
d260b0c2a0 Switch incorrectly configured native multidex to legacy for demos
Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470004102
2022-09-30 17:05:23 +00:00
bachinger
7fa3f99304 Enable subtitle selection in session demo app
Issue: androidx/media#102
#minor-release
PiperOrigin-RevId: 462391045
2022-08-08 07:56:20 +00:00
bachinger
c9abe70259 Use ContextCompat.getMainExecutor when calling MediaBrowser methods
This allows the service to be switched to run in another process and the app still works the same as if it is running in the same process.

Issue: androidx/media#100
PiperOrigin-RevId: 458460005
2022-07-04 19:50:35 +00:00
tonihei
bd126ec5c5 Forward legacy controller onPlay/PrepareFromXY calls to onAddMediaItems
These legacy callbacks are currently forwarded to onSetMediaUri which
will be removed in the future.

Also make sure to only call player.prepare/play after the items have
been set.

The calls to onAddQueueItem are also forwarded to onAddMediaItems to
actually allow a session to resolve these items to playable media, which
wasn't possible so far.

PiperOrigin-RevId: 453625204
2022-06-09 17:40:26 +00:00
tonihei
6b782d1011 Replace MediaItemFiller by asynchronous callback.
The MediaItemFiller is not flexible enough for most realworld usages
because:
 - it doesn't allow asynchronous resolution of MediaItems (e.g. to
   look up URIs from a database)
 - it doesn't allow to batch updates for multiple items or do more
   advanced customizations (e.g. expanding a mediaId representing
   a playlist to multiple items).

Both issues can be solved by passing in a list of items and
returning a ListenableFuture. The callback itself can also move
into MediaSession.Callback for consistency with the other
callbacks.

PiperOrigin-RevId: 451857319
2022-05-30 16:48:41 +00:00
bachinger
9a70bbca05 Demonstrate how to use custom actions in the session demo app.
PiperOrigin-RevId: 451410714
2022-05-30 16:40:41 +00:00
bachinger
08fc89a585 Implement onSubscribe in session demo service
Immediately notify a subscribing client about the availability of child items of
a parent ID to make the client load the children.

PiperOrigin-RevId: 450396690
2022-05-24 11:08:56 +01:00
ibaker
c78c1f5891 Rename nested session callback interfaces to just Callback
This is consistent with other nested callback/listener interfaces like
`Player.Listener`.

PiperOrigin-RevId: 449476261
2022-05-24 10:57:02 +01:00
christosts
7a631f4050 MediaSessionService: define foregroundServiceType
PiperOrigin-RevId: 447467287
2022-05-10 17:49:22 +01:00
christosts
1023b9d55e Start playback from notification
This change fixes two bugs where MediaSessionServe shows a notification
with the Play icon but tapping it will not start playback:
1. After playback ends: we need to seek to the beginning of the media
   item.
2. After adding media items to the player but not starting playback:
   We need to call Player.prepare() too.

PiperOrigin-RevId: 432469953
2022-03-04 17:52:46 +00:00
tonihei
c5b7e7b258 Fix session demo gradle build when used with a prefix
#minor-release

PiperOrigin-RevId: 425613253
2022-02-01 18:20:19 +00:00
olly
d2cc14a98b Fix some lint warnings
PiperOrigin-RevId: 424383900
2022-01-28 08:46:46 +00:00
ibaker
bfce8f5456 Rename StyledPlayerView to PlayerView
This commit leaves some 'styled' references, specifically:
* exo_styled_XXX dimension names
* exo_styled_controls_XXX drawable IDs
* exo_styled_XXX color names
* ExoStyledControls.XXX style names

PiperOrigin-RevId: 421576554
2022-01-25 18:10:42 +00:00
christosts
63a32e85c5 Session demo: update playlist add/remove icons
PiperOrigin-RevId: 421256149
2022-01-25 17:53:42 +00:00
christosts
152e986c09 Fix typo
PiperOrigin-RevId: 421036800
2022-01-25 17:48:24 +00:00
bachinger
f06c79e441 Merge pull request #24 from PaulWoitaschek:patch-1
PiperOrigin-RevId: 419827570
2022-01-11 13:22:37 +00:00
ibaker
35bd0f46a4 Update the session demo app to refer to exo_styled drawables
This app uses the StyledPlayerView, so it should use the styled_
drawables.

PiperOrigin-RevId: 416315889
2022-01-05 10:14:25 +00:00
Paul Woitaschek
b28f5ca413
Refactor unintuitive lateinit usage 2021-12-28 22:54:19 +01:00
Ian Baker
1a1d27aee6 Merge pull request #6 from dturner:add-artwork-images
PiperOrigin-RevId: 411524337
2021-11-22 17:21:14 +00:00
olly
3b11822fa1 Add backwards compatibility with MediaBrowserService
PiperOrigin-RevId: 409290492
2021-11-19 14:43:22 +00:00
olly
fea552e709 Update dependency versions
Note: Updating androidxTestTruthVersion is required tot
arget API level 31.
PiperOrigin-RevId: 409167744
2021-11-19 14:42:25 +00:00
Don Turner
05a4526e61 Display album artwork in media notifications 2021-11-17 20:12:10 +00:00
ibaker
8b34d160dc Fix implementations of MediaLibrarySessionCallback to pass params
The documentation makes it clear this value should be propagated
through to the result.

PiperOrigin-RevId: 407085751
2021-11-09 10:09:12 +00:00
ibaker
686f2ca96d Migrate usages of Window-based Player methods
Where this introduced an inconsistency (e.g. assigning to something
called `windowIndex`), I generally renamed the transitive closure of
identifiers to maintain consistency (meaning this change is quite
large). The exception is code that interacts with Timeline and Window
directly, where sometimes I kept the 'window' nomenclature.

#minor-release

PiperOrigin-RevId: 407040052
2021-11-09 10:07:30 +00:00
Andrew Lewis
933e207b3e Update to androidx.media3
PiperOrigin-RevId: 405656499
2021-10-27 09:12:46 +01:00