1 if(!dojo._hasResource["dojox.av._base.quicktime"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.av._base.quicktime"] = true;
3 dojo.provide("dojox.av._base.quicktime");
6 /*******************************************************
9 Base functionality to insert a QuickTime movie
10 into a document on the fly.
11 ******************************************************/
13 var qtMarkup, qtVersion, installed, __def__={
19 var keyBase="dojox-av-quicktime-", keyCount=0;
21 // reference to the test movie we will use for getting QT info from the browser.
22 var testMovieUrl=dojo.moduleUrl("dojox", "av/resources/version.mov");
24 // *** private methods *********************************************************
25 function prep(kwArgs){
26 kwArgs = dojo.mixin(dojo.clone(__def__), kwArgs || {});
27 if(!("path" in kwArgs)){
28 console.error("dojox.av._base.quicktime(ctor):: no path reference to a QuickTime movie was provided.");
31 if(!("id" in kwArgs)){
32 kwArgs.id=(keyBase + keyCount++);
37 var getQTMarkup = 'This content requires the <a href="http://www.apple.com/quicktime/download/" title="Download and install QuickTime.">QuickTime plugin</a>.';
39 installed = (function(){
41 var o = new ActiveXObject("QuickTimeCheckObject.QuickTimeCheck.1");
43 return o.IsQuickTimeAvailable(0);
49 qtMarkup = function(kwArgs){
50 if(!installed){ return { id: null, markup: getQTMarkup }; }
52 kwArgs = prep(kwArgs);
53 if(!kwArgs){ return null; }
54 var s = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" '
55 + 'codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" '
56 + 'id="' + kwArgs.id + '" '
57 + 'width="' + kwArgs.width + '" '
58 + 'height="' + kwArgs.height + '">'
59 + '<param name="src" value="' + kwArgs.path + '" />';
60 for(var i=0, l=kwArgs.params.length; i<l; i++){
61 s += '<param name="' + kwArgs.params[i].key + '" value="' + kwArgs.params[i].value + '" />';
64 return { id: kwArgs.id, markup: s };
67 installed = (function(){
68 for(var i=0, l=navigator.plugins.length; i<l; i++){
69 if(navigator.plugins[i].name.indexOf("QuickTime")>-1){
76 qtMarkup = function(kwArgs){
77 if(!installed){ return { id: null, markup: getQTMarkup }; }
79 kwArgs = prep(kwArgs);
80 if(!kwArgs){ return null; }
81 var s = '<embed type="video/quicktime" src="' + kwArgs.path + '" '
82 + 'id="' + kwArgs.id + '" '
83 + 'name="' + kwArgs.id + '" '
84 + 'pluginspage="www.apple.com/quicktime/download" '
85 + 'enablejavascript="true" '
86 + 'width="' + kwArgs.width + '" '
87 + 'height="' + kwArgs.height + '"';
88 for(var i=0, l=kwArgs.params.length; i<l; i++){
89 s += ' ' + kwArgs.params[i].key + '="' + kwArgs.params[i].value + '"';
92 return { id: kwArgs.id, markup: s };
96 qtVersion = { major: 0, minor: 0, rev: 0 };
98 // *** This is an offical kludge, but it seems to work everywhere. Sigh. *************************
99 dojo.addOnLoad(function(){
100 var n = document.createElement("div");
101 n.style.cssText = "top:0;left:0;width:1px;height:1px;overflow:hidden;position:absolute;";
102 var o = qtMarkup({ path: testMovieUrl, width:4, height:4 });
104 document.body.appendChild(n);
105 n.innerHTML = o.markup;
106 var qt = (dojo.isIE) ? dojo.byId(o.id) : document[o.id];
108 // Let Safari and IE have a moment to init the QT object before trying to query it.
109 setTimeout(function(){
113 v = qt.GetQuickTimeVersion().split(".");
114 qtVersion = { major: parseInt(v[0]||0), minor: parseInt(v[1]||0), rev: parseInt(v[2]||0) };
116 qtVersion = { major: 0, minor: 0, rev: 0 };
120 dojox.av.quicktime.supported = v[0];
121 dojox.av.quicktime.version = qtVersion;
122 if(dojox.av.quicktime.supported){
123 dojox.av.quicktime.onInitialize();
126 // fricking IE. gonna end up leaving the movie in the doc, for some
127 // reason getting an unspecified error when trying to remove it.
129 document.body.removeChild(n);
131 // move it out of the way.
132 n.style.top = "-10000px";
133 n.style.visibility="hidden";
138 // *** The public interface. ****************************************************************
141 available: installed,
142 supported: installed,
145 onInitialize: function(){ dojox.av.quicktime.initialized = true; }, // stub function to let you know when this is ready
147 place: function(/* DOMElement */node, /* Object */kwArgs){
148 node = dojo.byId(node);
149 var o = qtMarkup(kwArgs);
151 node.innerHTML = o.markup;
153 return (dojo.isIE)? dojo.byId(o.id) : document[o.id]; // QuickTimeObject
156 return null; // QuickTimeObject