parseFrames method

TimecodeData parseFrames(
  1. int frameCount, {
  2. dynamic ignoreDropFrame = false,
})

Code modified for Dart and split into two functions from https://www.davidheidelberger.com/2010/06/10/drop-frame-timecode/ Also consider the implementation here: http://www.andrewduncan.net/timecodes/

Implementation

TimecodeData parseFrames(int frameCount, {ignoreDropFrame = false}) {
  frameCount = timecodeFrames(frameCount, ignoreDropFrame: ignoreDropFrame);

  int frRound = fps.round();
  int ff = frameCount % frRound;
  int ss = (frameCount ~/ frRound) % 60;
  int mm = ((frameCount ~/ frRound) ~/ 60) % 60;
  int hh = (((frameCount ~/ frRound) ~/ 60) ~/ 60);
  int millis = (1000 * frameCount / frRound).floor(); // total time
  int frac = millis % 1000;

  // this is the "corrected" frame data
  return TimecodeData(hh, mm, ss, ff, frac, millis);
}