Forum Discussion
Musical loop
Hello Math,
I used your code and your module to try to find a solution.
Since I don't know JavaScript at all, I added some triggers in the audio layer. It works almost well: when I click on Pause, the music loop stops and I can restart it by clicking on Play.
But there is still a problem if you click on the progress bar (the variables change), also if you click on the Replay button.
I think that, at this level, it is a question of adjustments to be made in the javascript. Maybe you can still help me?
Many thanks.
Bruno
And indeed its a small adjustment now in the Javascript to pause/resume the audio when clicking the play/pause button in the player.
If you check the code you notice i added an extra if/then statement. The play/pause button in Articulate Storyline uses the aria-pressed property to see whether its pressed or not. So checking for that value returns true or false.
As we already had the selector for that button
var playButton = document.getElementById('play-pause');
We can check the value of 'aria-pressed' like this:playButton.ariaPressed
Its now only setting the appropriate variables and all works.
if(playButton.ariaPressed == true){
player.SetVar("isPaused", false);
player.SetVar("isPlayed", true);
}else{
player.SetVar("isPaused", true);
player.SetVar("isPlayed", false);
}
Adding the fixed story.
PS. This opens more options...as i do think this way you can capture any state of the player controls. Audio volume and more...
- BrunoFortDeleau4 years agoCommunity Member
Two brains worth better than one ;-)
I tested your content but I still have problems clicking on the "Replay" button on the player or moving the progress bar directly.
It seems the varaibles are totally lost ^^
- MathNotermans-94 years agoCommunity Member
Ah yes only fixed the play button ('play-pause'). To fix the code for the 'replay'-button and progress bar you need to find there 'html'-names in the console and then add that to the code.