listExecutions method

Lists ongoing FFmpeg executions.

Implementation

Future<List<FlutterSoundFFmpegExecution>> listExecutions() async {
  try {
    return await _methodChannel.invokeMethod('listExecutions').then((value) {
      var mapList = value as List<dynamic>;
      var executions =
          List<FlutterSoundFFmpegExecution>.empty(growable: true);

      for (var i = 0; i < mapList.length; i++) {
        var execution = FlutterSoundFFmpegExecution();
        execution.executionId = mapList[i]['executionId'];
        execution.startTime = DateTime.fromMillisecondsSinceEpoch(
            mapList[i]['startTime'].toInt());
        execution.command = mapList[i]['command'];
        executions.add(execution);
      }

      return executions;
    });
  } on PlatformException catch (e, stack) {
    logger.e('Plugin listExecutions error: ${e.message}');
    return Future.error('listExecutions failed.', stack);
  }
}