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

Jun 22, 2009 10:24 AM in response to GARYsParries

I found the problem. It was the dimensions of the QuickTime Player. Since I did not want it to show, I had set the dimensions to 0, 0. When I set the dimensions to nonzero, everything worked.

Apparently, Firefox is doing some kind of optimization, and doesn't like when things are not visible.

Similarly, I was using a button as a spacer, and never assigned it a source image. The spacer worked fine it Safari, but did not take up any space in Firefox, until I assigned a source image to it.

Live and learn.

Jun 30, 2009 9:32 AM in response to GARYsParries

Dave, you would think the HIDDEN parameter would be the answer. Unfortunately, that does not work in Firefox, Opera, and Navigator (all tested on a Mac).

For the optimization reasons mentioned in my previous comment above, any Javascript commands used to control a QuickTime Player will not work if the player is hidden in any way, i.e., by making its dimensions zero, by moving it offpage, by hiding it behind another visible object, by scrolling it offscreen, or by using the HIDDEN parameter, though all these methods work just fine in Safari.

I can accept these restrictions, except for the 'scrolling offscreen' one. If you go to a website in a scrollable window that is, say, half the height of the screen, and a QuickTime Player happens to be scrolled below the visible area of the window, that should NOT prevent the javascript controls from working ... IMHO.

Jun 30, 2009 2:08 PM in response to GARYsParries

Interesting ... Are you using the QT_WriteOBJECT function from Apple's AC_QuickTime.js to create your QuickTime Player, and then issuing your QuickTime commands as, for example, document.qtp.Play(), document.qtp.Stop(), document.qtp.Rewind(), etc. (where qtp is the obj#id and emb#name specified in my QT_WriteOBJECT function)?

If so, then my guess is it must be the fact that I am embedding my javascript in an iWeb HTML snippet as an iframe that is causing this strange behavior, and not QuickTime itself?

Jun 30, 2009 6:42 PM in response to GARYsParries

<!-- Start of movie embed -->
<script language="JavaScript" type="text/javascript"><!--
QT WriteOBJECTXHTML('poster.mov', '864', '560','','controller','false','autoplay','true','loop','true','showlogo','true' ,'name','Name of_video_here','scale','aspect','cache','true','href','<mymovie here.mov> E<autoplay=true controller=false loop=false>','target','myself','targetcache','true','enablejavascript','true');
// --></script>
<!-- End of movie embed -->

Here's the javascript:

(in the embed tag)'name','Name of_videohere'


(in the body of the html)
<aa href="javascript:document.Name of_videohere.Play();">Play</aa>
<aa href="javascript:document.Name of_videohere.Stop();">Pause</aa>
<aa href="javascript:document.Name of_videohere.Rewind();">Rewind</aa>

You have to give your video a name so the javascript knows which video to control. Even if you have only one video.

I'm using a poster frame in the above video tag.

Message was edited by: David M Brewer

Jul 1, 2009 3:06 PM in response to GARYsParries

Dave, what you have done is very similar to what I have done, with the following exceptions:

1. I'm using the regular HTML version of QT_WriteOBJECT rather than the XHTML version.

2. My first parameter is an .mp3 file rather than a .mov poster in combination with an 'href'.

3. I'm not using some of your parameters, such as, 'target', 'targetcache', 'scale', 'href', and 'name'.

4. Instead of 'name', I'm using --- 'obj#id', 'qtp', 'emb#name', 'qtp' --- which allows me to then reference the QuickTime functions as --- document.qtp.Play(); document.qtp.Stop(); --- etc.

5. I'm not creating HTML buttons as player controls; rather I am using my javascript program to detect and control the player operation with functions such as --- document.qtp.GetRate(); document.qtp.GetTime(); document.qtp.GetDuration(); document.qtp.SetVolume(); document.qtp.SetMute(); document.qtp.Play(); document.qtp.Rewind(); document.qtp.Stop() --- etc.

6. I change my .mp3 files using --- document.qtp.SetURL();

7. All my javascript is contained in an iWeb HTML snippet using an iframe.

Essentially, I've created a jukebox with button images of album covers that can be visually scrolled and then clicked to play an album via the HTML onClick, onMouseOver, and onMouseOut functions.

This all works without a hitch in Safari; however, in FF, NN, and Opera, it only works if the iframe is completely visible on the screen. It can't be scrolled offpage, and the HTML album cover buttons in the iframe cannot be dimensionless, hidden, or blocked from view.

I really think it's the iframe that is causing this behavior in all the browsers (except Safari).

BTW, as an aside, I don't have a Windows machine, but no one I know using IE on a PC has been able to get my QuickTime Player working. I think it's because, when I want to collapse an album cover, I set its width to '1px' ('0px' works only in Safari), but I think IE may require a minimum width of '2px'. I have not tried changing my image widths to '2px' yet.

Jul 11, 2009 2:52 AM in response to David M Brewer

Thought I would jump in here...

I have a page that loads various QTs from thumbnails, and referencing AC_Quicktime.js I'm creating the object:

QT WriteOBJECTXHTML ("mov1.mov", "480", "376", "",
'autoplay', 'true',
'scale', 'tofit',
'controller', 'true',
'enableJavaScript', 'true',
'SaveEmbedTags', 'true',
'obj#ID', 'movie',
'emb#name', 'movie',
'align', 'top');

Then in order to stop the first QT ('mov1.mov') from autoplaying on pageload/document ready I'm calling document.movie.Stop();

Subsequently the onclick handlers are:

a href="javascript:document.movie.SetURL('mov2.mov');"

Works great in Safari, but in FF the first time any thumbnail is clicked mov1.mov plays and the setURL function only works to display the correct QT on a subsequent click....

any ideas why?

Jul 11, 2009 6:19 PM in response to GARYsParries

I have one idea. I have noticed that after you use QT_WriteOBJECT to create a QuickTime Player, you must allow a bit of time before you issue any javascript QuickTime commands, such as document.movie.Stop(). If you issue a command too soon, the results can be unpredictable.

To resolve this, you could try setTimeout("document.movie.Stop();", 1000). If it works, you will probably hear the first movie start playing before it stops, but at least you will know that was the problem, and you can try reducing the wait time to something less than 1000 milliseconds.

You can also try setting the 'autoplay' parameter initially to 'false' when you create your QuickTime Player, and then use document.movie.SetAutoPlay(true) after the player is created to set 'autoplay' to 'true'. You may also have to then use document.movie.SetResetPropertiesOnReload(false) to keep 'autoplay' from resetting back to 'false' when you reload a movie using SetURL.

I'll be interested to hear if that helps.

Jul 12, 2009 7:06 AM in response to piersp

This is really driving me nuts 😝

I think the problem is that the div holding the QT_WRITEOBJECT is initially hidden with a call to jQuery $("#mediaPlayer").css('display', 'none'); Perhaps in Firefox the QT object is not being instantiated before the click event that should change the movie with SetURL.

If only there was a way to instantiate the QT object as a placeholder or without a src attribute.... :]

Jul 12, 2009 7:38 AM in response to piersp

I don't understand the difficulty here. Unless your trying to reinvent the wheel or something.

The above coding that I used work's perfectly in Safari and FF and IE. Whether it be using a poster frame ... XHTML, or not (which is about the same coding as a regular html). I didn't have to do any hacking or anything. And if you want to hide the .mov, use the hidden pram. No problem here.

Jul 12, 2009 8:22 AM in response to David M Brewer

I kid you not, David...

If the QT object is hidden, then when it is called by a click event such as a href="javascript:document.movie.SetURL('mov2.mov');" it will always play the original src (mov1.mov) on the first click in FF and Opera - Safari, of course, is no problem.

Even once the QT Object is instantiated, if it is subsequently hidden again, on recall the first click is back to mov1.mov.

The HIDDEN param wouldn't really help as no amount of CSS will show it again (it's really only if you want audio only), right?

I have another page in the site that doesn't have the QT Object hidden and there are no problems there...

I guess what it would need is some kind of method to clear the original movie...

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.