setVolume method

Future<void> setVolume(
  1. double volume
)

Sets the volume of the audio player.

volume: The desired volume level, typically between 0.0 (mute) and 1.0 (full volume).

Implementation

Future<void> setVolume(double volume) async {
  try {
    // Invoke the native method to set the volume
    await _channel.invokeMethod('setVolume', {'volume': volume});
  } catch (e) {
    // Log any errors that occur while setting the volume
    log("Error setting volume: ${e.toString()}");
  }
}