Skip to content

Commit

Permalink
Change file picker mode to custom & specify audio formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Aug 9, 2024
1 parent 63d9e36 commit 2d9f385
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup
Pod::PICKER_MEDIA = false
#Pod::PICKER_MEDIA = false
Pod::PICKER_AUDIO = false

target 'Runner' do
use_frameworks!
Expand Down
2 changes: 0 additions & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppleMusicUsageDescription</key>
<string>Allow selecting found files to use as sound effects</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Bluetooth is necessary to find and connect to The Tail Company's wings, ears, and tails</string>
<key>NSBluetoothPeripheralUsageDescription</key>
Expand Down
7 changes: 6 additions & 1 deletion lib/Backend/Definitions/Action/base_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class CommandAction extends BaseAction with _$CommandAction {

@HiveType(typeId: 12)
@unfreezed
class AudioAction extends BaseAction with _$AudioAction {
class AudioAction extends BaseAction with _$AudioAction implements Comparable<AudioAction> {
AudioAction._();

@Implements<BaseAction>()
Expand All @@ -112,6 +112,11 @@ class AudioAction extends BaseAction with _$AudioAction {
@HiveField(3) @Default(ActionCategory.audio) final ActionCategory actionCategory,
@Default({}) final Map<DeviceType, String> nameAlias,
}) = _AudioAction;

@override
int compareTo(AudioAction other) {
return file.compareTo(other.file);
}
}

@unfreezed
Expand Down
10 changes: 9 additions & 1 deletion lib/Frontend/pages/custom_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ class _CustomAudioState extends ConsumerState<CustomAudio> {
floatingActionButton: FloatingActionButton.extended(
onPressed: () async {
_audioLogger.info("Opening file dialog");
FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.audio, withReadStream: true);
FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.custom, withReadStream: true, allowedExtensions: [
'aac',
'm4a',
'flac',
'wav',
'avif',
'mp3',
'ac3',
]);
if (result != null) {
_audioLogger.info("Selected file");
PlatformFile file = result.files.first;
Expand Down

0 comments on commit 2d9f385

Please sign in to comment.