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

Use lofty instead of audiotags (yes, I know this is a duplicate, sorry) #18

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/metadata_god/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ class _MyAppState extends State<MyApp> {
final result = await FilePicker.platform.pickFiles(
allowCompression: false,
allowMultiple: false,
allowedExtensions: ["m4a", "mp3", 'flac', 'ogg'],
allowedExtensions: [
"m4a",
"mp3",
'flac',
'ogg',
'aiff',
'wav'
],
withData: false,
withReadStream: false,
);
Expand Down
17 changes: 7 additions & 10 deletions packages/metadata_god/ios/Classes/frb.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ typedef struct wire_Metadata {
struct wire_uint_8_list *artist;
struct wire_uint_8_list *album;
struct wire_uint_8_list *album_artist;
uint16_t *track_number;
uint16_t *track_total;
uint16_t *disc_number;
uint16_t *disc_total;
int32_t *year;
uint32_t *track_number;
uint32_t *track_total;
uint32_t *disc_number;
uint32_t *disc_total;
uint32_t *year;
struct wire_uint_8_list *genre;
struct wire_Picture *picture;
uint64_t *file_size;
Expand All @@ -55,13 +55,11 @@ void wire_write_metadata(int64_t port_,

double *new_box_autoadd_f64_0(double value);

int32_t *new_box_autoadd_i32_0(int32_t value);

struct wire_Metadata *new_box_autoadd_metadata_0(void);

struct wire_Picture *new_box_autoadd_picture_0(void);

uint16_t *new_box_autoadd_u16_0(uint16_t value);
uint32_t *new_box_autoadd_u32_0(uint32_t value);

uint64_t *new_box_autoadd_u64_0(uint64_t value);

Expand All @@ -74,10 +72,9 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) wire_read_metadata);
dummy_var ^= ((int64_t) (void*) wire_write_metadata);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_f64_0);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_i32_0);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_metadata_0);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_picture_0);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_u16_0);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_u32_0);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_u64_0);
dummy_var ^= ((int64_t) (void*) new_uint_8_list_0);
dummy_var ^= ((int64_t) (void*) free_WireSyncReturn);
Expand Down
87 changes: 35 additions & 52 deletions packages/metadata_god/lib/src/bridge_generated.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// AUTO GENERATED FILE, DO NOT EDIT.
// Generated by `flutter_rust_bridge`@ 1.72.1.
// Generated by `flutter_rust_bridge`@ 1.72.2.
// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const

import 'dart:convert';
Expand All @@ -13,16 +13,14 @@ import 'dart:async';
import 'package:meta/meta.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge.dart';
import 'package:uuid/uuid.dart';
import 'bridge_generated.io.dart'
if (dart.library.html) 'bridge_generated.web.dart';
import 'bridge_generated.io.dart' if (dart.library.html) 'bridge_generated.web.dart';

abstract class MetadataGod {
Future<Metadata> readMetadata({required String file, dynamic hint});

FlutterRustBridgeTaskConstMeta get kReadMetadataConstMeta;

Future<void> writeMetadata(
{required String file, required Metadata metadata, dynamic hint});
Future<void> writeMetadata({required String file, required Metadata metadata, dynamic hint});

FlutterRustBridgeTaskConstMeta get kWriteMetadataConstMeta;
}
Expand Down Expand Up @@ -74,48 +72,52 @@ class Picture {

class MetadataGodImpl implements MetadataGod {
final MetadataGodPlatform _platform;
factory MetadataGodImpl(ExternalLibrary dylib) =>
MetadataGodImpl.raw(MetadataGodPlatform(dylib));
factory MetadataGodImpl(ExternalLibrary dylib) => MetadataGodImpl.raw(MetadataGodPlatform(dylib));

/// Only valid on web/WASM platforms.
factory MetadataGodImpl.wasm(FutureOr<WasmModule> module) =>
MetadataGodImpl(module as ExternalLibrary);
factory MetadataGodImpl.wasm(FutureOr<WasmModule> module) => MetadataGodImpl(module as ExternalLibrary);
MetadataGodImpl.raw(this._platform);
Future<Metadata> readMetadata({required String file, dynamic hint}) {
var arg0 = _platform.api2wire_String(file);
return _platform.executeNormal(FlutterRustBridgeTask(
callFfi: (port_) => _platform.inner.wire_read_metadata(port_, arg0),
parseSuccessData: _wire2api_metadata,
constMeta: kReadMetadataConstMeta,
argValues: [file],
argValues: [
file
],
hint: hint,
));
}

FlutterRustBridgeTaskConstMeta get kReadMetadataConstMeta =>
const FlutterRustBridgeTaskConstMeta(
FlutterRustBridgeTaskConstMeta get kReadMetadataConstMeta => const FlutterRustBridgeTaskConstMeta(
debugName: "read_metadata",
argNames: ["file"],
argNames: [
"file"
],
);

Future<void> writeMetadata(
{required String file, required Metadata metadata, dynamic hint}) {
Future<void> writeMetadata({required String file, required Metadata metadata, dynamic hint}) {
var arg0 = _platform.api2wire_String(file);
var arg1 = _platform.api2wire_box_autoadd_metadata(metadata);
return _platform.executeNormal(FlutterRustBridgeTask(
callFfi: (port_) =>
_platform.inner.wire_write_metadata(port_, arg0, arg1),
callFfi: (port_) => _platform.inner.wire_write_metadata(port_, arg0, arg1),
parseSuccessData: _wire2api_unit,
constMeta: kWriteMetadataConstMeta,
argValues: [file, metadata],
argValues: [
file,
metadata
],
hint: hint,
));
}

FlutterRustBridgeTaskConstMeta get kWriteMetadataConstMeta =>
const FlutterRustBridgeTaskConstMeta(
FlutterRustBridgeTaskConstMeta get kWriteMetadataConstMeta => const FlutterRustBridgeTaskConstMeta(
debugName: "write_metadata",
argNames: ["file", "metadata"],
argNames: [
"file",
"metadata"
],
);

void dispose() {
Expand All @@ -131,15 +133,11 @@ class MetadataGodImpl implements MetadataGod {
return raw as double;
}

int _wire2api_box_autoadd_i32(dynamic raw) {
return raw as int;
}

Picture _wire2api_box_autoadd_picture(dynamic raw) {
return _wire2api_picture(raw);
}

int _wire2api_box_autoadd_u16(dynamic raw) {
int _wire2api_box_autoadd_u32(dynamic raw) {
return raw as int;
}

Expand All @@ -151,25 +149,20 @@ class MetadataGodImpl implements MetadataGod {
return raw as double;
}

int _wire2api_i32(dynamic raw) {
return raw as int;
}

Metadata _wire2api_metadata(dynamic raw) {
final arr = raw as List<dynamic>;
if (arr.length != 13)
throw Exception('unexpected arr length: expect 13 but see ${arr.length}');
if (arr.length != 13) throw Exception('unexpected arr length: expect 13 but see ${arr.length}');
return Metadata(
title: _wire2api_opt_String(arr[0]),
durationMs: _wire2api_opt_box_autoadd_f64(arr[1]),
artist: _wire2api_opt_String(arr[2]),
album: _wire2api_opt_String(arr[3]),
albumArtist: _wire2api_opt_String(arr[4]),
trackNumber: _wire2api_opt_box_autoadd_u16(arr[5]),
trackTotal: _wire2api_opt_box_autoadd_u16(arr[6]),
discNumber: _wire2api_opt_box_autoadd_u16(arr[7]),
discTotal: _wire2api_opt_box_autoadd_u16(arr[8]),
year: _wire2api_opt_box_autoadd_i32(arr[9]),
trackNumber: _wire2api_opt_box_autoadd_u32(arr[5]),
trackTotal: _wire2api_opt_box_autoadd_u32(arr[6]),
discNumber: _wire2api_opt_box_autoadd_u32(arr[7]),
discTotal: _wire2api_opt_box_autoadd_u32(arr[8]),
year: _wire2api_opt_box_autoadd_u32(arr[9]),
genre: _wire2api_opt_String(arr[10]),
picture: _wire2api_opt_box_autoadd_picture(arr[11]),
fileSize: _wire2api_opt_box_autoadd_u64(arr[12]),
Expand All @@ -184,16 +177,12 @@ class MetadataGodImpl implements MetadataGod {
return raw == null ? null : _wire2api_box_autoadd_f64(raw);
}

int? _wire2api_opt_box_autoadd_i32(dynamic raw) {
return raw == null ? null : _wire2api_box_autoadd_i32(raw);
}

Picture? _wire2api_opt_box_autoadd_picture(dynamic raw) {
return raw == null ? null : _wire2api_box_autoadd_picture(raw);
}

int? _wire2api_opt_box_autoadd_u16(dynamic raw) {
return raw == null ? null : _wire2api_box_autoadd_u16(raw);
int? _wire2api_opt_box_autoadd_u32(dynamic raw) {
return raw == null ? null : _wire2api_box_autoadd_u32(raw);
}

int? _wire2api_opt_box_autoadd_u64(dynamic raw) {
Expand All @@ -202,15 +191,14 @@ class MetadataGodImpl implements MetadataGod {

Picture _wire2api_picture(dynamic raw) {
final arr = raw as List<dynamic>;
if (arr.length != 2)
throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
return Picture(
mimeType: _wire2api_String(arr[0]),
data: _wire2api_uint_8_list(arr[1]),
);
}

int _wire2api_u16(dynamic raw) {
int _wire2api_u32(dynamic raw) {
return raw as int;
}

Expand Down Expand Up @@ -239,12 +227,7 @@ double api2wire_f64(double raw) {
}

@protected
int api2wire_i32(int raw) {
return raw;
}

@protected
int api2wire_u16(int raw) {
int api2wire_u32(int raw) {
return raw;
}

Expand Down
Loading