Multimedia Operations in Acrobat 9

| No Comments

If you’ve ever run into a situation where you’ve embedded a large audio file in a PDF file using Acrobat 9 and the multimedia_play operation fails to actually start playing the audio, a simple JavaScript can get your speakers blasting tunes in no time.

Typically, with the Flash Rich Media Annotation (RMA) you’d set the RMA to play when the page that it’s on is either opened or visible. For movies that play on the page, you may want them to start when clicked or automatically when the page is first viewed. But with Sound RMAs, at least most of the ones that I’ve seen, the player opens in a floating window so that users can browse through the PDF file while the music is playing.

There are four ways to start a Sound RMA playing, automatically, when clicked, via multimedia operations and through JavaScript. The first two are set in the Sound RMA’s properties dialog in the "Enable When" drop-down list. The second two allow you to start the sound playing from other objects in the PDF file like links, bookmarks or buttons. Here’s where things get tricky if you’ve got a large audio file.

In the "Actions" tab of a link, bookmark or button, you can specify a "Multimedia Operation" and then a variety of actions like "Play", "Pause", "Rewind" etc.

When a button tries to play an inactive Sound RMA through a Multimedia Operation, you may find that the RMA activates and the player launches but the audio doesn’t start. There’s a simple "fix" for this and all it takes is a little JavaScript. Assuming you only have one sound file on a given page, the following JavaScript will both activate and begin playing the Sound RMA. It always works, every time, regardless of the size of the Sound file.

this.getAnnotsRichMedia(this.pageNum)[0].activated = true;

Why does this work? Well – the Sound RMA player is set to autoplay when activated. By activating the Sound RMA, you are, by default telling it to play. After the Sound RMA is activated, other Multimedia Operations will work as expected including "Play" if the Sound RMA is paused.