Objective: How to query a movie for the current time every second or so.
Solution involves using the PowerPac function
pgTimer() to handle the sending of user events.
- Please realize that time markers are the best way to go, but it is not the most desirable approach in every case.
- pgTimer() can send a user event to any ToolBook object at regular intervals.
- Your user event code would simply have to query the video for its current position when it receives the periodic user event from pgTimer().
Basic Procedure:- Load a video using htmlVideoLoader().
- Immediately after the video loads, begin your query timer with pgTimer().
Like this: (Notice that user events will be sent to the object that contains the video; in this case a field called Video Player.)

- Start query timer with pgTimer()
- Image 1.png (24.56 KiB) Viewed 1331 times
BTW: When the object called Video Player receives the user event, it will also be sent the [value] parameter as a three-item comma-separated stack as [name of target object],[elapsed time in hh:mm:ss],[elapsed time in ms]. - Now the code for the user event on the Video Player might look like this:
(Notice that we are verifying the user event by checking item 1 of value, which should equal Video Player.)

- User event actions for Video Player
- Image 2.png (29.6 KiB) Viewed 1331 times
- Somewhere in the user event code, you need to call pgTimer() and set stop to true to stop the periodic timer. In our example above, we stop the periodic timer when the video reaches the end of the video.

- Stopping the periodic timer pgTimer()
- Image 3.png (21.78 KiB) Viewed 1331 times
Final note: In this example our query timer was set to fire every 500ms even though we only wanted to monitor the video every second. The reason for this is that the monitoring of the video will seem more accurate with a tighter fire time. Otherwise your monitor may actually miss the desired video playhead position by as much as 1 or 2 seconds. This way, it will be reasonably accurate. You could go down to 250ms but any greater frequency than that will likely be unnecessary.