You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[7.504 Adding a File Chooser](#7504-adding-a-file-chooser)
6
10
-[Week 18](#week-18)
7
11
-[9.2 Adding a moveable playhead](#92-adding-a-moveable-playhead)
8
12
-[9.207 - Implement A Timer](#9207-Implement-a-timer)
@@ -13,6 +17,48 @@
13
17
14
18
This page is about the [Object Oriented Programming module](../../../modules/level-5/cm-2005-object-oriented-programming/).
15
19
20
+
## Week 14
21
+
22
+
### 7.5 Audio Playback - Files
23
+
24
+
#### 7.504 Adding a File Chooser
25
+
26
+
_"For those of you wondering how to get the file browser working (chooser.browseForFileToOpen does not exist any more) without changing the library preprocessor symbols - use the async version, e.g. like this:"_ - Matthias Truxa
27
+
28
+
In `MainComponent.h` -> `private:`
29
+
30
+
```C++
31
+
juce::FileChooser chooser{ "Select a file..." };
32
+
```
33
+
34
+
In `MainComponent.cpp` -> `MainComponent::buttonClicked`
35
+
36
+
```C++
37
+
void MainComponent::buttonClicked(Button* button)
38
+
{
39
+
if (button == &loadButton)
40
+
{
41
+
auto dlgFlags =
42
+
juce::FileBrowserComponent::openMode |
43
+
juce::FileBrowserComponent::canSelectFiles;
44
+
45
+
this->chooser.launchAsync(dlgFlags,
46
+
[this](const juce::FileChooser& chooser)
47
+
{
48
+
player1.loadURL(chooser.getURLResult());
49
+
});
50
+
51
+
// juce::FileChooser chooser{ "Select a file..." };
52
+
// if (chooser.browseForFileToOpen())
53
+
// {
54
+
// player1.loadURL(URL{ chooser.getResult() });
55
+
// }
56
+
}
57
+
}
58
+
```
59
+
60
+
Note: There is another method where you can add `JUCE_MODAL_LOOPS_PERMITTED=1` to your JUCE preprocessors, but this method is not suggested as any changes you make to your preprocessor might not reflect in the graders' version. This might cause your project to not function as intended.
61
+
16
62
## Week 18
17
63
18
64
### 9.2 Adding a moveable playhead
@@ -21,7 +67,16 @@ This page is about the [Object Oriented Programming module](../../../modules/lev
21
67
22
68
_"There's a nasty bug in week 18 video 9.207. When you load a file the application will crash. After a bit of detective work it turns out that as the timer is being called before a file is loaded, the position is NaN (not a number). I found a simple fix for this: "_ - Jamie Jackson
0 commit comments