Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 642b5d60 authored by Sal Savage's avatar Sal Savage
Browse files

Wait for playback when playing a browsed media item

Currently, BrowsedPlayerWrapper treats all browsing and playing actions
as transient operations where it sets an operation to do, connect()'s,
invokes the function with the desired operation, disconnect()'s and
clears the callback for the operation. The key thing here is connect and
disconnect translate to bind() and unbind() calls on the browse service.
Unbinding from a service when you're the last person that is bound to
that service can cause the service to go down.

With browsing, we subscribe once connected and wait for media items to
be loaded before we disconnect. This is fine, as we get the data we're
after before the service goes down.

With playing from a media ID, we simply get transport controls, call
playFromMediaId(), and disconnect(). The play call is async though and
assuming the media source isn't in the foreground yet, can result in
the service AND its session being torn down before playback can began
and the service can transition into a foreground audio source. This
results in no metadata being loaded or audio playing.

This can be very impactful in a car where you might need to take your
phone out while driving to start a media app so you can begin playback
on your own.

This change makes it so the BrowsedPlayerWrapper will wait until it gets
a playback state of STATUS_PLAYING before it disconnects from the browse
service (with a timeout). Proper synchronization is also added to the
callback object used on connections. Tests are updated to reflect the
new wait for playback, timing out and synchronization behaviors.

Bug: b/139430948
Test: Connect to a car kit that supports playing from a browsed media
item and select an item to play + atest BrowsedPlayerWrapperTest

Change-Id: Ib9135196b578561813df9e0663c0960b4af7899b
parent f21731af
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment