PDA

View Full Version : Dynamic title display.


piers
06-15-2009, 05:12 AM
I have a page that uses a javascript "function()" to embed quicktimes based on user selection (clicking on a thumbnail).

I wondering if there is some kind of event listener code that I could use to observe which movie is playing, and then display its title in a div..?

Any suggestions would be greatly appreciated! :)

Gjslick
06-17-2009, 08:00 AM
There is no way in native javascript to read the title of a quicktime video. The only way would be if apple has provided some utiliity to do that.

Perhaps when a user clicks a video, create a click handler function that sets the title from there. In other words, when they click a link for a video, have it send the video's title to say, a setPageTitle() function.


<a href="..." onclick="setPageTitle( 'This video title' );">Video Link</a>

piers
06-17-2009, 09:56 AM
Hi Gjslick - thanks for your response.

In fact, I have already incorporated click handlers to set the title... the problem is that each quicktime is linked to the next, which replaces it. The onclick event will set only the current title - so when the quicktime changes on it will still display the same..

If you have time, maybe you can look at this thread:

http://www.codingforums.com/showthread.php?p=827608#post827608

where I've been wrangling the problem... and perhaps have a new insight..?

Thanks!

Gjslick
06-17-2009, 08:56 PM
Ahh, I see, I didn't realize that the video's loaded one after the other. I checked out your other forum, seems that you figured out the issue. :thumbsup:

All the best!

piers
06-25-2009, 04:21 AM
Well I'm thinking there is a way to read the title of a quicktime movie in javascript after all....

I found this on the Apple dev website at http://developer.apple.com/documentation/QuickTime/Conceptual/QTScripting_JavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html#//apple_ref/doc/uid/TP40001526-CH001-SW4

The browser plug-ins for QuickTime 7.2.1 and later include the ability to emit Document Object Model (DOM) events. DOM events can be emitted when the plug-in is instantiated and ready to interact with JavaScript, at various points during a movie’s loading process, when playback has begun, paused, or ended, or in the event of an error. JavaScript functions can be set to "listen" for particular DOM events. Whenever the DOM event occurs, the listener function is called.

This allows you to create web pages that detect events such as movie loading, playing, pausing, or ending, without having to create JavaScript timing loops or constantly poll the plug-in for status. It also allows you to execute JavaScript functions in response to various movie events without sending javascript:// URLs from a movie.

Two of the DOM events emitted by the QT plugin are:

qt_loadedmetadata — The movie header information has been loaded or created. The duration, dimensions, looping state, and so on are now known.

qt_load — All media data has been loaded.


Therefore by registering an event listener:


<script language="javascript" type="text/javascript">
function myAddListener(obj, evt, handler, captures)
{
if ( document.addEventListener )
obj.addEventListener(evt, handler, captures);
else
// IE
obj.attachEvent('on' + evt, handler);
}
</script>


and writing a function that uses the

string GetUserData('Šnam')

method, (Which returns the movie's name from the user data), it should be possible to write a piece of code that listens for the new movie loading and then returns that movies name, right?

'Cept, of course, that I'm clueless about how to do that :)