{"id":923,"date":"2017-10-11T11:41:24","date_gmt":"2017-10-11T10:41:24","guid":{"rendered":"https:\/\/greladesign.co\/blog\/?p=923"},"modified":"2018-01-07T16:45:23","modified_gmt":"2018-01-07T16:45:23","slug":"storyline-360-custom-volume-control","status":"publish","type":"post","link":"https:\/\/greladesign.co\/blog\/2017\/10\/11\/storyline-360-custom-volume-control\/","title":{"rendered":"Storyline 360 custom volume control"},"content":{"rendered":"<p>Today I was asked by my colleague at work to help her out with fixing problem with custom volume control. She was using StoryLine 2 solution from <a href=\"http:\/\/www.swiftelearningservices.com\/how-to-create-custom-volume-controls-in-articulate-storyline-2\/\" target=\"_blank\" rel=\"noopener\">this page<\/a> but on Storyline 360. Following is the script from the SL2 solution:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar player = GetPlayer();\r\nvar volumeCount = player.GetVar('volumeCount')\r\nAudio.setMasterVolume(volumeCount);\r\n<\/pre>\n<p><!--more--><\/p>\n<p>This worked on the courses exported from StoryLine 2 as the <code>Audio<\/code> object indeed has the <code>setMasterVolume<\/code> which is not true for StoryLine 360 courses. I&#8217;ve searched internet and failed to find anything about volume controls on SL360.<br \/>\nMy colleague told me that SL has built in volume controls which work. I&#8217;ve enabled it and checked what has appeared in code (<code>player-volume<\/code> and <code>control-volume-slider<\/code>), then searched for it in output files. In the minified code I&#8217;ve found the <code>currentVolume<\/code> function which was something I hoped to get access to.<\/p>\n<p>I&#8217;ve noticed that this method is wrapped with the <code>define(\"helpers\/appState\"...<\/code> so I&#8217;ve tried to retrieve it with <code>require<\/code> and succeeded<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nvar appState = require(&quot;helpers\/appState&quot;);\r\nappState.currentVolume();\/\/get\r\nappState.currentVolume(0.5);\/\/set\r\n<\/pre>\n<p>With this finding in hand it was now simple to modify the original code to work in SL360:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar player = GetPlayer();\r\nvar volumeCount = player.GetVar(&quot;volumeCount&quot;);\r\nvar appState = require(&quot;helpers\/appState&quot;);\r\nappState.currentVolume(volumeCount);\r\n<\/pre>\n<p>The SL2 example was using <code>volumeCount<\/code> property to make a division by <code>10<\/code> we can skip it and if we set up slider to be from start: 0 to end: 1 with step: 0.1 we can modify the script even further:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar player = GetPlayer();\r\nvar value = player.GetVar(&quot;volumeSlider&quot;);\r\nvar appState = require(&quot;helpers\/appState&quot;);\r\nappState.currentVolume(value);\r\n<\/pre>\n<p>Note: I have no prior knowledge of Storyline and I kind of hacked this solution, so if there is an &#8220;official&#8221; way to setup volume please let me know:)<\/p>\n<p><strong>EDIT:<\/strong><br \/>\nI think better option for changing the volume will be to use the <code>onVolumeChanged(value)<\/code> callback method as it also updates the <code>volumeToggle<\/code> state. <\/p>\n<p>If you want to have mute button functionality then use <code>onToggleVolume()<\/code> method.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar player = GetPlayer();\r\nvar value = player.GetVar(&quot;volumeSlider&quot;);\r\nvar appState = require(&quot;helpers\/appState&quot;);\r\nappState.onVolumeChanged(value);\r\n<\/pre>\n<p>To toggle audio:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar appState = require(&quot;helpers\/appState&quot;);\r\n    appState.onToggleVolume();\/\/mute\/unmute\r\n<\/pre>\n<p>to test current state of the audio<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar appState = require(&quot;helpers\/appState&quot;);\r\nif(appState.volumeToggle) {\r\n\/\/ audio muted\r\n} else {\r\n\/\/ audio unmuted\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today I was asked by my colleague at work to help her out with fixing problem with custom volume control. She was using StoryLine 2 solution from this page but on Storyline 360. Following is the script from the SL2 &hellip; <a href=\"https:\/\/greladesign.co\/blog\/2017\/10\/11\/storyline-360-custom-volume-control\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":""},"categories":[141],"tags":[223,320],"_links":{"self":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/923"}],"collection":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/comments?post=923"}],"version-history":[{"count":10,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/923\/revisions"}],"predecessor-version":[{"id":964,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/923\/revisions\/964"}],"wp:attachment":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/media?parent=923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/categories?post=923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/tags?post=923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}