32 Commits

Author SHA1 Message Date
tonihei
ae8000aeca 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
2022-12-12 11:32:57 +00:00
michaelkatz
64603cba8d Added cancellation check for MediaBrowserFuture in demo session app
When app is deployed with device's screen being off, MainActivity's onStart is called swiftly by its onStop. The onStop method cancels the browserFuture task which in turn "completes" the task. Upon task "completion", pushRoot() runs and then throws error as it calls get() a cancelled task.

PiperOrigin-RevId: 492416445
2022-12-12 11:03:37 +00:00
bachinger
6a5ac19140 Stop service when app is terminated while the player is paused
If the service ever has been started but is not in the foreground, the
service would be terminated without calling onDestroy(). This is because
when onStartCommand returns START_STICKY [1], the app takes the
responsibility to stop the service.

Note that this change interrupts the user journey when paused, because the
notification is removed. Apps can implement playback resumption [2] to give
the user an option to resume playback after the service has been terminated.

[1] https://developer.android.com/reference/android/app/Service#START_STICKY
[2] https://developer.android.com/guide/topics/media/media-controls#supporting_playback_resumption

Issue: androidx/media#175
#minor-release
PiperOrigin-RevId: 492192690
2022-12-12 10:59:23 +00:00
tianyifeng
cfe36af847 Update targetSdkVersion of demo session app to appTargetSdkVersion
PiperOrigin-RevId: 488884403
2022-11-16 12:18:46 +00:00
tonihei
ab9f0608cd Set matching folder type in Session demo app.
The folder type is useful metadata to understand programmatically
what criterion was used to create the folder.

PiperOrigin-RevId: 486653317
2022-11-08 11:32:18 +00:00
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