getCurrentVolume method

Future<void> getCurrentVolume()

Implementation

Future<void> getCurrentVolume() async {
  if (Platform.isLinux || Platform.isWindows) {
    if (duration.value.inSeconds != 0) {
      try {
        _currentVolume.value = _videoPlayerControllerWindows!.general.volume;
      } catch (e) {
        print("currentVolume " + e.toString());
        //throw 'Failed to get current volume';
        //return 0;
      }
    } else {
      _timerForGettingVolume?.cancel();
      _timerForGettingVolume =
          Timer.periodic(Duration(milliseconds: 250), (Timer t) async {
        _timerForGettingVolume = null;
        if (duration.value.inSeconds != 0) {
          try {
            _currentVolume.value =
                _videoPlayerControllerWindows!.general.volume;
          } catch (e) {
            print("currentVolume " + e.toString());
            //throw 'Failed to get current volume';
            //return 0;
          }
        }
      });
    }
  } else {
    try {
      _currentVolume.value = await VolumeController().getVolume();
    } catch (e) {
      print("currentVolume " + e.toString());
      //throw 'Failed to get current brightness';
      //return 0;
    }
  }
  //return 0;
}