{"id":1716,"date":"2018-11-04T18:08:44","date_gmt":"2018-11-04T18:08:44","guid":{"rendered":"https:\/\/lab.florianschwarz.net\/PennController\/?post_type=yada_wiki&#038;p=1716"},"modified":"2018-11-07T15:04:40","modified_gmt":"2018-11-07T15:04:40","slug":"penncontroller-downloadvoicebutton","status":"publish","type":"yada_wiki","link":"https:\/\/lab.florianschwarz.net\/PennController\/wiki\/penncontroller-downloadvoicebutton\/","title":{"rendered":"PennController.DownloadVoiceButton"},"content":{"rendered":"<p class='command-format'><code>PennController.DownloadVoiceButton( text )<\/code><\/p>\n<p>Generates a <code>&lt;button&gt;<\/code> that, when clicked, proposes to download a ZIP archive containing all the audio recordings collected during the experiment.<\/p>\n<p>This should be used only after the recordings have been sent to the server you specified (see <a href=\"https:\/\/lab.florianschwarz.net\/PennController\/wiki\/recording-and-collecting-audio-samples\/\" class=\"wikilink-published\">this page<\/a>). You would typically send the results early with <code><a href=\"https:\/\/lab.florianschwarz.net\/PennController\/wiki\/penncontroller-sendresults\/\" class=\"wikilink-published\">PennController.SendResults<\/a><\/code> and show an exit page with the button after that.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>[js highlight=&#8221;24&#8243; try=&#8221;data&#8221;]PennController.InitiateRecorder(&#8220;https:\/\/myserver\/uploadVoices\/saveRecordings.php&#8221;);<\/p>\n<p>PennController( &#8220;record&#8221; ,<br \/>\n    newVoiceRecorder(&#8220;recorder&#8221;)<br \/>\n        .print()<br \/>\n        .wait()<br \/>\n);<\/p>\n<p>PennController.SendResults();<\/p>\n<p>PennController(<br \/>\n    newFunction(&#8220;check upload&#8221;, ()=>PennController.uploadRecordingsError)<br \/>\n        .test.is()<br \/>\n        .success(<br \/>\n            newText(&#8220;confirmation&#8221;, &#8220;The recordings were sent to the server. &#8220;)<br \/>\n                .print()<br \/>\n        )<br \/>\n        .failure(<br \/>\n            newText(&#8220;error&#8221;, &#8220;There was a problem sending the recordings to the server. &#8220;)<br \/>\n                .settings.color(&#8220;red&#8221;)<br \/>\n                .print()<br \/>\n        )<br \/>\n    ,<br \/>\n    newText(&#8220;download&#8221;, PennController.DownloadVoiceButton(&#8220;Click here to download an archive of your recordings.&#8221;) )<br \/>\n        .print()<br \/>\n    ,<br \/>\n    newTimer(&#8220;inifinite&#8221;, 0)<br \/>\n        .wait()<br \/>\n);<br \/>\n[\/js]<\/p>\n<p>Invites the participant to make a voice recording and send the results to the server. In this case, we specified a dummy URL, so uploading the recordings will fail, and <code>PennController.uploadRecordingsError<\/code> will accordingly be defined. The last screen will inform the participant of the error (since <code>PennController.uploadRecordingsError<\/code> is <strong>not<\/strong> void\/undefined) and will show a button to download an archive of the recordings.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"wiki_cats":[13,5,4,33,35],"wiki_tags":[],"class_list":["post-1716","yada_wiki","type-yada_wiki","status-publish","hentry","wiki_cats-command","wiki_cats-documentation","wiki_cats-element","wiki_cats-global-command","wiki_cats-penncontroller-global"],"_links":{"self":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki"}],"about":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/types\/yada_wiki"}],"author":[{"embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/comments?post=1716"}],"version-history":[{"count":6,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1716\/revisions"}],"predecessor-version":[{"id":1722,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1716\/revisions\/1722"}],"wp:attachment":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/media?parent=1716"}],"wp:term":[{"taxonomy":"wiki_cats","embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/wiki_cats?post=1716"},{"taxonomy":"wiki_tags","embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/wiki_tags?post=1716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}