June 4, 2019
Time information – with Captivate’s JS Methods
Comments
(0)
June 4, 2019
Time information – with Captivate’s JS Methods
Lieve is a civil engineer (ir) and a professional musician. After years of teaching and research (project management/eLearning/instability) she is now a freelancer specializing in advanced Adobe Captivate as trainer and consultant. Her blog is popular with Captivate users worldwide. As an Adobe Community Expert and Adobe Education Leader, she has presented both online and offline. Since 2015 she is moderator on the Adobe forums and was named as Forum Legend (special category) in the Wall of Fame. In 2017 Adobe Captivate users voted for Lieve as a Top Content Experience Strategist.
Legend 245 posts
Followers: 411 people
(0)

Intro

In a previous post I showed an example movie, where both developer’s time and the real time in a project is shown. Showing rea time in a linear project is straightforward, using the Timer widget. For the developer’s durations however you need to use either an advanced action or JavaScript. This time I opted for JS, using the interface provided by the Captivate team. You have the choice between two scripts. They have to be triggered by the On Enter event of each slide, either as a standalone command or as part of an advanced action if you need more commands to be done with the On Enter vent.

Solution 1 –  System variables and methods

This workflow is close to the one I used in the old blog post with the Expression commands. It will transfer the values of some system variables to variables in JS, do some calculations and return the result to Captivate where they are displayed by in serting user variables in text containers.

Variables

The system variables used in the first script are:

  • cpInfoFrameCount: its value is the total number of frames in the Project Info panel (see first screenshot in this article)
  • cpInfoFPS: each movie is played at a certaing speed, which defines its qualtiy. It is indicated as Frames per Second. The higher that rate, the higher the quality
  • cpInfoCurrentFrame: indicates the present frame number. Frames are numbered, starting with 0, not per slide but for the whole project. More details can be found in this blog post about Micro-navigation

In Captivate I created three user variables to display the results in the project:

  • v_total: total duration of the project in seconds
  • v_done: sum of the duration of the previous slides in seconds
  • v_perc: percentage of duration viewed, in %

To avoid confusion, the variables in the JavaScript have these names:

  • frames: will start from the value of cpInfoFrameCount and after calculation return the total project duration (secs)
  • start: will start with a frame number (first frame of the present slide) and after calculation return the already viewed duration (secs) of the previous slides
  • speed: will store the value of cpInfoFPS
  • percent: will  return the percentage viewed after calculation

Script

This script has to be triggered On Enter for each slide. That can be directly with the command ‘Execute JavaScript’ as simple action if you don’t need any other commands to be done on entering the slide. If no slide nneeds any extra commands, you can select all slides in the Filmstrip and attach the script to all slides at once. If you need more for some slides, it could be a good idea to use the script in an advanced action, where you can add more commands. Even a shared action is possible, but in this example had no real sense.
Have a look at the script:

I am using two methods from the Common JS Interface:

  • getVariableValue to store the values of Captivate’s system variables in the JS variables frames, speed, start. (lines 1-3)
  • setVariableValue to return the results to the Captivate variables v_total, v_done and v_perc (lines 6-7,9)

The calculations in lines 4-5 and 8 are straightforward. To control the formatting of the numbers I used the JS Number method ‘Number.toFixed(x)’. I didn’t want to display two decimals for a simple reason: the first frame will be detected on each slide, and that would have led to a duration of 0,03 seconds on the first slide (30 seconds in a frame). It would be possible to split up the results in minutes and seconds as well. I wanted this example to be a simple introduction for JS newbies. I planned to use the formatting workflow  in a third article about numbers. The first two were ‘Playing with numbers – part 1‘ and ‘Playng with numbers – part 2‘. Both were meant as simple intro to JS for newbies. However, since they didn’t get a lot of viewers, I gave up spending more time on it. I may upgrade those two posts with HMTL5 output and to the present CP version.

Solution 2 – only methods

Variables

No system variables here, the user variables and variables in JS are the same as in the first script:

  • user variables v_total, v_done, v_perc,
  • variables in JS: frames, speed, start, percent..

Script – methods

Have a look at the script:

I didn’t need the method getVariableValue in this case but used three more methods adding to the already described method setVariableValue to return the results to Captivate:

  • getPlaySpeed: returns the same value as the system variable cpInfoFPS (line 1)
  • getCurrentFrame: returns the same value as the system variable cpInfoCurrentFrame (line 2)
  • getDurationInSeconds: spares me one calculation, this value doesn’t exist as system variable. This time I don’t have to divide the total number of frames (exists as getDurationInFrames) by the FPSusing the  value. (line 3)

The other lines in the script are similar to those explained in the first script, using the Number method .toFixed to format the results with the wanted number of decimals.

TIP: wondering how to have line numbers in the scripts? I use Brackets to create a JS, don’t like that tiny small JS window in Captivate. Brackets is free, a great editor (as is Notepad+).

0 Comments
Add Comment