arcticfox1919 / vlc-flutter

Flutter plugin for vlc player
MIT License
21 stars 7 forks source link

How to use progress indicator #14

Open Adam-Salamat opened 6 months ago

Adam-Salamat commented 6 months ago

Hello everyone :)

Everything works perfectly, better than some packages I've tried recently, but I was relying on the listener to display the progress indicator CircularProgressIndicator(), and here I couldn't find a way to display it.

onPlayerState The listener displays "playing" the first time and then always displays "Buffering" in this case How can I use the progress indicator CircularProgressIndicator().

final VLCController _videoPlayerController = VLCController(args: ["-vvv"]);
bool _isMuted = false;
bool _isPlaying = true;
bool _isBuffering = true;

void initVLC(url) {
  _videoPlayerController.play(uri: url);

  _videoPlayerController.onPlayerState.listen((event) {
    //print('///////////// -- ' + event.name);
    if (event == VLCState.Error) {
      //TODO: Show error message
    } else if (event == VLCState.Playing) {
      if (_isBuffering) {
        setState(() {
          _isBuffering = false;
        }); // Hide progress indicator
      }
    } else if (event == VLCState.Buffering) {
      if (!_isBuffering) {
        setState(() {
          _isBuffering = true;
        }); // Show progress indicator
      }
    }
  }); 
}

Many thanks to everyone who made the package, it's really good .