recreateNode method

void recreateNode()

Implementation

void recreateNode() {
  if (currentUrl == null) {
    return;
  }
  player = AudioElement(currentUrl);
  player?.loop = shouldLoop();
  player?.volume = currentVolume;
  player?.playbackRate = currentPlaybackRate;
  playerTimeUpdateSubscription = player?.onTimeUpdate.listen(
    (_) => plugin.channel.invokeMethod<int>(
      'audio.onCurrentPosition',
      {
        'playerId': playerId,
        'value': (1000 * (player?.currentTime ?? 0)).round(),
      },
    ),
  );
}