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 12, 2009 12:54 PM in response to GARYsParries

Piersp, I wasn't aware you were hiding anything, but now it all makes sense. I don't know why David hasn't experienced this problem in all major browsers other than Safari, but that is exactly what I am experiencing.

In my hundreds of hours of struggling with this issue, I was able to find ONE WAY of actually hiding images so that it works in all browsers, and FWIW, I will share it with you, and maybe you can apply it to your situation.

Make a 'shield' image, either the same color as your background if you don't want anything to show in that area, or any other color or image that you do want to show in that area. Put the image you want to hide behind the 'shield' image, and then set the transparency of the 'shield' image to 100%.

If this does not cause a problem in FF, etc., then try setting the transparency of the 'shield' image to 50%, then 25%, etc. I was able to get it to work with a 'shield' transparency of 1% (i.e., 99% opaque), which is far more opaque than you need to keep the hidden image from showing through.

Hope that helps.

Jul 12, 2009 7:08 PM in response to GARYsParries

Hi guys..

I think you're both proposing basically the same solution, right? Basically hide the QT object behind a div and fade the div out when required? I've never had much luck hiding a QT as it always seems to show through (only the controller is hidden)

Also my background is a repeating pattern that might be hard to match up in a div.

@David - I checked out your demo but couldn't seem to get the movie to play...

@Gary - how about an onclick event that triggers a short timeOut before re-triggering SetURL...?

Jul 12, 2009 10:45 PM in response to GARYsParries

I wonder if David is not experiencing the 'hidden' problem with FF because he is using a G4 and/or Tiger?

Regarding the onClick event handler, I would call GetURL() before retriggering SetURL(), and I would not call GetURL() until you know that the player is ready, because a GetURL() call can cause problems if the player is not ready. Something like the following will work using a GetVolume() call, which is a nondestructive call and will just return 0 if the player exists but is not ready. This assumes that you have not previously set the volume to 0.

function processMouseClickedMovie(theMouseClickedMovie)
{
// 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 ((theMouseClickedMovie != "mov1.mov") && (document.movie.GetURL() == "mov1.mov"))
{
// mov1.mov is incorrectly playing.
// Play the correct movie.
//
document.movie.SetURL(theMouseClickedMovie);

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

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

Hope there are not too many typos in the above handler. 🙂

Jul 13, 2009 6:25 PM in response to GARYsParries

Hmmm... I don't seem to be able to get this to work - it still plays the original mov1.mov, but then renders the thumbnail unclickable...

I wonder if it could be worth simplifying everything somehow with any code that would turn a single click into a 'double-click'...? If I could adjust the timeout to the 'second click' as it were, I might be able to noodle it to work...?

Jul 13, 2009 10:24 PM in response to GARYsParries

Right...

basically what I did, to test the function, was replace (theMouseClickedMovie) with (mov2.mov) throughout the above code... and then called function processMouseClickedMovie(mov2.mov) as an onclick event at one of my links.

On click, mov1.mov still started playing - and subsequent clicks on the link were ignored...

it seemed that the first time I ran it mov1.mov did stop, but then start again - however, I couldn't reproduce that subsequently... so it might just have been my computer hiccupping.

Jul 14, 2009 9:11 AM in response to GARYsParries

I wouldn't exactly call them skills, as much as trial and error. 🙂

From your description of the function simplification, I think you may have introduced an error that is preventing the function from working. The simplified function with mov2.mov hardcoded in should look more like this.

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);
}
}

Again, I apologize for any inadvertent syntax errors.

Jul 14, 2009 7:08 PM in response to GARYsParries

Well I definitely appreciate your patience :]

I guess I haven't had that Eureka moment with js - most of my experience is with jquery (which is perhaps more intuitive - perhaps).

But okay -

I pasted the above code into the head of my document (didn't see any typos or nesting problems) and then at the mov2.mov thumbnail I have:

a href="javascript:processMouseClickedMovie();" onclick="$('#mediaPlayer').fadeIn(1500);"


but still mov1.mov plays first in FF and subsequent clicks on the link are ignored.

Interestingly... now, in Safari, the same thing happens - mov1.mov plays first then clicks ignored.

I'm wondering if it might not be possible to use:

qt_begin — The plug in has been instantiated and can interact with JavaScript.

as per http://www.devworld.apple.com/documentation/QuickTime/Conceptual/QTScriptingJavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html#//appleref/doc/uid/TP40001526-CH001-SW5

But maybe you see some glaring error in my application of your function 🙂

Jul 15, 2009 3:09 AM in response to GARYsParries

I've been playing with a test function:

function foo()
{
document.movie.Play();
setTimeout(document.movie.SetURL('mov2.mov'), 1500);
}

(calling a href="javascript:foo();")

and amazingly it seems to make no difference to either Safari or Firefox - Safari plays mov2.mov no problem right away, while FF still plays mov1.mov until a second click event at which time it dutifully plays mov2.mov.

Unless I'm more boneheaded than I thought....

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.