MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Poll

Method Poll

Source/SamplePlayer.cpp:153–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void SamplePlayer::Poll()
154{
155 IDrawableModule::Poll();
156
157 const juce::String& clipboard = TheSynth->GetTextFromClipboard();
158 if (clipboard.contains("youtube"))
159 {
160 juce::String clipId = clipboard.substring(clipboard.indexOf("v=") + 2, clipboard.length());
161 mYoutubeId = clipId.toStdString();
162 mDownloadYoutubeButton->SetShowing(true);
163 }
164 else if (clipboard.contains("youtu.be"))
165 {
166 std::vector<std::string> tokens = ofSplitString(clipboard.toStdString(), "/");
167 if (tokens.size() > 0)
168 {
169 mYoutubeId = tokens[tokens.size() - 1];
170 mDownloadYoutubeButton->SetShowing(true);
171 }
172 }
173 else
174 {
175 mYoutubeId = "";
176 mDownloadYoutubeButton->SetShowing(false);
177 }
178
179 if (mRunningProcess != nullptr)
180 {
181 if (mModuleSaveData.GetBool("show_youtube_process_output"))
182 {
183 char buffer[512];
184 auto num = mRunningProcess->readProcessOutput(buffer, sizeof(buffer));
185
186 if (num > 0)
187 {
188 MemoryOutputStream result;
189 result.write(buffer, (size_t)num);
190 ofLog() << result.toString();
191 }
192 }
193
194 if (mRunningProcessType == RunningProcessType::SearchYoutube)
195 {
196 std::string tempPath = ofToDataPath("youtube_temp");
197 auto dir = juce::File(tempPath);
198 if (dir.exists())
199 {
200 Array<juce::File> results;
201 dir.findChildFiles(results, juce::File::findFiles, false, "*.info.json");
202 if (results.size() != mYoutubeSearchResults.size())
203 {
204 for (auto& result : results)
205 {
206 std::string file = result.getFileName().toStdString();
207 ofStringReplace(file, ".info.json", "");
208 std::vector<std::string> tokens = ofSplitString(file, "#");
209 if (tokens.size() >= 3)
210 {

Callers

nothing calls this directly

Calls 11

ofSplitStringFunction · 0.85
ofLogClass · 0.85
ofToDataPathFunction · 0.85
ofStringReplaceFunction · 0.85
ofToFloatFunction · 0.85
containsMethod · 0.80
lengthMethod · 0.80
sizeMethod · 0.80
GetBoolMethod · 0.80
GetChannelMethod · 0.80
SetShowingMethod · 0.45

Tested by

no test coverage detected