Stopping QuickTime When Thickbox Closes

Posted on December 03, 2006

So I'm working on [melodysphotography.com][1] and I want to load QuickTime content in a [thickbox][2]. It works , with the addition of my css hack, fairly well except that the audio track continues to play when the thickbox closes in Safari. Now that's ugly. I googled around and found out that Apple makes a JavaScript API available from Safari. With a little work, I came up with the following script which overrides the thickbox remove function and stops the QuickTime player before calling the original remove function.

TB_originalRemove = TB_remove;

TB_remove = function() {
  try {
    document.movie1.Stop();
  } catch(err) {}
  try {
    document.movie2.Stop();
  } catch(err) {}
  TB_originalRemove();
};

Wondering about the movie1, movie2 stuff? It's an ugly cross-browser thing required to support Firefox, Safari, and IE on Windoze and OS X. I'll post another entry with the details and relevant links.