Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why FrbAnyhowException is throwing? What is going wrong? #28

Open
s681562 opened this issue Mar 8, 2024 · 2 comments
Open

Why FrbAnyhowException is throwing? What is going wrong? #28

s681562 opened this issue Mar 8, 2024 · 2 comments

Comments

@s681562
Copy link

s681562 commented Mar 8, 2024

minSdk 29
targetSdk 34
compileSdk 34

I/flutter (16667): #### writeAudioTagArtist file path /storage/emulated/0/Recordings/Call/통화 녹음 010aaaaxxxx_240308_160557.m4a
I/flutter (16667): ###### writeAudioTagArtist exception Instance of 'FrbAnyhowException'
I/flutter (16667): #0 FlutterRustBridgeBase._transformRust2DartMessage (package:flutter_rust_bridge/src/basic.dart:133)
I/flutter (16667): #1 FlutterRustBridgeBase.executeNormal. (package:flutter_rust_bridge/src/basic.dart:70)

FAILED Metadata metadata = await MetadataGod.readMetadata(file: path);

What I am executed:

Future writeAudioTagArtist(String path, String phone) async {
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
AndroidDeviceInfo info = await deviceInfoPlugin.androidInfo;
int sdkVersion = info.version.sdkInt;
if (Platform.isAndroid && sdkVersion <= 32) {
final bool hasStorageAccess = await Permission.storage.isGranted;
if(!hasStorageAccess) {
await Permission.storage.request();
if (!await Permission.storage.isGranted) {
print("#### writeAudioTagArtist Permission.storage not granted");
return;
}
}
}

print("#### writeAudioTagArtist file path ${path}");

try {
  // Get metadata from file
  Metadata metadata = await MetadataGod.readMetadata(file: path);
  print("#### A${phone}");
  print("#### A${path}");
  print("#### A${metadata}");
  // Set metadata to file
  await MetadataGod.writeMetadata(file: path, metadata:
  Metadata(
    title: phone,
    artist: phone,
    albumArtist: phone,
    genre: phone,
  ),
  );

  Metadata metadataA = await MetadataGod.readMetadata(file: path);
  print("#### TITLE ${metadataA.title}");
  print("#### ARTIST ${metadataA.artist}");
  print("#### ALBUM ${metadataA.albumArtist}");
  print("#### GENRE ${metadataA.genre}");
} catch (error, stack) {
  print("###### writeAudioTagArtist exception ${error}");
  print(stack);
}

}

Please help. Thanks in advance.

@arrahmanbd
Copy link

It's an error occured when reading metadata of a file without having anymetadata/tag. When No tags found, creating a new tag of type Id3v2 also caused this error of metadata_god package. Try using try-cartch-finally handeling method.

@arrahmanbd
Copy link

Best solution is:

try{
// Fetch metadata for each song
Metadata filemetadata = await MetadataGod.readMetadata(file: songFile.path);
}
catch (e) {
// Handle individual file metadata errors
print("Error reading metadata for ${songFile.path}: $e");
// Skip the current file and continue with the next one
continue;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants