So I decided to insert a flash on the site and there is such a problem. Flash video plays when the page loads. Is there any javascript command that plays a movie at this event? The flash object is in the tags "object" and has its own ID.

  • I think there will be more willing to answer if you give a sample code, or even better, a link to this miracle. - DL_
  • Google about the insertion parameters of the object, there must be something related to autorun! - metazet

2 answers 2

If you mean a player from youtube, it has an appropriate API:

function play() { if (ytplayer) { ytplayer.playVideo(); } } 

If you have access to the sources of the flash-player, any function can be made available via swfObject:

Actionscript:

 import flash.external.ExternalInterface; ExternalInterface.addCallback( "methodName", this, method ); function method() { trace("called from javascript"); } 

Javascript:

 function callAS() { swf.methodName(); } 

In all other cases, see the documentation for the appropriate player.

And best of all - use not Flash, but HTML5 Video , for example Video.js

    According to the documentation from Adobe , to disable autoplay when loading there are a number of parameters, specifically for the object tag it

     <param name="play" value="false"> 

    But in reality, this may not work depending on the specific content of the video that Flash should play and which is controlled by ActionScript.

    To run a movie from JavaScript, you need to set the function that starts playback from the ActionScript. You can use the SWFObject for this purpose.