I was reading documentation of audio_service flutter and was going through a couple of examples while analyzing mediaLibray i got a doubt regarding AudioService.browsableRootId what it is? is it denoting any particular album if so then why in id attribute of mediaitem under AudioService.browsableRootId a string which not a URL? I'm a kind of a newbie.
example url of code = https://github.com/ryanheise/audio_service/blob/7a29ba22fed8567996db1050f58e2d685ef7b713/audio_service/example/lib/example_playlist.dart#L652
class MediaLibrary {
static const albumsRootId = 'albums';
final items = <String, List<MediaItem>>{
AudioService.browsableRootId: const [
MediaItem(
id: albumsRootId,
title: "Albums",
playable: false,
),
],
albumsRootId: [
MediaItem(
id: 'https://s3.amazonaws.com/scifri-episodes/scifri20181123-episode.mp3',
album: "Science Friday",
title: "A Salute To Head-Scratching Science",
artist: "Science Friday and WNYC Studios",
duration: const Duration(milliseconds: 5739820),
artUri: Uri.parse(
'https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg'),
),
MediaItem(
id: 'https://s3.amazonaws.com/scifri-segments/scifri201711241.mp3',
album: "Science Friday",
title: "From Cat Rheology To Operatic Incompetence",
artist: "Science Friday and WNYC Studios",
duration: const Duration(milliseconds: 2856950),
artUri: Uri.parse(
'https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg'),
),
MediaItem(
id: 'https://s3.amazonaws.com/scifri-segments/scifri202011274.mp3',
album: "Science Friday",
title: "Laugh Along At Home With The Ig Nobel Awards",
artist: "Science Friday and WNYC Studios",
duration: const Duration(milliseconds: 1791883),
artUri: Uri.parse(
'https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg'),
),
],
};
}
This is an Android-specific feature that works in conjunction with the getChildren(parentMediaId)
method. The getChildren(parentMediaId)
method will be queried by Android Auto when the user wants to browse your content and see a list of children in a particular folder identified by parentMediaId
. The root of this hierarchical folder structure is given by the special parent ID AudioService.browsableRootId
.
audio_service doesn't provide any documentation on Android Auto, so if you want to use this feature, it is best to familiarise yourself with the original Android Auto documentation where these two concepts are referred to by their native method names onGetRoot
and onLoadChildren
. e.g. https://developer.android.com/training/cars/media
There is another Android feature that makes use of the same getChildren
(onLoadChildren
) method, and that is media session resumption. For more information on this, you can read: https://developer.android.com/guide/topics/media/media-controls