Skip to content

Commit

Permalink
AudioFilePlayer: Fix oddity in recents dir Fixes #171
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher31 committed Feb 16, 2020
1 parent 0cf2a4c commit f9e05a4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/engine/nodes/AudioFilePlayerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,25 @@ class AudioFilePlayerEditor : public AudioProcessorEditor,
DirectoryIterator iter (recentsDir, recursive, processor.getWildcard(), File::findFiles);
while (iter.next())
{
if (iter.getFile().isDirectory())
continue;
chooser->addRecentlyUsedFile (iter.getFile());
}
}
}

void timerCallback() override { stabilizeComponents(); }
void changeListenerCallback (ChangeBroadcaster*) override { stabilizeComponents(); }

void stabilizeComponents()
{
if (processor.getWatchDir().isDirectory())
addRecentsFrom (processor.getWatchDir());
if (chooser->getRecentlyUsedFilenames().isEmpty())
addRecentsFrom (processor.getWatchDir());

if (chooser->getCurrentFile() != processor.getAudioFile())
chooser->setCurrentFile (processor.getAudioFile(), dontSendNotification);
if (processor.getAudioFile().existsAsFile())
chooser->setCurrentFile (processor.getAudioFile(), dontSendNotification);

playButton.setToggleState (processor.getPlayer().isPlaying(), dontSendNotification);
playButton.setButtonText (playButton.getToggleState() ? "Pause" : "Play");
Expand Down Expand Up @@ -139,7 +144,10 @@ class AudioFilePlayerEditor : public AudioProcessorEditor,

void filenameComponentChanged (FilenameComponent*) override
{
processor.openFile (chooser->getCurrentFile());
const auto f1 = chooser->getCurrentFile();
const auto f2 = processor.getAudioFile();
if (! f1.isDirectory() && f1 != f2)
processor.openFile (chooser->getCurrentFile());
}

void resized() override
Expand Down Expand Up @@ -240,7 +248,7 @@ class AudioFilePlayerEditor : public AudioProcessorEditor,
if (fc.browseForDirectory())
{
processor.setWatchDir (fc.getResult());
addRecentsFrom (processor.getWatchDir());
// addRecentsFrom (processor.getWatchDir());
}
};

Expand Down

0 comments on commit f9e05a4

Please sign in to comment.