Display Time (CP2019)


Almost 10 years ago I wrote a blog post to answer user question  quote: “…. if there was anyway to insert running time”.
The user wanted a display on all slides of the time information you can find  in the TOC (total duration of the project and elapsed duration).  Total duration can be found also in the panel ‘Project Info’ in Captivate, which shows global project information (number of slides/frames). In this panel you can also check the expected size of the output file.
Total duration is calculated as the sum of slide durations. Similar the elapsed duration:is calculated as the sum of the duration of the slides before the currently viewed slide. I would call that type of duration ‘developer time’. 

Developer time can be very different from the real time spent by the user viewing slides in that project.  You’ll see in this refurbished article how to show both times, developer and real ones. It is a nice use case for System variables.  BTW, if you didn’t get my free table with System variables, maybe it is the right moment .

Contrary to the old post, which was meant for SWF output, I used JS this time instead of advanced actions with the Expression command.  Reason is that for SWF output the formatting of the variable values could be controlled by the number of characters to display when inserting the variable in a text container. That is not working for HTML5 output. Formatting of numbers is a typical use case (like random data) where I tend to use JavaScript.

Example output

Watch this published movie. The described workflow (from the original post) is working only for linear projects. Sorry for the use of TTS, those slides are based on a longe project….in Dutch.

The ‘developer time’ is shown in the top left corner: total project time (secs), time of the previously viewed slides (secs) and percentage viewed.

Real time workflow

The real time is visible at the bottom, next to my name. I used the Timer widget for the real time.  You have to be careful: set the maximum time to a high number, to avoid triggering the end of time action. Getting rid of the background is easy, have a look at my setup.:

Developer's time workflow

As I announced at the start, for several reasons I preferred to use JS instead of Expressions in an Advanced action as was the case for the older blog post. I propose two scripts. The first one is close to the older blog post, because I use the same system variables, and two methods of the JS interface for Captivate. Details can be found in this document.

In the second script I skipped using the known system variables, replaced them by some more methods of the same document.

Script 1


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 these 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, variables in JavaScript used these names:

  • frames: will start with the value of cpInfoFrameCount and end after calculation return the total project duration (secs) 
  • start: will start with a frame number (frist frame of the present slide) and after calculation return the alreadu viewed duration (secs)
  • speed: will store the value of cpInfoFPS
  • percent: will return the percentage viewed after calculation


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 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 to JS newbies. I planned to use the formatting 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.

Script 2

No system variables here, the user variables and variables in JS are the same as in the first script: v_total, v_done, v_perc, frames, speed, start, percent.. Have a look at the script:

I didn't need the method getVariableValue in this case but used three more methods on top of 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 FPS value. (line 3)

The other lines in the script are similar to those explained in the first script.

8 responses
Hi, I've tried exactly the same steps which you mentioned here for display time but I am not seeing any thing in the end of the presentation. Can you help me with this???
@Pushpenda Bit difficult to answer in blog comments. How did you test? You need to test using F11, Preview HTML in Browser, or after publishing and uploading to a webserver or a LMS. Was that the case?
@lieve Weymeis Thanks for the quick response. Yes, I am previewing in HTML browser. If everything seems perfect then I will upload it in moodle. But in preview itself I am not getting desired output. Is there any other way to connect with you, so that it would be easier for you to understand where's the mistake is??
Go to the Adobe forums, or to the eLearning community (you can open it from within Captivate). There it is possible to explain fully and add screenshots. I am always around in both locations.
First, thank you for this post! I have been trying to implement your script 1. I have a 23-slide project that consists of an Intro slide, instruction slide, enter your name slide, 18 questions slide, result slide, and the thank you slide. For the 18-question slide, 8 are multiple choice with images that I created by adding a quiz slide. the other 10 question slide are randomly generated from the quiz pool manager. 1. I have script one to execute on entering each slide. (not the quiz pool slides because it will not allow me) 2. I have the widget on each slide. (setup like your example) 3. On my result slide I have it set to show the name from the entry box slide 3, v-total and v_percent. I get no data for these variables when I preview in HTML5. 4. I set to see the cpInforElapsedTimeMS and I see that result just fine. My question is: 1. Am I missing something that I should be doing. Or 2. Have you since found another method of using JS to take the Elapsed Time in MS and show it in min/sec? 3. Is there a way to set the slide from the quiz pool to also be time? I know this was a lot and if you need more information please let me know. Sincerely, AP
Thanks for visiting my blog. All my posts are for free, and some have lot more information than you'll get in a not-free training. Please understand that you cannot ask me to enhance the use case for one person, also for free. Random questions have a lot of limitations as you may read in another blog post https://blog.lilybiri.com/random-questions-dos-.... You can always try to post your question in a forum, maybe someone will help you for free.
Thank you for your response. My apologies but I did not see an option to offer any payment for asking a question. I have no issue paying for professional advice when I am stuck on a problem. However, in this situation, I was finally able to figure it out myself. Thank you for your time.
1 visitor upvoted this post.