Widgets for Adobe Acrobat : VideoPlayerX

Using the vpx_init() function

VideoPlayerX build 10.2 and later will look for a document-level JavaScript function named "vpx_init" and if found, will call the function once when the annotation activates. If it's not defined, it won't. The point behind this feature is that in many cases you will want to send one or more video annotations specific setup commands (such as changing skin colors, scale modes, etc.) whenever they activate. As the annotation's Flash stage doesn't exist until it's activated, document-level scripts fired when the PDF opens cannot send those instructions. Placing them in the vpx_init() function you know that the annotation is ready to receive commands, and which annotation it is.

Of course if your PDF software doesn't support JavaScript, or it's disabled, nothing will work!

Parameters sent to the function

The vpx_init() function should have two parameters (RMA,Page) and no return value:

RMA	name of the Rich Media Annotation (string)
Page	PDF page on which the RMA is located (integer, zero-based)


Suppose your annotation has a name of "RM1" and has been placed on page 2. You want to set this annotation to have a red background color, but not affect any others in the document. You would define a document-level function as follows:

function vpx_init(r,pg) {
  if (r=="RM1" && pg==1) {

Suppose you want to set every annotation to use "exactFit" scaling except the ones on page 4, which should use "noScale". You would define a document-level function as follows:

function vpx_init(r,pg) {
  var _sm = (pg==3)? "noScale":"exactFit";

You can use the vpx_init() function to do whatever you want, it doesn't have to relate to controlling the video. Note that in some very rare cases the function may not be fired - if the JSAPI engine takes more than 3 seconds to enter the ready state, VideoPlayerX will assume it's not available and will stop talking. In most cases the JSAPI engine will be ready in less than 500 milliseconds.

Back to VideoPlayerX