htmlVideoLoader()

Help for using specific functions

htmlVideoLoader()

Postby John Robin Dove » Wed Jan 29, 2014 2:28 pm

Hi,
How can I send a user event from the loaded video every second? Timemarkers would not seem appropriate in this case. I need to retrieve the currentTime property. I haven't not been able to do this with htmlVideoLoader or htmVideoControl.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: htmlVideoLoader()

Postby Clifton » Thu Jan 30, 2014 12:55 am

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:
  1. Load a video using htmlVideoLoader().
  2. 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.)
    Image 1.png
    Start query timer with pgTimer()
    Image 1.png (24.56 KiB) Viewed 840 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].
  3. 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.)
    Image 2.png
    User event actions for Video Player
    Image 2.png (29.6 KiB) Viewed 840 times
  4. 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.
    Image 3.png
    Stopping the periodic timer pgTimer()
    Image 3.png (21.78 KiB) Viewed 840 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.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am


Return to Function Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron