diff --git a/README.md b/README.md index 36d8278..61e0c88 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Currently only the following APIs are integrated (both Android and iOS): * Load RemoteMediaRequestData * Play, Pause, Stop media * Expanded controls +* Mini Controller * Cast Button * Chromecast connection @@ -148,8 +149,12 @@ I used this project to test the capabilities of the following technologies: ## Roadmap +Next features to be developed: + * CC in Expanded Controls (iOS) * Expanded Controls cosmetics (ad in progress bar, full screen, progress bar handle) +* Title in MiniController and ExpandedControls (blocked because of a [pigeon issue](https://github.com/flutter/flutter/issues/93464)) * Handle queue * Handle progress seek -* Understand if it is better to refactor using streams instead of listeners \ No newline at end of file +* Understand if it is better to refactor using streams instead of listeners +* Add tests \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 21929f0..34e64a4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -22,6 +22,23 @@ class _MyAppState extends State { CastState _castState = CastState.idle; SessionState _sessionState = SessionState.idle; String _message = ''; + PlayerState _playerState = PlayerState.idle; + + bool get _hasSession => _sessionState == SessionState.started; + bool get _hasMedia { + if (!_hasSession) return false; + + switch (_playerState) { + case PlayerState.idle: + case PlayerState.unknown: + return false; + case PlayerState.loading: + case PlayerState.buffering: + case PlayerState.paused: + case PlayerState.playing: + return true; + } + } final textMessageController = TextEditingController(); @@ -78,9 +95,13 @@ class _MyAppState extends State { } void _onRemoteMediaClientStatusUpdated() { - final playerState = castFramework - .castContext.sessionManager.remoteMediaClient.playerState.value; - debugPrint("RemoteMediaClient status updated - playerState $playerState"); + debugPrint("Player state changed from example"); + setState(() { + final playerState = castFramework + .castContext.sessionManager.remoteMediaClient.playerState.value; + + _playerState = playerState; + }); } void _onSendMessage() { @@ -141,13 +162,14 @@ class _MyAppState extends State { Expanded( child: TextField( controller: textMessageController, + enabled: _hasSession, ), ), Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( child: Text('Send'), - onPressed: _onSendMessage, + onPressed: _hasSession ? _onSendMessage : null, ), ) ], @@ -162,14 +184,18 @@ class _MyAppState extends State { padding: const EdgeInsets.all(8.0), child: ElevatedButton( child: Text('Cast video'), - onPressed: _onCastVideo, + onPressed: _hasSession ? _onCastVideo : null, ), ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Player State: $_playerState"), + ), Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( child: Text('Expanded Controls'), - onPressed: _openExpandedControls, + onPressed: _hasMedia ? _openExpandedControls : null, ), ), _buildTitle("Mini Controller"), @@ -177,7 +203,7 @@ class _MyAppState extends State { padding: const EdgeInsets.symmetric(vertical: 8.0), child: MiniController( castFramework: castFramework, - onControllerTapped: _openExpandedControls, + onControllerTapped: _hasMedia ? _openExpandedControls : null, ), ), ],