GSAP timeline to speedup / slowdown any animations on it
As i mentioned before in some posts GSAP has a timeline that controls all animation. And probably Storyline uses that timeline for its animation too. As i didnot find a way to control Storyline's timeline i made a sample showing how perfectly and easily GSAP's timelines control the speed of animations.
BTW I have another question, but it is for another function, do you know how a user can change the size of the closing caption by running a Java, I found some solution, but this one only works for one time.
I used:
Big size
if (!window.alteredCaptions) { var sheet = document.createElement('style'); sheet.innerHTML = ".caption{font-size:180% !important;}"; document.body.appendChild(sheet); window.alteredCaptions = true; }
Small size
if (!window.alteredCaptions) { var sheet = document.createElement('style'); sheet.innerHTML = ".caption{font-size:140% !important;}"; document.body.appendChild(sheet); window.alteredCaptions = true; }
Any advice for this?
this could be interesting for others
here is an example, to switch the CC size in the course
I been having problems with my background music, when I speed down my audio, also the music slowdown, can you help me to identify what I'm doing wrong.
One more question, is there any way to add in the code that respects the speed of audio en video playback from one slide to another, because every time I advance to the next slide the user would have to click on speed +/-, right now it just works with audio, but if I have both this doesn't work :(
I have read several posts about GSAP, I did the test with the example of speeding up audio and video, however I would like to know if you have any update about the timeline speeding up as well.
When you plan your project with GSAP, and ensure all is build with GSAP instead of using default Storyline transitions and animations.... you can use GSAPs timeline functions and global timescale functionality to speed up or slow down the complete setup. The newest version of GSAP 3.11.1 has a new function called gsap.context() that makes it even easier to maintain and control behaviour of all your gsap animations.
As now all this still isnot possible with the default Storyline timeline and animations...i suspect they use GSAP internally for it, but i tried controlling it and that doesnot work. Mentioned this to Articulate though and hope they implement it in the near future.
Another great new feature in the latest gsap version is gsap.matchMedia()
This feature gives you the option to adapt animations based on screensize and resizing. Whether and how this works in Storyline360 ( Storyline being not responsize ) i have to test.
var allAudios = document.getElementsByTagName("audio"); for (var i = 0; i < allAudios.length; i++) { allAudios[i].playbackRate = 1.25; }
slow down audio
var allAudios = document.getElementsByTagName("audio"); for (var i = 0; i < allAudios.length; i++) { allAudios[i].playbackRate = 0.5; }
Audio background
//load the scripts dynamically into the head of the document
function add_line() { var line = document.createElement("audio"); var head=document.getElementsByTagName('body')[0]; line.type = "audio/mp3"; line.src=""; line.id="bgSong" ; line.autoplay = true; line.loop = true; head.appendChild(line); }
//but we only want to add these once! if(document.getElementById('bgSong')==null){ add_line(); var audio = document.getElementById('bgSong'); audio.volume = 0.5; }
play audio background
var audio = document.getElementById('bgSong'); audio.src="story_content/external_files/MusicaDiversidad.mp3"; audio.load(); audio.play();
Hope you find the solution in the java so that it does not take the background audio speed, also I would like the speed respect in the other slides, because I keep continuing the slides I need to set up the velocity in each one.
I wish I had knowledge of java, but this time it's beyond my knowledge.
What you did wrong is looping all the audios in the Storyline and changing their playback speed.
A for loop basically acts on all elements it finds. To fix that you need to only act on your embedded audio. How to do that ? Well several solutions...for one you can check the name of the audio...if that is the one you want changed....act.
for (var i = 0; i < allAudios.length; i++) { allAudios[i].playbackRate = 0.25; }
Like this...it changes th playbackRate of all your audios...
for (var i = 0; i < allAudios.length; i++) { if(mp3Name !="MusicaDiversidad.mp3"){ allAudios[i].playbackRate = 0.25; } }
And like this it changes all audios except your background music. To get this working we still need to know the names of our mp3s. Especially because Storyline generates a custom name for embedded audio.
Like this when checking for allAudios[i].url: .../story_content/external_files/MusicaDiversidad.mp3 .../story_content/5UxkXXG1RPh_44100_48_0.mp3
Also you notice the folder structure for embedded and external audio is different.
So splitting the url in an array and getting the last value of that array gives us the proper names. Then this works.
for (var i = 0; i < allAudios.length; i++) { var mp3URL = allAudios[i].src; var tmpArr = mp3URL.split("/"); mp3Name = tmpArr[tmpArr.length-1]; audioNamesArray.push(mp3Name); console.log(mp3Name+" pushed into ["+audioNamesArray+"]"); if(mp3Name !="MusicaDiversidad.mp3"){ allAudios[i].playbackRate = 0.25; } }
Woooooow that's great news... Thank you very much Math, you don't know how grateful I am. It is that I was taking several post codes on the subject and so I did not know how to configure it correctly, what course I need to take to learn java.
One more question, is there any way to add in the code that respects the speed of playback from one slide to another, because every time I advance to the next slide the user would have to click on speed +/-, and we need it because this configuration is for people with disabilities and should be as few clicks as possible .
Create a custom variable. In this case 'audioSpeed', a numeric variable
Its default value will be 1. Then we go to the Javascript ( PS. it is Javascript, Java is something completely different ;-)
In this case we cannot add all of the script simply to the Maximo and Minimo buttons as you want the audio to be speed up or down on next pages when a user set it earlier. So we need 2 changes...one on the buttons that saves the chosen speed to the variable 'audioSpeed' and one on the start of every slide that sets the speed of the audio. Let us first change the buttons Maximo and Minimo.
This is the code needed on Minimo. // player is your StorylinePlayer and GetPlayer() is a command to connect to it. var player = GetPlayer();
// the audiospeed we want var audioSpeed = 0.25;
// Now we can set the Storyline variable player.SetVar("audioSpeed",audioSpeed);
And offcourse in your loop like this. allAudios[i].playbackRate = audioSpeed;
On Maximo its the same except for the different speed.
Change this, and test it :-)
If you have that working as planned, the next step is getting it working on start of every next slide. You could add it to a Masterslide and have it happen on every slide that uses that Masterslide, but for now im showing it just on start of the existing slides.
We start with adding a Javascript trigger that gets executed When the timeline starts.
The code we need now is this. var allAudios = document.getElementsByTagName("audio"); var audioNamesArray = []; var mp3Name;
// player is your StorylinePlayer and GetPlayer() is a command to connect to it. var player = GetPlayer();
// Now we can get the Storyline variable var audioSpeed = player.GetVar("audioSpeed");
for (var i = 0; i < allAudios.length; i++) { var mp3URL = allAudios[i].src; var tmpArr = mp3URL.split("/"); mp3Name = tmpArr[tmpArr.length-1]; audioNamesArray.push(mp3Name); console.log(mp3Name+" pushed into ["+audioNamesArray+"]"); if(mp3Name !="MusicaDiversidad.mp3"){ allAudios[i].playbackRate = audioSpeed; }
}
Notice GetVar to get a Storyline variable into Javascript.
Math, I saw the storyline project very quickly and my brain exploded at a surprising result. Let me interact with this, but again, verily thank you very much...
HI MATH; I'm having problems with the content, but it's weird because when I view the story.html on my computer the button speed works, but when I upload it on an lms it doesn't work. I leave you here my file and the link of it in the lms to know what I am doing wrong.
I know this happened before... Mark Ramsey figured out why i do believe.... something to do with selector in Storyline not correct when published on the LMS. In this post i believe... https://community.articulate.com/discussions/articulate-storyline/variable-playback-speed On page 4 it states why...getting to the audio file by using getElementsByTagName returns zero indexes on a LMS.
A direct selector to the proper folder the audio is in should work. As this always depends on the LMS you use...i see if i can find a solution.
PS. The invitation to Scorm Cloud is not valid anymore.
I do think that getting the 'getElementsByTagName' so the part where all audio used in the Storyline is gathered... out of the MasterSlide and into the main HTML of the published output might work.