From 73e30bb8c8cf3b073df7716d733f75feb3c52af4 Mon Sep 17 00:00:00 2001 From: gianlucaparadise Date: Tue, 23 Nov 2021 06:13:36 +0100 Subject: [PATCH] RemoteMediaClient GetMediaInfo used in example --- example/lib/main.dart | 18 ++++++++++++++++++ lib/src/cast/RemoteMediaClient.dart | 4 ++++ lib/src/flutter_cast_framework.dart | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 6330032..49414a5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:flutter_cast_framework/cast.dart'; import 'package:flutter_cast_framework/widgets.dart'; @@ -79,6 +81,15 @@ class _MyAppState extends State { castFramework.castContext.sessionManager.remoteMediaClient.load(request); } + Future _openExpandedControls() async { + final remoteMediaClient = + this.castFramework.castContext.sessionManager.remoteMediaClient; + + final mediaInfo = await remoteMediaClient.getMediaInfo(); + debugPrint("$mediaInfo"); + inspect(mediaInfo); + } + Widget _buildTitle(String text) { return Padding( padding: const EdgeInsets.all(8.0), @@ -138,6 +149,13 @@ class _MyAppState extends State { child: Text('Cast video'), onPressed: _onCastVideo, ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + child: Text('Expanded Controls'), + onPressed: _openExpandedControls, + ), ) ], ), diff --git a/lib/src/cast/RemoteMediaClient.dart b/lib/src/cast/RemoteMediaClient.dart index 2c3fc51..2183841 100644 --- a/lib/src/cast/RemoteMediaClient.dart +++ b/lib/src/cast/RemoteMediaClient.dart @@ -8,4 +8,8 @@ class RemoteMediaClient { void load(MediaLoadRequestData request) { _hostApi.loadMediaLoadRequestData(request); } + + Future getMediaInfo() async { + return await _hostApi.getMediaInfo(); + } } diff --git a/lib/src/flutter_cast_framework.dart b/lib/src/flutter_cast_framework.dart index 09d5964..2f7cae5 100644 --- a/lib/src/flutter_cast_framework.dart +++ b/lib/src/flutter_cast_framework.dart @@ -5,7 +5,7 @@ import 'PlatformBridgeApis.dart'; import 'cast/CastContext.dart'; class FlutterCastFramework extends CastFlutterApi { - final hostApi = CastHostApi(); + final _hostApi = CastHostApi(); late CastContext castContext; /// List of namespaces to listen for custom messages @@ -14,7 +14,7 @@ class FlutterCastFramework extends CastFlutterApi { FlutterCastFramework.create(List namespaces) { debugPrint("FlutterCastFramework created!"); this.namespaces = namespaces; - this.castContext = CastContext(hostApi); + this.castContext = CastContext(_hostApi); CastFlutterApi.setup(this); }