enqueueVoice method

Future<bool> enqueueVoice(
  1. Uint8List wav, {
  2. int priority = 1,
})

Queues a WAV clip in the navigation voice queue, so it never plays over a guidance sentence (and a sentence never plays over it).

Use it to route another SDK's voice through navigation, for example the alerts of mapzone_nav_speed_alert:

alert.onVoice.listen((v) => controller.enqueueVoice(v.wav, priority: v.priority));

Without calls to this method the queue only holds guidance sentences.

Rules: clips play before pending guidance; nothing that is playing gets cut; clips arriving faster than they can play are dropped by priority — 0 first, then 1; 2 and guidance are never dropped. wav may be any WAV/PCM clip; its duration is read from the header. mute silences guidance only, not these clips.

Returns false when the navigation view is not available (not created yet or disposed); play the clip yourself in that case.

Implementation

Future<bool> enqueueVoice(Uint8List wav, {int priority = 1}) async {
  try {
    final result = await _methodChannel.invokeMethod<bool>(
      MethodChannelEvent.enqueueVoice,
      {'wav': wav, 'priority': priority.clamp(0, 2)},
    );
    return result ?? false;
  } on PlatformException catch (e) {
    log('enqueueVoice error: ${e.message}');
  } on MissingPluginException catch (e) {
    log('enqueueVoice error: ${e.message}');
  }
  return false;
}