play static method

Future<void> play(
  1. SoundPlayerOptions options
)

Plays the sound from the provided options.

Implementation

static Future<void> play(SoundPlayerOptions options) async {
  if (!_isValidUrl(options.soundUrl)) {
    if (kDebugMode) {
      print('Invalid URL: ${options.soundUrl}');
    }
    return;
  }

  try {
    await _audioPlayer.play(UrlSource(options.soundUrl));
  } catch (e) {
    if (kDebugMode) {
      print('Failed to play sound: $e');
    }
  }
}