Hi Kamil, the code has been updated. You no longer need to use the require method and can access a DS object directly which contains the appState instance.
unfortunately, there is no such function like volumeToggle in DS.appState. I was able to show currentVolume but can't change. I've noticed function like setVolume but it doesnt work or I execute incorrectly. Are you able to help?
Hi Brian, see the file "audio-control.story" I provided in my previous reply. This contains a custom volume control using a slider interacting with JavaScript to change the volume. Its a working example.
Sam, thank you, I appreciate that. Was hoping to find some other examples, such as how to set a specific volume level at the beginning of the course, how to create a mute button, those sorts of things.
Not being a javascript guy I am unable to figure out from your example how to do these things that (I assume) are relatively easy to do now?
Thank you so much for these examples... One quick question: I've tried to figure out what the purpose might be (how you're using) %lastvolume% but can't see anything obvious. Would you be able to elaborate on how it could/should be used in these examples?
Once again, very much appreciate you taking the time to share your expertise here. This community never fails to amaze me.
11 Replies
Hi Kamil, the code has been updated. You no longer need to use the require method and can access a DS object directly which contains the appState instance.
DS.appState.volumeToggle();
Hi Sam,
unfortunately, there is no such function like volumeToggle in DS.appState. I was able to show currentVolume but can't change. I've noticed function like setVolume but it doesnt work or I execute incorrectly. Are you able to help?
Hi Kamil, my mistake, DS.appState.volumeToggle is a boolean.
The method you need is:
$volume = 0.3; // $volume is a number from 0 - 1 (increments of 0.1)
DS.appState.currentVolume($volume);
Many thanks Sam! We missed the ability to set volume to 100% via Javascript since the big core update earlier this year,
Same here... anyone aware of any other resources around setting/adjusting/creating custom volume controls using javascript?
Hi Brian, see the file "audio-control.story" I provided in my previous reply. This contains a custom volume control using a slider interacting with JavaScript to change the volume. Its a working example.
Sam, thank you, I appreciate that. Was hoping to find some other examples, such as how to set a specific volume level at the beginning of the course, how to create a mute button, those sorts of things.
Not being a javascript guy I am unable to figure out from your example how to do these things that (I assume) are relatively easy to do now?
Hi Brian, see attached. A couple more things added (mute and set volume at beginning of timeline).
This. IS. Amazing!!
Thank you so much for these examples... One quick question: I've tried to figure out what the purpose might be (how you're using) %lastvolume% but can't see anything obvious. Would you be able to elaborate on how it could/should be used in these examples?
Once again, very much appreciate you taking the time to share your expertise here. This community never fails to amaze me.
B
Never mind... just realized that %lastvolume% is required to unmute the audio, brilliant!
Ah, well done. You figured it out.
This discussion is closed. You can start a new discussion or contact Articulate Support.