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

Turning off media using "app.media.openPlayer( args1 )"

corageous
Registered: Oct 4 2008
Posts: 5
Answered

I am using "app.media.openPlayer( args1 )" to play the media using Javascript. How do I stop or close this embedded media using Javascript?

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The "openPlayer()" function returns a media player object. This is what you use to control the player.

For example:

var oPlayer = app.media.openPlayer(...);

// Stop
oPlayer.stop();

//Pause
oPlayer.pause();

//Play
oPlayer.play();

//Close

oPlayer.close();


If you are opening the player from a button script then you'll want to assign the player object to a document level variable.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

corageous
Registered: Oct 4 2008
Posts: 5
I have tried using "app.media.openPlayer" as an object by setting it to a variable. Next I used the "stop" function of that object. It still does not stop my media player. Maybe my settings are configured wrongly. Here is my coding below.


function CloseAxelay()
{
// Get the screen annotation with a title of myScreen
var annot1= this.media.getAnnot({ nPage: 0,cAnnotTitle: "Axelay" });
// Get the rendition present in this document with a rendition name of// myClip
var rendition1 = this.media.getRendition("Axelay");
// Get the set of default settings for this rendition.
var settings1 = app.media.getRenditionSettings({ rendition: rendition1 });
// Play the clip in a docked window.
settings1.windowType=app.media.windowType.docked;
// Set the arguments to be passed to openPlayer, the rendition, the
//annotation and the settings.
var args1 = { rendition: rendition1, annot: annot1, settings: settings1 };
// Open the the media player and play.
var Oplayer = app.media.openPlayer(args1);
Oplayer.stop();

}
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Were any errors reported in the console window?

Immediately opening and then stopping the player may be running up against timing issues. It would be better to open the player with "autoPlay" set to false.

Add this to your code:

settings1.autoPlay = false;

I also think this can be set in the Media Properties dialog, although I'm not sure.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script