This tutorial shows you how to work with the Combine Files features in Acrobat X. See what the all-new Acrobat DC can do for you.

Download a free trial of the new Acrobat.

Controlling multimedia with Acrobat X

Learn how to control multimedia in PDF files using the tools in Adobe Acrobat X.

By Dave Merchant – September 22, 2011

 



Dave Merchant looks at ways you can control multimedia in PDF files using the tools in Adobe Acrobat.

View transcript

Controlling multimedia with Acrobat X

Dave Merchant – September 22, 2011

Hello, I'm Dave Merchant, and today I want to show you some of the ways we can control multimedia in PDF files, using the tools in Adobe Acrobat.Ever since version 9, Acrobat has been able to add interactive multimedia annotations - videos, sounds, flash files and 3D models - into PDF files in a way that plays back cross-platform, using the embedded Flash Player engine built into Acrobat and Adobe Reader 9 and X.

This type of multimedia is called a Rich Media annotation, as opposed to the "legacy" media which we could embed with earlier versions of Acrobat.

Legacy media is no longer supported for authoring in Acrobat X, so I'm not covering it in this video, but the general principles are roughly the same.Rich Media is not only reliable in playback, but adding it to a file is really simple - in Acrobat X we open the Tools Pane, Content panel and click the Multimedia button, in Acrobat 9 we use the Tools menu.

In Acrobat X, if you do this a lot you can add the multimedia button to the Quick Tools area by dragging it or by right-clicking it.We can add four types of media - a video (in FLV or H.264 format), an MP3 sound file, a SWF Flash file or a 3D model.

3D annotations are slightly different objects, so I'll concentrate today on the other three; we have an in-depth series of videos on how to work with 3D files on the AcrobatUsers.com Learning Center if you're so inclined.So let's drop in a video of our Mayor, with all the default options.

Draw out a rectangle, choose the video file, in this case an H.264-encoded F4V file, and click OK.

To activate the annotation we just click the poster image.

Whenever you embed a video or sound, Acrobat attaches a SWF player widget - so your readers get a set of default play, pause and timeline tools without having to do anything.

For many situations that's all you need, but there can be times when you want to control this Rich Media annotation via a button or link, or even a script.

This is especially true of SWF files, but let's start with this video.Right now we can watch it with the inbuilt player controls, but I want to jump to a specific place, based on links in the text.

I know that there's a coffee cup 34.5 seconds in, so let's make a link for the word "coffee" that will take us to that point in the video.

I know it's not long to wait, but if this was an hour-long video, you'd be stuck listening to me while we tested the playback.We create links in Acrobat X from the Tools Pane > Content panel, pick the Link tool and draw around the word "coffee".

I want this to be a "custom link", I want it to be invisible, click Next and on the Actions tab, we're going to choose "Multimedia Operation (Acrobat 9 and later)".

Further down this list are similar functions for legacy media, but this is a Rich Media annotation - we can't make legacy media in Acrobat X.

Click Add, and Acrobat will show us a list of all the Rich Media annotations in the document - as you can send messages to annotations even if they're on a different page - but we want to talk to this one, the only one.

To help us out, it shows the name of the video as well as the page it's embedded on.

Next we choose the command to send, in this case I want to "seek to time", in seconds, from the start of the video.

If it's not playing, running this command will start it playing anyway, so we simply need to enter the time of our coffee, 34.5 seconds, and click OK.

If we switch back to the hand tool, move the video to somewhere where we can see the Mayor - coffee!

Mayor - coffee - marvellous.Of course you can do the same with buttons, and run any of the commands from the list available on a link can also be run on a button, the workflow is the same - and there's no coding involved.

Now, the eagle-eyed amongst you will have noticed that on our list of available commands we had something called "custom" - this comes into play if you're using an extended video player widget, or a SWF file, which exposes other functions to the host environment - which in this case is Acrobat.

How the SWF does that is also covered in the AUC Learning Center tutorials, but in essence it has some Actionscript code that registers a function with the ExternalInterface in Flash Player, as it would on a web page.For example, in this awesome flyer for The Nut Shack I've got a SWF file added as a Rich Media annotation.

The SWF exposes a function, called "showmethenut", that can be told to display some other things - within reason - so let's make a peanut button.As before, Tools Pane, Content panel, and grab the button tool.

I'm not aiming for design perfection here, so I'll just give this button a label of "Peanut", and on the Actions tab, again we're firing a Multimedia operation, but this time it's a "custom" command - the name of the function goes in the top box - showmethenut - and the parameters for that function go in the bottom box - in this case it's just the name of the nut.

We don't need quotes around it if it's a string.

Click OK, click Close.

Back to the hand tool, Peanut!Buttons have one advantage over links, as they can fire events when you mouse over them even without clicking - and I've hidden a button on the photo which does just that, with a hazelnut.

We can even set actions on a bookmark - hamster!

- just create a new bookmark, right-click, choose properties, go to the Actions tab, delete the existing navigation action and add in your multimedia operations just as you did with links and buttons.Now, so far we haven't done any scripting - we've let the Actions tab do all the work.

This has one major advantage, in that with JavaScript disabled these actions still work, and I'll prove that by disabling it now, and re-hamstering the hazelnut.

Don't get to say that very often!

However, there are a some things these inbuilt actions can't yet do.

One of them is enabling and disabling the annotation itself, and for that we need to turn JavaScript back on, and switch to a different document.I'm going to add a video onto this page, but in a really small box.

I'll grab a video and under the advanced options I'm going to make this video play back in a floating window.

If I click this little "thumbnail" the video will start playing, which is all fine, but if I click it again, I expect the video to go away again, and it doesn't.

You have to right-click and choose to close the floating window or disable the content, and the context menu is a little strange.

What we'd like is for the intuitive method to work, where we click on something and a window appears, we click on the same thing and the window disappears; and we can do that very easily with a button and a line and a half of JavaScript.So again the button tool, we're going to draw a button that covers our little video thumbnail.

Go into properties, and we want this to be completely invisible - no border, no fill, no label, so for all intents and purposes the button is invisible.

The button's action is going to be "Run a JavaScript", and click Add.Now, to control this Rich Media annotation, we first need to get hold of it as a variable; and in Acrobat we do that with the function getAnnotsRichMedia() - note the capitals, JavaScript is case-sensitive.

This function takes the page number as a parameter,as we're on the first page, which is page 0 in JavaScript-land, we could type "0", or we can type type "pageNum" with a capital N, and that will automatically substitute for the current page number.

Let's assign this function to a variable, rm.

This function returns an array of all the Rich Media annotations on the current page - there is only one, but we still need to talk to the specific annotation we're interested in, the first one - and we can get the item from an array using square brackets.

The first and only item is item 0, and we end the line with a semicolon, which in Facebook generation terms is the top half of a wink.So, this variable "rm" is pointing at the annotation - the video player - we can finally set stuff, and the stuff in our case is the "activated" property, which decides if it's playing in its window, or if it's gone to sleep.

If it's true, we set it to false, if it's false, we set it to true.

Simplest way to do that is to set it to "not" itself - so our second and final line of code is "rm.activated = !rm.activated".

Click OK, click close and switch back to the hand tool.Now if we click our button - the button is on top of the video so the button will collect the mouse click - there's our video.

Click it again and the video disappears, exactly as we want.

Simple thing to do, but it makes documents a little bit more intuitive for people who aren't used to right-clicking and looking for context menus.The scripting route to control these annotations can do all the things that the "multimedia operation" commands can do in your Actions dialog, and much more besides, though if your readers disable JavaScript obviously these kind of features won't work.

It's a compromise between power and reliability, but with a little bit of thought and not a lot of effort, you can create some really complex interactivity between video elements on the page and the page objects themselves.

In this example, we use links on each of these items which fire off the multimedia operation "seek to time" as we used before, which move the video to a particular point, and it also changes the layers in the file to move our little red pointer up and down.

This video playback uses a slightly-customized video player widget - a SWF file - which sends out commands - so if we do to a particular point near to the transition between one point and the next, when that cue point is reached in the file, the video player sends out a command to Acrobat, telling it in this case move our red pointer from one point to the next.

So you can create some quite interesting interactivity between the multimedia and page content with only the normal tools - buttons, links and a little bit of scripting.

There's a tutorial in the Learning Center at AcrobatUsers.com showing how we made this particular example, and all these functions and properties are explained in the Acrobat SDK documentation, which you can download free from the Adobe Developer Connection website.I've been Dave Merchant, thanks for listening and see you again soon.



Products covered:

Acrobat X

2 comments

Comments for this tutorial are now closed.

ivan gomez

12, 2014-06-13 13, 2014

Great tutorial!! Thank you

Patty Friesen

4, 2012-09-23 23, 2012

Hi Robert,

You may want to check out the related videos that appear in upper right side bar. You can also go to the main tutorial page <http://acrobatusers.com/tutorials> and do a search on Dave’s name for more videos that Dave has done. On the main tutorial page, you can also search by topic under “Rich media and 3D models.”

Hope this helps,

Patty

Robert May

7, 2012-09-14 14, 2012

Nice job Dave. Are there more tutorials like this one?

Comments for this tutorial are now closed.