File tree 3 files changed +16
-2
lines changed
demos/session/src/main/java/androidx/media3/demo/session
libraries/session/src/main/java/androidx/media3/session
3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 56
56
* Add helper method ` MediaSession.getControllerForCurrentRequest ` to
57
57
obtain information about the controller that is currently calling
58
58
a` Player ` method.
59
+ * Fix bug that prevented the ` MediaLibraryService ` from returning null for
60
+ a call from System UI to ` Callback.onGetLibraryRoot ` with
61
+ ` params.isRecent == true ` on API 30
62
+ ([ #355 ] ( https://github.com/androidx/media/issues/355 ) ).
59
63
* UI:
60
64
61
65
* Add Util methods ` shouldShowPlayButton ` and
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import androidx.media3.common.util.Util
30
30
import androidx.media3.datasource.DataSourceBitmapLoader
31
31
import androidx.media3.exoplayer.ExoPlayer
32
32
import androidx.media3.session.*
33
+ import androidx.media3.session.LibraryResult.RESULT_ERROR_NOT_SUPPORTED
33
34
import androidx.media3.session.MediaSession.ControllerInfo
34
35
import com.google.common.collect.ImmutableList
35
36
import com.google.common.util.concurrent.Futures
@@ -143,6 +144,12 @@ class PlaybackService : MediaLibraryService() {
143
144
browser : ControllerInfo ,
144
145
params : LibraryParams ?
145
146
): ListenableFuture <LibraryResult <MediaItem >> {
147
+ if (params != null && params.isRecent) {
148
+ // The service currently does not support playback resumption. Tell System UI by returning
149
+ // an error of type 'RESULT_ERROR_NOT_SUPPORTED' for a `params.isRecent` request. See
150
+ // https://github.com/androidx/media/issues/355
151
+ return Futures .immediateFuture(LibraryResult .ofError(RESULT_ERROR_NOT_SUPPORTED ))
152
+ }
146
153
return Futures .immediateFuture(LibraryResult .ofItem(MediaItemTree .getRootItem(), params))
147
154
}
148
155
Original file line number Diff line number Diff line change @@ -126,8 +126,11 @@ public BrowserRoot onGetRoot(
126
126
.putBoolean (BROWSER_SERVICE_EXTRAS_KEY_SEARCH_SUPPORTED , isSearchSessionCommandAvailable );
127
127
return new BrowserRoot (result .value .mediaId , extras );
128
128
}
129
- // No library root, but keep browser compat connected to allow getting session.
130
- return MediaUtils .defaultBrowserRoot ;
129
+ // No library root, but keep browser compat connected to allow getting session unless the
130
+ // `Callback` implementation has not returned a `RESULT_SUCCESS`.
131
+ return result != null && result .resultCode != RESULT_SUCCESS
132
+ ? null
133
+ : MediaUtils .defaultBrowserRoot ;
131
134
}
132
135
133
136
// TODO(b/192455639): Optimize potential multiple calls of
You can’t perform that action at this time.
0 commit comments