Javascript functions to control QuickTime not working in Firefox

I am using the provided Javascript functions to control QuickTime (7.6.2); however, the functions are not working in Firefox (3.0.11), whereas they are working in Safari (4.0.1).

I create a QuickTime Player, as follows:

QT_WriteOBJECT('Music.mp3', '0', '0', '', 'AUTOPLAY', 'True', 'KIOSKMODE', 'True', 'CONTROLLER', 'False', 'LOOP', 'False', 'obj#id', 'qtp', 'emb#name', 'qtp', 'emb#id', 'qtpID', 'ENABLEJAVASCRIPT', 'True', 'SHOWLOGO', 'False', 'VOLUME', '256');

The Music.mp3 file starts playing in both Safari and Firefox; however, the Javascript functions to control that playing work only in Safari, not in Firefox.

Examples of QuickTime functions that work in Safari, but not in Firefox:

document.qtp.Stop();

document.embeds[0].GetRate();

document.embeds["qtp"].GetTime();

document.embeds["qtpID"].GetQuickTimeVersion();

The GetRate and GetTime functions always return a "0" in Firefox, the Stop command is ineffectual in Firefox, and the GetQuickTimeVersion function aborts the Javascript code in Firefox.

Any ideas what's happening?

MacBook Pro 17" Core Duo, Mac OS X (10.5.7)

Posted on Jun 22, 2009 1:05 AM

Reply
40 replies

Jul 15, 2009 8:12 AM in response to GARYsParries

Piers, I was thinking that the processMouseClickedMovie function would be the onclick event handler, not the href. Why not try something like the following?

a href="#" onclick="processMouseClickedMovie();"

Once we get the correct movie playing in FF, then we can figure out where to put your jquery call.

To respond to the qt_begin DOM event, you need to create and register an event listener, as described further down in the document you referenced.

Jul 15, 2009 10:33 AM in response to GARYsParries

Hi Gary, here's the whole unsightly mess 😀

Just the media player, function processMouseClickedMovie(), the jquery code to reveal the player, and the link (with tags removed to prevent parsing) ...

In both Safari and FF mov!.mov plays (because of the autoplay param, and jquery fadeIN, I think) and the link subsequently ignores...



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="AC_QuickTime.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<style type="text/css">
#mediaPlayer {
position:absolute;
z-index:2;
float: left;
left: 485px;
top: 235px;
border: 10;
border-style: double 10px;
border-color: #171717;
display: none
}
</style>
<script type="text/javascript">
function processMouseClickedMovie()
{
// Check if the player exists and is ready.
// Don't use parens with the first GetVolume.
// Assumes you have not previously set the volume to 0.
//
if (document.movie && document.movie.GetVolume && (document.movie.GetVolume() != 0))
{
// The player exists and is ready.
// Now check if mov1.mov is incorrectly playing.
//
if (document.movie.GetURL() == "mov1.mov")
{
// mov1.mov is incorrectly playing.
// Play the correct movie.
//
document.movie.SetURL("mov2.mov");

// Wait 1 second.
// Check again to make sure that mov1.mov is not still playing.
//
setTimeout("processMouseClickedMovie();", 1000);
}
}

else
{
// The player either does not exist yet, or exists and is not ready yet.
// Wait 1 second, and then check again.
//
setTimeout("processMouseClickedMovie();", 1000);
}
}
</script>
</head>

<body>
<!--MediaPlayer-->
<script language="JavaScript" type="text/javascript">
QT WriteOBJECTXHTML ("mov1.mov", "480", "376", "",
'controller', 'true',
'scale','aspect',
'autoplay','true',
'cache','true',
'emb#bgcolor','#000000',
'obj#bgcolor','',
'SaveEmbedTags','true',
'obj#ID','movie',
'emb#name','movie',
'postdomevents','true',
'EnableJavaScript','true');
</script>

a href="#" onclick="processMouseClickedMovie();">Play mov2 - hopefully</a
</body>

<script type="text/javascript">
$("a").click(function(event){
$('#mediaPlayer').fadeIn(1500);
});
</script>
</html>

Message was edited by: piersp

Message was edited by: piersp

Jul 15, 2009 7:46 PM in response to GARYsParries

Piers, I think we are banging our heads against the wall. Here is why.

By using jQuery to hide your movies, FF is optimizing them out so they cannot play. HOWEVER, once a movie has been faded in by the first click, FF then recognizes it and subsequently plays it correctly.

It is very similar to my experience trying to start my Jukebox in a small window where the Jukebox is, not hidden, but just scrolled off the page. It starts playing fine in Safari, but not in FF, NN, or Opera. Then, the first time the Jukebox is scrolled onto the page, it starts playing in those other browsers, and continues playing if scrolled off the page again.

I think that is exactly analogous to what is happening with your jQuery fade in. My suggestion would be to use javascript to PRE fade in all your movies once before the user ever clicks on a movie.

I really don't know what else to suggest.

Also, here is a jQuery pluggin "Embed QuickTime" that may be of use.

http://jquerystyle.com/2009/06/03/embed-quicktime

I'll be interested to hear if any of this helps.

Jul 15, 2009 11:27 PM in response to GARYsParries

Piers, you're talking like I've given up. 🙂

Two more ideas to try:

1. Go back to your original code. Then change your fadeIn calls to fadeTo, which takes a speed parameter like fadeIn AND an opacity parameter between 0.0 and 1.0. Before any clicks, fade your divs to, say, 0.5. The movies will definitely show through, but that should allow the clicks to work from the start. If so, then try changing the initial div opacity from 0.5 to 0.6, 0.7, 0.8, 0.9, 0.91, 0.92, ... , and finally 0.99. I really think that will work because that is exactly what I did with the images I am using to hide behind, but I did it without jQuery.

2. Go back to your original code. Add my processMouseClickedMovie function as a second parameter to your fadeIn calls. The second parameter is the optional callback function you want executed after the fade. The function will be running after the movie is visible, so now it should work.

I neither of those work, then I might try giving up. 🙂

Jul 16, 2009 1:34 AM in response to GARYsParries

What a great idea! - and it's almost, almost working...

FF is behaving - but there's an annoying flicker of the QT object on page load cross-browser. I have the movie object fading out with $("#movie").fadeTo(0, 0.0); heh heh - opacity to 0 in 0 milliseconds 🙂

I'm not sure what to do about that flicker - do you think I could fade the QT object or it's container div to 1% (or something) onBeforePageLoad?

Maybe I should upload to the server to see if it is eliminated by the download queue...

Thanks for not giving up 🙂

Jul 16, 2009 9:49 AM in response to GARYsParries

Without actually seeing the flicker you are talking about, I can only guess at what is causing it. My guess is this.

You are creating your QT Player in your XHTML body using QT WriteOBJECTXHTML. This happens before the page has finished loading, so for a brief time you see a 480 x 376 blank screen.

One way to minimize this is to add a parameter 'emb#bgcolor', 'black', (for example) to your QT WriteOBJECTXHTML and make your initial movie be a 1x1 pixel movie so that the rest of your 480 x 376 movie screen is filled in with the specified background color, which should ideally be the same color as your page.

You may even be able to use an mp3 file (e.g., one second of silence) instead of a 1x1 pixel mov file as your initial file to load.

You should also change your initial 'controller' parameter to 'false' and then, in your code that runs after the page is loaded, set it to 'true' using document.movie.SetControllerVisible(true).

I'm going to play with the 'hidden' parameter that Dave was talking about, because ideally, you would like to start with the QT Player hidden, and then set it to visible in your code after the page has loaded. Not sure if that can be done successfully in FF.

Jul 16, 2009 6:41 PM in response to GARYsParries

I think we're almost there...

I already had switched mov1.mov to a 2s blank qt as the original source, but after reading you're post, I simply deleted the video track in the Movie Properties window.

Plus for good measure I've added a snippet of jquery:

$('.t').click(function() {
$(this).trigger("dblclick");

});

to the class of thumbnails - which should be invisible to safari but could help FF etc.

So you're thinking of looking at the param 'hidden' and changing it after page load with setAttribute? That might be really cool because, while everything is working with local files, I do worry about what might happen - 'in the real world' with varying connection speeds etc - having the QT object exposed on the page as it is now....

Jul 17, 2009 7:32 AM in response to GARYsParries

The "hidden" parameter was a dead end. With the QT Player hidden, my Jukebox stopped working in FF, Opera, and NN, but kept right on working in Safari. If anyone else had suggested it, I would not have tried it, but with over 3000 posts on this forum, I figured Dave knows what he is talking about.

The only thing I can think of is that his G4, which uses a Motorola processor, works differently with this type optimization than Intel based Macs.

I would be very careful with that dblclick, not so much triggering it, but trying to process it with an event handler, if that is your intention.

As an alternative, the fadeTo function also takes an optional callback function as a parameter.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Javascript functions to control QuickTime not working in Firefox

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.