Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling a .mov (<object>) file with javascript?
    text
    copied!<p>So my question is <strong>how do I start a movie with a call to a javascript / jquery function?</strong></p> <p>Background:</p> <p>I have an object in my html that embeds is a .mov file like so:</p> <pre><code>&lt;object CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="100%" height="100%" class="movie1" id="movie1ie"&gt; &lt;param name="src" value="movies/test.mov"&gt; &lt;param name="autoplay" value="false"&gt; &lt;param name="loop" value="false"&gt; &lt;param name="controller" value="false"&gt; &lt;!--[if !IE]&gt;--&gt; &lt;object type="video/quicktime" data="movies/test.mov" width="100%" height="100%" class="movie1" id="movie1"&gt; &lt;param name="autoplay" value="false"&gt; &lt;param name="loop" value="false"&gt; &lt;param name="controller" value="false"&gt; &lt;/object&gt; &lt;!--&lt;![endif]--&gt; &lt;/object&gt; </code></pre> <p>And it seems to be okay, until I want to play the movie with a call to javascript. I am using jQuery so I tried this from within a function:</p> <pre><code>function startMovie(whom){ var playIt = 'movie'+ whom; $('#' + playIt).get(0).play(); } //and call the function startMovie(1); </code></pre> <p>But then I get this error:</p> <pre><code>Uncaught TypeError: Object #&lt;HTMLObjectElement&gt; has no method 'play' </code></pre> <p>Weird, but I'm no jQuery ninja so I tried to call it using good ole javascript:</p> <pre><code>function startMovie(1){ var playIt = 'movie'+ whom; document.getElementById(playIt).Play(); } </code></pre> <p>But now I get the following error in my console:</p> <pre><code>Uncaught Error: Error calling method on NPObject. </code></pre> <p>Which is very wierd, since if I put the following into my console the movie will start playing without errors:</p> <pre><code>document.getElementById('movie1').Play() </code></pre> <p>FWIW I am using Chrome on a Mac and the files are running on the local machine (no server).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload