Display Time (CP2019)

Intro

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

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 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

Javascript

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.