adds buffering intermediate state
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
+14
-3
@@ -58,6 +58,17 @@ class _MainPageState extends State<MainPage> {
|
||||
StreamingAudioBusinessObject get _audio => widget.audio;
|
||||
late final WebViewController _webViewController;
|
||||
|
||||
String _playbackStatusLabel() {
|
||||
switch (_audio.playbackStatus) {
|
||||
case StreamingPlaybackStatus.stopped:
|
||||
return 'Stopped';
|
||||
case StreamingPlaybackStatus.buffering:
|
||||
return 'Buffering...';
|
||||
case StreamingPlaybackStatus.playing:
|
||||
return 'Playing';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -193,17 +204,17 @@ class _MainPageState extends State<MainPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: _audio.isPlaying ? null : _play,
|
||||
onPressed: _audio.isStopped ? _play : null,
|
||||
child: const Text('▶️'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ElevatedButton(
|
||||
onPressed: _audio.isPlaying ? _stop : null,
|
||||
onPressed: _audio.isStopped ? null : _stop,
|
||||
child: const Text('⏹️'),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
_audio.isPlaying ? 'Playing' : 'Stopped',
|
||||
_playbackStatusLabel(),
|
||||
style: TextStyle(color: themeColors.statusText),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user