mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
ConvolutionDemo: Fix bug where "Load File..." button only worked once
This commit is contained in:
parent
cd41e31cb5
commit
d31b85ef00
1 changed files with 34 additions and 29 deletions
|
|
@ -587,37 +587,42 @@ private:
|
||||||
{
|
{
|
||||||
audioFileReader.stop();
|
audioFileReader.stop();
|
||||||
|
|
||||||
if (fileChooser == nullptr)
|
if (fileChooser != nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SafePointer<AudioPlayerHeader> safeThis (this);
|
||||||
|
|
||||||
|
if (! RuntimePermissions::isGranted (RuntimePermissions::readExternalStorage))
|
||||||
{
|
{
|
||||||
SafePointer<AudioPlayerHeader> safeThis (this);
|
RuntimePermissions::request (RuntimePermissions::readExternalStorage,
|
||||||
|
[safeThis] (bool granted) mutable
|
||||||
if (! RuntimePermissions::isGranted (RuntimePermissions::readExternalStorage))
|
{
|
||||||
{
|
if (granted)
|
||||||
RuntimePermissions::request (RuntimePermissions::readExternalStorage,
|
safeThis->openFile();
|
||||||
[safeThis] (bool granted) mutable
|
});
|
||||||
{
|
return;
|
||||||
if (granted)
|
|
||||||
safeThis->openFile();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileChooser.reset (new FileChooser ("Select an audio file...", File(), "*.wav;*.mp3;*.aif"));
|
|
||||||
|
|
||||||
fileChooser->launchAsync (FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles,
|
|
||||||
[safeThis] (const FileChooser& fc) mutable
|
|
||||||
{
|
|
||||||
if (safeThis != nullptr && fc.getURLResults().size() > 0)
|
|
||||||
{
|
|
||||||
auto u = fc.getURLResult();
|
|
||||||
|
|
||||||
if (! safeThis->audioFileReader.loadURL (u))
|
|
||||||
NativeMessageBox::showOkCancelBox (AlertWindow::WarningIcon, "Error loading file", "Unable to load audio file", nullptr, nullptr);
|
|
||||||
else
|
|
||||||
safeThis->thumbnailComp.setCurrentURL (u);
|
|
||||||
}
|
|
||||||
}, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileChooser.reset (new FileChooser ("Select an audio file...", File(), "*.wav;*.mp3;*.aif"));
|
||||||
|
|
||||||
|
fileChooser->launchAsync (FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles,
|
||||||
|
[safeThis] (const FileChooser& fc) mutable
|
||||||
|
{
|
||||||
|
if (safeThis == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fc.getURLResults().size() > 0)
|
||||||
|
{
|
||||||
|
auto u = fc.getURLResult();
|
||||||
|
|
||||||
|
if (! safeThis->audioFileReader.loadURL (u))
|
||||||
|
NativeMessageBox::showOkCancelBox (AlertWindow::WarningIcon, "Error loading file", "Unable to load audio file", nullptr, nullptr);
|
||||||
|
else
|
||||||
|
safeThis->thumbnailComp.setCurrentURL (u);
|
||||||
|
}
|
||||||
|
|
||||||
|
safeThis->fileChooser = nullptr;
|
||||||
|
}, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeListenerCallback (ChangeBroadcaster*) override
|
void changeListenerCallback (ChangeBroadcaster*) override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue