Open cingh-jasdeep opened 5 years ago
@cingh-jasdeep I solved the first problem by calling when I want to update media list
MediaBrowserServiceCompat.notifyChildrenChanged(String parentId)
Calling this notifies all connected media browsers that the children of the specified parent id have changed in some way.
After thisonLoadChildren()
will be called again.
@YuriPopiv Hi Yuri, do you happen to have a committed example of this in action? Or could you perhaps point me to a working example? I'm currently trying to refresh custom JSON content using a wrapper activity and would like a way to resubscribe to the Music service. Any help you could provide would be much appreciated. Thank you.
@ponder-bar First you need update catalog
in the JsonSource
object with media content.
Then, for example, add a method to MediaSessionConnection
fun resubscribe() {
mediaBrowser.unsubscribe(parentId, callback)
mediaBrowser.subscribe(parentId, callback)
}
after this onLoadChildren( parentMediaId: String, result: androidx.media.MediaBrowserServiceCompat.Result<List<MediaItem>>)
method in your MusicService
will be triggered and result.sendResult(children)
will be called with new content
@YuriPopiv Thank you, this is a definitely a help, though as a Kotlin beginner I am wondering where I would theoretically call this resub function. Thanks again.
@ponder-bar I am facing same thing , Have you done it ??
Hi
Thanks for this helpful sample. I am building an online radio streaming app. Very similar to the sample
UAMP: Kotlin version Android Version: Pie Device: Pixel 1
I wanted to know how the MediaSession can handle exceptions in the following cases? (currently it does nothing)
When there is no internet connection and a client tries to onLoadChildren? Right now it returns null, so no items. But how to reload onLoadChildren when internet connection resumes.
After Catalog loaded, internet goes away while playing? Right now Playback goes to error state and does not return How to come back to normal state when internet connection resumes.
Thanks for your help!