From a5530e744198120cee89e115453a54913bf18a1a Mon Sep 17 00:00:00 2001 From: gianlucaparadise Date: Mon, 29 Nov 2021 20:08:53 +0100 Subject: [PATCH] ExpandedControls: integrate getMediaInfo --- .../expanded_controls/ExpandedControls.dart | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/src/cast/widgets/expanded_controls/ExpandedControls.dart b/lib/src/cast/widgets/expanded_controls/ExpandedControls.dart index 2874d38..f5dbede 100644 --- a/lib/src/cast/widgets/expanded_controls/ExpandedControls.dart +++ b/lib/src/cast/widgets/expanded_controls/ExpandedControls.dart @@ -42,13 +42,17 @@ class ExpandedControls extends StatelessWidget { }); Widget _getDecoratedToolbar(MediaInfo? mediaInfo) { + // Title and subtitle can't be retrieved at the moment + // final title = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.title] + // final subtitle = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.subtitle] + final title = ""; + final subtitle = ""; + return Container( decoration: _topDownBlackGradient, child: ExpandedControlsToolbar( - castFramework: castFramework, - title: "Title", - subtitle: "Subtitle", - onBackTapped: onBackTapped, + title: title, + subtitle: subtitle, ), ); } @@ -108,8 +112,33 @@ class ExpandedControls extends StatelessWidget { @override Widget build(BuildContext context) { + var remoteMediaClient = + this.widget.castFramework.castContext.sessionManager.remoteMediaClient; + return SafeArea( - child: _getFullControls(context, null), + child: FutureBuilder( + future: remoteMediaClient.getMediaInfo(), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + var mediaInfo = snapshot.data; + return _getFullControls(context, mediaInfo); + } else if (snapshot.hasError) { + return _getFullControls(context, null); + } else { + final controls = _getFullControls(context, null); + return Stack( + children: [ + controls, + Center( + child: CircularProgressIndicator( + color: Colors.white, + ), + ), + ], + ); + } + }, + ), ); } }