sync method

void sync({
  1. required int frame,
  2. required int fps,
  3. required bool playing,
  4. bool seek = false,
  5. bool restart = false,
})

Implementation

void sync({
  required int frame,
  required int fps,
  required bool playing,
  bool seek = false,
  bool restart = false,
}) {
  if (_disposed) return;
  final inRange = frame >= audioItem.startFrame && frame < audioItem.endFrame;
  final position = Duration(
    milliseconds:
        audioItem.startTime +
        ((frame - audioItem.startFrame) * 1000 / fps).round(),
  );
  final changed =
      inRange != _inRange || playing != _playing || seek || restart;
  _inRange = inRange;
  _playing = playing;
  _position = position;
  _seek |= seek;
  _restart |= restart;
  if (changed) _schedule();
}