From 8b708b348d44ab47b2bdefcba41d27d02a2b413c Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 27 Feb 2023 14:52:30 +0000 Subject: [PATCH] AudioPlaybackDemo: Fix usability issues on Android Android devices won't necessarily be able to load MP3 files, so that option has been removed from the file chooser. FLAC files should be supported, but were missing from the MIME table. The demo no longer tries to load files into the thumbnail view if they previously failed to load into the transport. --- examples/Audio/AudioPlaybackDemo.h | 11 ++++++++--- modules/juce_core/files/juce_common_MimeTypes.cpp | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/Audio/AudioPlaybackDemo.h b/examples/Audio/AudioPlaybackDemo.h index 6d317f4466..0251c62a21 100644 --- a/examples/Audio/AudioPlaybackDemo.h +++ b/examples/Audio/AudioPlaybackDemo.h @@ -415,9 +415,14 @@ private: //============================================================================== void showAudioResource (URL resource) { - if (loadURLIntoTransport (resource)) - currentAudioFile = std::move (resource); + if (! loadURLIntoTransport (resource)) + { + // Failed to load the audio file! + jassertfalse; + return; + } + currentAudioFile = std::move (resource); zoomSlider.setValue (0, dontSendNotification); thumbnail->setURL (currentAudioFile); } @@ -492,7 +497,7 @@ private: if (FileChooser::isPlatformDialogAvailable()) { - fileChooser = std::make_unique ("Select an audio file...", File(), "*.wav;*.mp3;*.aif"); + fileChooser = std::make_unique ("Select an audio file...", File(), "*.wav;*.flac;*.aif"); fileChooser->launchAsync (FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles, [this] (const FileChooser& fc) mutable diff --git a/modules/juce_core/files/juce_common_MimeTypes.cpp b/modules/juce_core/files/juce_common_MimeTypes.cpp index 42e150e93e..fe08f71a8d 100644 --- a/modules/juce_core/files/juce_common_MimeTypes.cpp +++ b/modules/juce_core/files/juce_common_MimeTypes.cpp @@ -206,6 +206,7 @@ private: { "fdf", "application/vnd.fdf" }, { "fif", "application/fractals" }, { "fif", "image/fif" }, + { "flac", "audio/flac" }, { "fli", "video/fli" }, { "fli", "video/x-fli" }, { "flo", "image/florian" },