/    Sign up×
Community /Pin to ProfileBookmark

Starting Quicktime Movie Muted

My Goal: Start a quicktime movie embedded on a page, but with the sound muted.

The Problem: Can mute sound under user action, but not automatically. Whenever I try to use the SetMute(), I get unidentified errors (which I take to mean that the object is not in a full state of existence, or somesuch).

Enclosed is the HTML/JavaScript, which is mostly copied directly from Apple’s examples. But their examples perform all the actions on the movies only under user’s initiation, which necessarily happens after the page is all loaded.

My particular addition is the MuteMe script at the end, which attempts to mute one of the movies. This creates an “Unidentified Error” in IE, whereas in Firefox the message is “…SetMute is not a function”. Note that the call is the same as that used in the links, and the links work fine.

What’s going wrong here? It seems to me that the object isn’t fully constructed yet, or something like that, but I can’t find a way around it. I’ve tried onloads on just about everything, to no avail. I’ve tried detecting the object’s existence (if (document.movie1) etc), but even when it seems to exist, the call fails. How can I get this thing to mute before it starts?

My code:

8<8<8<8<8<8<8<8<8<8<8<8<8<8<8<8<8<

<html>
<head>
<title>Simple QuickTime Movie Controls</title>
</head>

<script language =”JavaScript”>
<!–

/* define function that calls QuickTime’s “Play” method */
function PlayIt(anObj)
{
anObj.Play();
}

/* define function that calls QuickTime’s “Stop” method */
function StopIt(anObj)
{
anObj.Stop();
}

/* function to mute movie */
function MuteMe(anObj)
{
anObj.SetMute(true);
}

//–>
</script>

<body>

<P>
This page uses JavaScript to control a QuickTime movie…
</P>

<div align=center>
<table>
<tr>
<td width=200>
<OBJECT classid=”clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B”
codebase=”http://www.apple.com/qtactivex/qtplugin.cab
width=”180″ height=”160″
id=”movie1″>
<PARAM name=”src” value=”PICT0025.MOV”>
<EMBED width=”180″ height=”160″
src=”PICT0025.MOV”
TYPE=”video/quicktime”
PLUGINSPAGE=”www.apple.com/quicktime/download”
name=”movie1″
enablejavascript=”true”>
</EMBED>
</OBJECT>

<P> Movie1 </P>

</td>
<td width=200>

<OBJECT classid=”clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B”
codebase=”http://www.apple.com/qtactivex/qtplugin.cab
width=”180″ height=”160″
id=”movie2″ >
<PARAM name=”src” value=”PICT0027.MOV”>

<EMBED width=”180″ height=”160″
src=”PICT0027.MOV”
TYPE=”video/quicktime”
PLUGINSPAGE=”www.apple.com/quicktime/download”
name=”movie2″
enablejavascript=”true”>
</EMBED>
</OBJECT>

<P> Movie2 </P>
</td>
</tr>
</table>
</div>

<P>Pass movie name to JavaScript functions as a parameter: <br>
<a href=”javascript?layIt(document.movie1);”>PlayIt(movie1)</a><br>
<a href=”javascript:StopIt(document.movie1);”>StopIt(movie1)</a><br>
<a href=”javascript:MuteMe(document.movie1);”>MuteMe(movie1)</a><br>
<a href=”javascript?layIt(document.movie2);”>PlayIt(movie2)</a><br>
<a href=”javascript:StopIt(document.movie2);”>StopIt(movie2)</a><br>
<a href=”javascript:MuteMe(document.movie2);”>MuteMe(movie2)</a><br>
</P>

<P>Control movie by name directly: <br>
<a href=”javascript:document.movie1.Play();”>movie1.Play()</a><br>
<a href=”javascript:document.movie1.Stop();”>movie1.Stop()</a><br>
<a href=”javascript:document.movie1.SetMute(true);”>movie1.Mute(true)</a><br>
<a href=”javascript:document.movie2.Play();”>movie2.Play()</a><br>
<a href=”javascript:document.movie2.Stop();”>movie2.Stop()</a><br>
<a href=”javascript:document.movie2.SetMute(true);”>movie2.Mute(true)</a><br>
</P>

<P>Control movie by index in the embeds[ ] array:<br>
(Does not work for IE 6 and later if you use the Object tag)
<a href=”javascript:document.embeds[0].Play();”>embeds[0].Play()</a><br>
<a href=”javascript:document.embeds[0].Stop();”>embeds[0].Stop()</a><br>
<a href=”javascript:document.embeds[1].Play();”>embeds[1].Play()</a><br>
<a href=”javascript:document.embeds[1].Stop();”>embeds[1].Stop()</a><br>
</P>

<script language =”JavaScript”>
document.movie1.SetMute(true);
</script>

</body>
</html>

8<8<8<8<8<8<8<8<8<8<8<8<8<8<8<8<8<

Any help or hints would be appreciated…

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@lownoiseauthorMay 05.2005 — Sample page is posted here (high-bandwidth connection required due to large size of the movies):

http://www.bangstart.com/test/movies/testmovies2.php
×

Success!

Help @lownoise spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...