getAudioInfo method

  1. @override
Future<AudioInfo> getAudioInfo(
  1. String inputPath
)
override

Gets comprehensive information about an audio file

Analyzes the audio file and returns detailed information including format, duration, quality metrics, and compatibility information.

inputPath - Path to the input audio file

Returns AudioInfo with comprehensive file information. Throws AudioAnalysisException if analysis fails.

Implementation

@override
Future<AudioInfo> getAudioInfo(String inputPath) async {
  // Validate arguments
  _validateFilePath(inputPath, 'inputPath');

  try {
    final result = await methodChannel
        .invokeMethod('getAudioInfo', {'inputPath': inputPath})
        .timeout(const Duration(seconds: 30));

    if (result == null) {
      throw AudioAnalysisException(
        'Audio analysis failed: No result returned from platform',
        inputPath: inputPath,
      );
    }

    // Safely convert the result to Map<String, dynamic>
    final Map<String, dynamic> convertedResult;
    if (result is Map) {
      convertedResult = Map<String, dynamic>.from(result);
    } else {
      throw AudioAnalysisException(
        'Audio analysis failed: Invalid result type from platform',
        inputPath: inputPath,
      );
    }

    return AudioInfo.fromMap(convertedResult);
  } on PlatformException catch (e) {
    throw _convertPlatformException(e, AudioAnalysisException.new, {
      'inputPath': inputPath,
    });
  } catch (e) {
    throw AudioAnalysisException(
      'Audio analysis failed: $e',
      originalError: e,
      inputPath: inputPath,
    );
  }
}