These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Playing a media clip [video] from a file

kmoniz
Registered: Jul 7 2008
Posts: 6

Hi there,

I was trying to figure out how to play a video from file. I found an example in "Developing Acrobat Applications Using JavaScript" on page 133... so I decided to take a shot on creating a javascript file and saving it in my usr folder [C:\Users\kmoniz\AppData\Roaming\Adobe\Acrobat\8.0\JavaScripts].

For some reason, nothing happens when I click on my menu item.

Here is my javascript code:

var myVideo = "/C/Users/kmoniz/AppData/Roaming/Adobe/Acrobat/8.0/JavaScripts/surgery.mpg";

var args = {
URL: myVideo,
mimeType: "video/x-mpg",
doc: this,
settings:
{
players: app.media.getPlayers("video/x-mpg"),
windowType: app.media.windowType.floating,
data: app.media.getURLData( myVideo,"video/x-mpg" ),
floating: { height: 400, width: 600 }
}
}

var settings = app.media.getURLSettings(args);
args.settings = settings;

// Create a trusted function to execute a video
trustedPlayVideo = app.trustedFunction( function (args)
{
app.beginPriv();

app.media.openPlayer(args);

app.endPriv();
})

app.addMenuItem({
cName: "Play Video",
cUser: "JS: Play Video",
cParent: "Advanced",
cExec: "trustedPlayVideo", nPos: 0
});

I believe that there may be something wrong with my file path.

If anyone can help me out with this I would greatly appreciate it. I am new to Acrobats javascript development side.

My Product Information:
Acrobat 3D 8.0, Windows
kmoniz
Registered: Jul 7 2008
Posts: 6
Hi,

Ok, it looks like I forgot to place parantheses within my addMenuItem cExec call. Modified-> cExec: "trustedPlayVideo", nPos: 0So, now when I click on the menu item in Acrobat, i get the following error on the javascript debugger:

args.doc.media has no properties
invalid 'in' operand a.doc.media
invalid 'in' operand a.doc.media
invalid 'in' operand a.doc.media

Does anyone know what I could do to solve this issue?

Thanks in advance.
kmoniz
Registered: Jul 7 2008
Posts: 6
Hi,

sorry for all the posts -> but, I just solved the "args.doc.media" error.I modified the parameters within my trusted function as follows:

var args = {
URL: myVideo,
mimeType: "video/x-mpg",
doc: this,
settings:
{
players: app.media.getPlayers("video/x-mpg"),
windowType: app.media.windowType.floating,
data: app.media.getURLData(myVideo,"video/x-mpg"),
autoPlay: false,
repeat: 1,
showUI: true,
floating: {
height: 400,
width: 400,
}
}
};

var settings = app.media.getURLSettings(args);
args.settings = settings;

// Create a trusted function to execute a video
trustedPlayVideo = app.trustedFunction( function ( properties )
{
app.beginPriv();

app.newDoc();

app.media.openPlayer( properties );

app.endPriv();
})

app.addMenuItem({
cName: "Play Video",
cUser: "JS: Play Video",
cParent: "Advanced",
cExec: "trustedPlayVideo( settings );",
nPos: 1
});

------------------------

Now, I have an error saying:

a.doc has no properties
a.doc has no properties
a.doc has no properties

Can anyone help me with this issue? Thanks :)