Bug 20489 Configure illegal file characters https://bugzilla.wikimedia.org/show_bug...
[mediawiki.git] / js2 / mwEmbed / libEmbedVideo / flashEmbed.js
blobef83a2df6ce8d43369e29313e8be2d06cc348e8c
1 /**
2  * metavid: mv_flashEmbed builds off of flowplayer api (included first in this file) 
3  */
4  
5  /**
6  * flowplayer.js 3.0.0-rc5. The Flowplayer API.
7  * 
8  * This file is part of Flowplayer, http://flowplayer.org
9  *
10  * Author: Tero Piirainen, <support@flowplayer.org>
11  * Copyright (c) 2008 Flowplayer Ltd
12  *
13  * Released under the MIT License:
14  * http://www.opensource.org/licenses/mit-license.php
15  * 
16  * Version: 3.0.0-rc5 - Thu Nov 20 2008 22:09:49 GMT-0000 (GMT+00:00)
17  */
18 (function() {
20 /* 
21         FEATURES 
22         --------
23         - handling multiple instances 
24         - Flowplayer programming API 
25         - Flowplayer event model        
26         - player loading / unloading
27         - $f() function
28         - jQuery support
29 */ 
32 /*jslint glovar: true, browser: true */
33 /*global flowplayer, $f */
35 // {{{ private utility methods
36         
37         function log(args) {
38                 
39                 // write into opera console
40                 if (typeof opera == 'object') {
41                         opera.postError("$f.fireEvent: " + args.join(" | "));   
43                         
44                 } else if (typeof console == 'object') {
45                         console.log("$f.fireEvent", [].slice.call(args));       
46                 }
47         }
49                 
50         // thanks: http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone
51         function clone(obj) {   
52                 if (!obj || typeof obj != 'object') { return obj; }             
53                 var temp = new obj.constructor();       
54                 for (var key in obj) {  
55                         if (obj.hasOwnProperty(key)) {
56                                 temp[key] = clone(obj[key]);
57                         }
58                 }               
59                 return temp;
60         }
62         // stripped from jQuery, thanks John Resig 
63         function each(obj, fn) {
64                 if (!obj) { return; }
65                 
66                 var name, i = 0, length = obj.length;
67         
68                 // object
69                 if (length === undefined) {
70                         for (name in obj) {
71                                 if (fn.call(obj[name], name, obj[name]) === false) { break; }
72                         }
73                         
74                 // array
75                 } else {
76                         for (var value = obj[0];
77                                 i < length && fn.call( value, i, value ) !== false; value = obj[++i]) {                         
78                         }
79                 }
80         
81                 return obj;
82         }
84         
85         // convenience
86         function el(id) {
87                 return document.getElementById(id);      
88         }       
90         
91         // used extensively. a very simple implementation. 
92         function extend(to, from, skipFuncs) {
93                 if (to && from) {                       
94                         each(from, function(name, value) {
95                                 if (!skipFuncs || typeof value != 'function') {
96                                         to[name] = value;               
97                                 }
98                         });
99                 }
100         }
101         
102         // var arr = select("elem.className"); 
103         function select(query) {
104                 var index = query.indexOf("."); 
105                 if (index != -1) {
106                         var tag = query.substring(0, index) || "*";
107                         var klass = query.substring(index + 1, query.length);
108                         var els = [];
109                         each(document.getElementsByTagName(tag), function() {
110                                 if (this.className && this.className.indexOf(klass) != -1) {
111                                         els.push(this);         
112                                 }
113                         });
114                         return els;
115                 }
116         }
117         
118         // fix event inconsistencies across browsers
119         function stopEvent(e) {
120                 e = e || window.event;
121                 
122                 if (e.preventDefault) {
123                         e.stopPropagation();
124                         e.preventDefault();
125                         
126                 } else {
127                         e.returnValue = false;  
128                         e.cancelBubble = true;
129                 } 
130                 return false;
131         }
133         // push an event listener into existing array of listeners
134         function bind(to, evt, fn) {
135                 to[evt] = to[evt] || [];
136                 to[evt].push(fn);               
137         }
138         
139         
140         // generates an unique id
141    function makeId() {
142           return "_" + ("" + Math.random()).substring(2, 10);   
143    }
144         
145 //}}}   
146         
148 // {{{ Clip
150         var Clip = function(json, index, player) {
151                 
152                 // private variables
153                 var self = this;
154                 var cuepoints = {};
155                 var listeners = {}; 
156                 this.index = index;
157                 
158                 // instance variables
159                 if (typeof json == 'string') {
160                         json = {url:json};      
161                 }
162         
163                 extend(this, json, true);       
164                 
165                 // event handling 
166                 each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),
167                         function() {
168                         
169                         var evt = "on" + this;
170                                 
171                         // before event
172                         if (evt.indexOf("*") != -1) {
173                                 evt = evt.substring(0, evt.length -1); 
174                                 var before = "onBefore" + evt.substring(2); 
175                                 
176                                 self[before] = function(fn) {
177                                         bind(listeners, before, fn);
178                                         return self;
179                                 };                              
180                         }  
181                         
182                         self[evt] = function(fn) {
183                                 bind(listeners, evt, fn);
184                                 return self;
185                         };
186                         
187                         
188                         // set common clip event listeners to player level
189                         if (index == -1) {
190                                 if (self[before]) {
191                                         player[before] = self[before];          
192                                 }                               
193                                 if (self[evt])  {
194                                         player[evt] = self[evt];                
195                                 }
196                         }
197                         
198                 });                       
199                 
200                 extend(this, {
201                         
202                          
203                         onCuepoint: function(points, fn) {
204                                 
205                                 // embedded cuepoints
206                                 if (arguments.length == 1) {
207                                         cuepoints.embedded = [null, points];
208                                         return self;
209                                 }
210                                 
211                                 if (typeof points == 'number') {
212                                         points = [points];      
213                                 }
214                                 
215                                 var fnId = makeId();  
216                                 cuepoints[fnId] = [points, fn]; 
217                                 
218                                 if (player.isLoaded()) {
219                                         player._api().fp_addCuepoints(points, index, fnId);     
220                                 }  
221                                 
222                                 return self;
223                         },
224                         
225                         update: function(json) {
226                                 extend(self, json);
228                                 if (player.isLoaded()) {
229                                         player._api().fp_updateClip(json, index);       
230                                 }
231                                 var conf = player.getConfig(); 
232                                 var clip = (index == -1) ? conf.clip : conf.playlist[index];
233                                 extend(clip, json, true);
234                         },
235                         
236                         
237                         // internal event for performing clip tasks. should be made private someday
238                         _fireEvent: function(evt, arg1, arg2, target) {                          
239                                 
240                                 if (evt == 'onLoad') { 
241                                         each(cuepoints, function(key, val) {
242                                                 player._api().fp_addCuepoints(val[0], index, key);               
243                                         }); 
244                                         return false;
245                                 }                                       
246                                 
247                                 // target clip we are working against
248                                 if (index != -1) {
249                                         target = self;  
250                                 }
251                                 
252                                 if (evt == 'onCuepoint') {
253                                         var fn = cuepoints[arg1];
254                                         if (fn) {
255                                                 return fn[1].call(player, target, arg2);
256                                         }
257                                 }  
258         
259                                 if (evt == 'onStart' || evt == 'onUpdate') {
260                                         
261                                         extend(target, arg1);                                   
262                                         
263                                         if (!target.duration) {
264                                                 target.duration = arg1.metaData.duration;        
265                                         } else {
266                                                 target.fullDuration = arg1.metaData.duration;   
267                                         }                                         
268                                 }  
269                                 
270                                 var ret = true;
271                                 each(listeners[evt], function() {
272                                         ret = this.call(player, target, arg1);          
273                                 }); 
274                                 return ret;                             
275                         }                       
276                         
277                 });
278                 
279                 
280                 // get cuepoints from config
281                 if (json.onCuepoint) {
282                         self.onCuepoint.apply(self, json.onCuepoint);
283                         delete json.onCuepoint;
284                 } 
285                 
286                 // get other events
287                 each(json, function(key, val) {
288                         if (typeof val == 'function') {
289                                 bind(listeners, key, val);
290                                 delete json[key];       
291                         }
292                 });
294                 
295                 // setup common clip event callbacks for Player object too (shortcuts)
296                 if (index == -1) {
297                         player.onCuepoint = this.onCuepoint;    
298                 }
299         
300         };
302 //}}}
305 // {{{ Plugin
306                 
307         var Plugin = function(name, json, player, fn) {
308         
309                 var listeners = {};
310                 var self = this;   
311                 var hasMethods = false;
312         
313                 if (fn) {
314                         extend(listeners, fn);  
315                 }   
316                 
317                 // custom callback functions in configuration
318                 each(json, function(key, val) {
319                         if (typeof val == 'function') {
320                                 listeners[key] = val;
321                                 delete json[key];       
322                         }
323                 });  
324                 
325                 // core plugin methods          
326                 extend(this, {
327   
328                         animate: function(props, speed, fn) { 
329                                 if (!props) {
330                                         return self;    
331                                 }
332                                 
333                                 if (typeof speed == 'function') { 
334                                         fn = speed; 
335                                         speed = 500;
336                                 }
337                                 
338                                 if (typeof props == 'string') {
339                                         var key = props;
340                                         props = {};
341                                         props[key] = speed;
342                                         speed = 500; 
343                                 }
344                                 
345                                 if (fn) {
346                                         var fnId = makeId();
347                                         listeners[fnId] = fn;
348                                 }
349                 
350                                 if (speed === undefined) { speed = 500; }
351                                 json = player._api().fp_animate(name, props, speed, fnId);      
352                                 return self;
353                         },
354                         
355                         css: function(props, val) {
356                                 if (val !== undefined) {
357                                         var css = {};
358                                         css[props] = val;
359                                         props = css;                                    
360                                 }
361                                 try{
362                                         json = player._api().fp_css(name, props);
363                                         extend(self, json);
364                                         return self;
365                                 }catch(e){
366                                         js_log('flow player could not set css: ' + json);
367                                 }
368                         },
369                         
370                         show: function() {
371                                 this.display = 'block';
372                                 player._api().fp_showPlugin(name);
373                                 return self;
374                         },
375                         
376                         hide: function() {
377                                 this.display = 'none';
378                                 player._api().fp_hidePlugin(name);
379                                 return self;
380                         },
381                         
382                         toggle: function() {
383                                 this.display = player._api().fp_togglePlugin(name);
384                                 return self;
385                         },                      
386                         
387                         fadeTo: function(o, speed, fn) {
388                                 
389                                 if (typeof speed == 'function') { 
390                                         fn = speed; 
391                                         speed = 500;
392                                 }
393                                 
394                                 if (fn) {
395                                         var fnId = makeId();
396                                         listeners[fnId] = fn;
397                                 }                               
398                                 this.display = player._api().fp_fadeTo(name, o, speed, fnId);
399                                 this.opacity = o;
400                                 return self;
401                         },
402                         
403                         fadeIn: function(speed, fn) { 
404                                 return self.fadeTo(1, speed, fn);                               
405                         },
406         
407                         fadeOut: function(speed, fn) {
408                                 return self.fadeTo(0, speed, fn);       
409                         },
410                         
411                         getName: function() {
412                                 return name;    
413                         },
414                         
415                         
416                         // internal method not meant to be used by clients
417                  _fireEvent: function(evt, arg) {
419                                 
420                         // update plugins properties & methods
421                         if (evt == 'onUpdate') {
422                            var json = arg || player._api().fp_getPlugin(name); 
423                                         if (!json) { return;    }                                       
424                                         
425                            extend(self, json);
426                            delete self.methods;
427                                         
428                            if (!hasMethods) {
429                                   each(json.methods, function() {
430                                          var method = "" + this;           
431                                                         
432                                          self[method] = function() {
433                                                 var a = [].slice.call(arguments);
434                                                 var ret = player._api().fp_invoke(name, method, a); 
435                                                 return ret == 'undefined' ? self : ret;
436                                          };
437                                   });
438                                   hasMethods = true;             
439                            }
440                         }
441                         
442                         // plugin callbacks
443                         var fn = listeners[evt];
445                                 if (fn) {
446                                         
447                                         fn.call(self, arg);
448                                         
449                                         // "one-shot" callback
450                                         if (evt.substring(0, 1) == "_") {
451                                                 delete listeners[evt];  
452                                         } 
453                         }                
454                  }                                       
455                         
456                 });
458         };
461 //}}}
464 function Player(wrapper, params, conf) {   
465                 
466         // private variables (+ arguments)
467         var 
468                 self = this, 
469                 api = null, 
470                 html, 
471                 commonClip, 
472                 playlist = [], 
473                 plugins = {},
474                 listeners = {},
475                 playerId,
476                 apiId,
477                 activeIndex,
478                 swfHeight,
479                 wrapperHeight;  
481   
482 // {{{ public methods 
483         
484         extend(self, {
485                         
486                 id: function() {
487                         return playerId;        
488                 }, 
489                 
490                 isLoaded: function() {
491                         return (api !== null);  
492                 },
493                 
494                 getParent: function() {
495                         return wrapper; 
496                 },
497                 
498                 hide: function(all) {
499                         if (all) { wrapper.style.height = "0px"; }
500                         if (api) { api.style.height = "0px"; } 
501                         return self;
502                 },
504                 show: function() {
505                         wrapper.style.height = wrapperHeight + "px";
506                         if (api) { api.style.height = swfHeight + "px"; }
507                         return self;
508                 }, 
509                                         
510                 isHidden: function() {
511                         return api && parseInt(api.style.height, 10) === 0;
512                 },
513                 
514                 
515                 load: function(fn) { 
516                         
517                         if (!api && self._fireEvent("onBeforeLoad") !== false) {
518                                 
519                                 // unload all instances
520                                 each(players, function()  {
521                                         this.unload();          
522                                 });
523                                 
524                                 html = wrapper.innerHTML; 
525                                 flashembed(wrapper, params, {config: conf});
526                                 
527                                 // function argument
528                                 if (fn) {
529                                         fn.cached = true;
530                                         bind(listeners, "onLoad", fn);  
531                                 }
532                         }
533                         
534                         return self;    
535                 },
536                 
537                 unload: function() {  
538                         
539                  if (api && html.replace(/\s/g, '') !== '' && !api.fp_isFullscreen() && 
540                         self._fireEvent("onBeforeUnload") !== false) { 
541                                 api.fp_close();
542                                 wrapper.innerHTML = html; 
543                                 self._fireEvent("onUnload");
544                                 api = null;
545                         }
546                         
547                         return self;
548                 },
550                 getClip: function(index) {
551                         if (index === undefined) {
552                                 index = activeIndex;    
553                         }
554                         return playlist[index];
555                 },
556                 
557                 
558                 getCommonClip: function() {
559                         return commonClip;      
560                 },              
561                 
562                 getPlaylist: function() {
563                         return playlist; 
564                 },
565                 
566           getPlugin: function(name) {  
567                  var plugin = plugins[name];
568                  
569                         // create plugin if nessessary
570                  if (!plugin && self.isLoaded()) {
571                                 var json = self._api().fp_getPlugin(name);
572                                 if (json) {
573                                         plugin = new Plugin(name, json, self);
574                                         plugins[name] = plugin;                                           
575                                 } 
576                  }              
577                  return plugin; 
578           },
579                 
580                 getScreen: function() { 
581                         return self.getPlugin("screen");
582                 }, 
583                 
584                 getControls: function() { 
585                         return self.getPlugin("controls");
586                 }, 
588                 getConfig: function() { 
589                         return clone(conf);
590                 },
591                 
592                 getFlashParams: function() { 
593                         return params;
594                 },              
595                 
596                 loadPlugin: function(name, url, props, fn) { 
598                         // properties not supplied                      
599                         if (typeof props == 'function') { 
600                                 fn = props; 
601                                 props = {};
602                         } 
603                         
604                         // if fn not given, make a fake id so that plugin's onUpdate get's fired
605                         var fnId = fn ? makeId() : "_"; 
606                         self._api().fp_loadPlugin(name, url, props, fnId); 
607                         
608                         // create new plugin
609                         var arg = {};
610                         arg[fnId] = fn;
611                         var p = new Plugin(name, null, self, arg);
612                         plugins[name] = p;
613                         return p;                       
614                 },
615                 
616                 
617                 getState: function() {
618                         return api ? api.fp_getState() : -1;
619                 },
620                 
621                 // "lazy" play
622                 play: function(clip) {
623                         
624                         function play() {
625                                 if (clip !== undefined) {
626                                         self._api().fp_play(clip);
627                                 } else {
628                                         if(typeof self._api().fp_play == 'function')
629                                                 self._api().fp_play();  
630                                 }
631                         }
632                         
633                         if (api) {
634                                 play();
635                                 
636                         } else {
637                                 self.load(function() { 
638                                         play();
639                                 });
640                         }
641                         
642                         return self;
643                 },
644                 
645                 getVersion: function() {
646                         var js = "flowplayer.js 3.0.0-rc5";
647                         if (api) {
648                                 var ver = api.fp_getVersion();
649                                 ver.push(js);
650                                 return ver;
651                         }
652                         return js; 
653                 },
654                 
655                 _api: function() {
656                         if (!api) {
657                                 throw "Flowplayer " +self.id()+ " not loaded. Try moving your call to player's onLoad event";
658                         }
659                         return api;                             
660                 },
661                 
662                 _dump: function() {
663                         console.log(listeners);
664                 }
665                 
666         }); 
667         
668         
669         // event handlers
670         each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),
671                 function() {             
672                         var name = "on" + this;
673                         
674                         // before event
675                         if (name.indexOf("*") != -1) {
676                                 name = name.substring(0, name.length -1); 
677                                 var name2 = "onBefore" + name.substring(2);
678                                 self[name2] = function(fn) {
679                                         bind(listeners, name2, fn);     
680                                         return self;
681                                 };                                              
682                         }
683                         
684                         // normal event
685                         self[name] = function(fn) {
686                                 bind(listeners, name, fn);      
687                                 return self;
688                         };                       
689                 }
690         ); 
691         
692         
693         // core API methods
694         each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset").split(","),         
695                 function() {             
696                         var name = this;
697                         
698                         self[name] = function(arg) {
699                                 if (!api) { return self; }
700                                 try{
701                                         var ret = (arg === undefined) ? api["fp_" + name]() : api["fp_" + name](arg);
702                                         return ret == 'undefined' ? self : ret;
703                                 }catch (e){
704                                         js_log('flowplayer could not access fp_ '+ name);
705                                 }
706                         };                       
707                 }
708         );               
709         
710 //}}}
713 // {{{ public method: _fireEvent
714                 
715         self._fireEvent = function(evt, arg0, arg1, arg2) {             
716                                 
717                 if (conf.debug) {
718                         log(arguments);         
719                 }                               
720                 
721                 // internal onLoad
722                 if (evt == 'onLoad' && !api) {  
723                         
724                         api = api || el(apiId); 
725                         swfHeight = api.clientHeight;
726                         
727                         each(playlist, function() {
728                                 this._fireEvent("onLoad");              
729                         });
730                         
731                         each(plugins, function(name, p) {
732                                 p._fireEvent("onUpdate");               
733                         });
734                         
735                         
736                         commonClip._fireEvent("onLoad");  
737                 }
738                 
739           if (evt == 'onContextMenu') {
740                  each(conf.contextMenu[arg0], function(key, fn)  {
741                         fn.call(self);
742                  });
743                  return;
744           }
746                 if (evt == 'onPluginEvent') {
747                         var name = arg0.name || arg0;
748                         var p = plugins[name];
749                         if (p) {
750                                 if (arg0.name) {
751                                         p._fireEvent("onUpdate", arg0);         
752                                 }
753                                 p._fireEvent(arg1);             
754                         }
755                         return;
756                 }               
758                 // onPlaylistReplace
759                 if (evt == 'onPlaylistReplace') {
760                         playlist = [];
761                         var index = 0;
762                         each(arg0, function() {
763                                 playlist.push(new Clip(this, index++));
764                         });             
765                 }
766                 
767                 var ret = true;
768                 
769                 // clip event
770                 if (arg0 === 0 || (arg0 && arg0 >= 0)) {
771                         
772                         activeIndex = arg0;
773                         var clip = playlist[arg0];                      
774                         
775                         if (clip) {
776                                 ret = clip._fireEvent(evt, arg1, arg2); 
777                         } 
778                         
779                         if (!clip || ret !== false) {
780                                 
781                                 // clip argument is given for common clip, because it behaves as the target
782                                 ret = commonClip._fireEvent(evt, arg1, arg2, clip);     
783                         }  
784                 } 
785                 
786                 // player event 
787                 var i = 0;
788                 each(listeners[evt], function() {
789                         ret = this.call(self, arg0);            
790                         
791                         // remove cached entry
792                         if (this.cached) {
793                                 listeners[evt].splice(i, 1);    
794                         }
795                         
796                         // break loop
797                         if (ret === false) { return false;       }
798                         i++;
799                         
800                 }); 
802                 return ret;
803         };
805 //}}}
808 // {{{ init
809         
810    function init() {
811                 
812                 if ($f(wrapper)) {
813                         return null;    
814                 }               
815                 
816                 wrapperHeight = parseInt(wrapper.style.height) || wrapper.clientHeight;
817                 
818                 // register this player into global array of instances
819                 players.push(self);  
820                 
821                 
822                 // flashembed parameters
823                 if (typeof params == 'string') {
824                         params = {src: params}; 
825                 }       
826                 
827                 // playerId     
828                 playerId = wrapper.id || "fp" + makeId();
829                 apiId = params.id || playerId + "_api";          
830                 params.id = apiId;
831                 conf.playerId = playerId;
832                 
833                 
834                 // plain url is given as config
835                 if (typeof conf == 'string') {
836                         conf = {clip:{url:conf}};       
837                 } 
838                 
839                 // common clip is always there
840                 conf.clip = conf.clip || {};
841                 commonClip = new Clip(conf.clip, -1, self);  
842                 
843                 
844                 // wrapper href as playlist
845                 if (wrapper.getAttribute("href")) { 
846                         conf.playlist = [{url:wrapper.getAttribute("href", 2)}];                        
847                 } 
848                 
849                 // playlist
850                 conf.playlist = conf.playlist || [conf.clip]; 
851                 
852                 var index = 0;
853                 each(conf.playlist, function() {
855                         var clip = this;
856                         
857                         // clip is an array, we don't allow that
858                         if (typeof clip == 'object' && clip.length)  {
859                                 clip = "" + clip;       
860                         }
861                         
862                         if (!clip.url && typeof clip == 'string') {                             
863                                 clip = {url: clip};                             
864                         } 
865                         
866                         // populate common clip properties to each clip
867                         extend(clip, conf.clip, true);          
868                         
869                         // modify configuration playlist
870                         conf.playlist[index] = clip;                    
871                         
872                         // populate playlist array
873                         clip = new Clip(clip, index, self);
874                         playlist.push(clip);                                            
875                         index++;                        
876                 });
877                         
878                 
879                 // event listeners
880                 each(conf, function(key, val) {
881                         if (typeof val == 'function') {
882                                 bind(listeners, key, val);
883                                 delete conf[key];       
884                         }
885                 });              
886                 
887                 
888                 // plugins
889                 each(conf.plugins, function(name, val) {
890                         if (val) {
891                                 plugins[name] = new Plugin(name, val, self);
892                         }
893                 });
894                 
895                 
896                 // setup controlbar plugin if not explicitly defined
897                 if (!conf.plugins || conf.plugins.controls === undefined) {
898                         plugins.controls = new Plugin("controls", null, self);  
899                 } 
900                 
901                 // Flowplayer uses black background by default
902                 params.bgcolor = params.bgcolor || "#000000";
903                 
904                 
905                 // setup default settings for express install
906                 params.version = params.version || [9,0];               
907                 params.expressInstall = 'http://www.flowplayer.org/swf/expressinstall.swf';
908                 
909                 
910                 // click function
911                 function doClick(e) {
912                         if (self._fireEvent("onBeforeClick") !== false) {
913                                 self.load();            
914                         } 
915                         return stopEvent(e);                                    
916                 }
917                 
918                 // defer loading upon click
919                 html = wrapper.innerHTML;
920                 if (html.replace(/\s/g, '') !== '') {    
921                         
922                         if (wrapper.addEventListener) {
923                                 wrapper.addEventListener("click", doClick, false);      
924                                 
925                         } else if (wrapper.attachEvent) {
926                                 wrapper.attachEvent("onclick", doClick);        
927                         }
928                         
929                 // player is loaded upon page load 
930                 } else {
931                         
932                         // prevent default action from wrapper (safari problem) loaded
933                         if (wrapper.addEventListener) {
934                                 wrapper.addEventListener("click", stopEvent, false);    
935                         }
936                         
937                         // load player
938                         self.load();
939                 }
940                 
941         }
943         // possibly defer initialization until DOM get's loaded
944         if (typeof wrapper == 'string') { 
945                 flashembed.domReady(function() {
946                         var node = el(wrapper); 
947                         
948                         if (!node) {
949                                 throw "Flowplayer cannot access element: " + wrapper;   
950                         } else {
951                                 wrapper = node; 
952                                 init();                                 
953                         } 
954                 });
955                 
956         // we have a DOM element so page is already loaded
957         } else {                
958                 init();
959         }
960         
961         
962 //}}}
968 // {{{ flowplayer() & statics 
970 // container for player instances
971 var players = [];
974 // this object is returned when multiple player's are requested 
975 function Iterator(arr) {
976         
977         this.length = arr.length;
978         
979         this.each = function(fn)  {
980                 each(arr, fn);  
981         };
982         
983         this.size = function() {
984                 return arr.length;      
985         };      
988 // these two variables are the only global variables
989 window.flowplayer = window.$f = function() {
990         
991         var instance = null;
992         var arg = arguments[0]; 
993         
994         
995         // $f()
996         if (!arguments.length) {
997                 each(players, function() {
998                         if (this.isLoaded())  {
999                                 instance = this;        
1000                                 return false;
1001                         }
1002                 });
1003                 
1004                 return instance || players[0];
1005         } 
1006         
1007         if (arguments.length == 1) {
1008                 
1009                 // $f(index);
1010                 if (typeof arg == 'number') { 
1011                         return players[arg];    
1012         
1013                         
1014                 // $f(wrapper || 'containerId' || '*');
1015                 } else {
1016                         
1017                         // $f("*");
1018                         if (arg == '*') {
1019                                 return new Iterator(players);   
1020                         }
1021                         
1022                         // $f(wrapper || 'containerId');
1023                         each(players, function() {
1024                                 if (this.id() == arg.id || this.id() == arg || this.getParent() == arg)  {
1025                                         instance = this;        
1026                                         return false;
1027                                 }
1028                         });
1029                         
1030                         return instance;                                        
1031                 }
1032         }                        
1034         // instance builder 
1035         if (arguments.length > 1) {             
1037                 var swf = arguments[1];
1038                 var conf = (arguments.length == 3) ? arguments[2] : {};
1039                                                 
1040                 if (typeof arg == 'string') {
1041                         
1042                         // select arg by classname
1043                         if (arg.indexOf(".") != -1) {
1044                                 var instances = [];
1045                                 
1046                                 each(select(arg), function() { 
1047                                         instances.push(new Player(this, clone(swf), clone(conf)));               
1048                                 });     
1049                                 
1050                                 return new Iterator(instances);
1051                                 
1052                         // select node by id
1053                         } else {                
1054                                 var node = el(arg);
1055                                 return new Player(node !== null ? node : arg, swf, conf);         
1056                         } 
1057                         
1058                         
1059                 // arg is a DOM element
1060                 } else if (arg) {
1061                         return new Player(arg, swf, conf);                                              
1062                 }
1063                 
1064         } 
1065         
1066         return null; 
1068         
1069 extend(window.$f, {
1071         // called by Flash External Interface            
1072         fireEvent: function(id, evt, a0, a1, a2) {              
1073                 var p = $f(id);         
1074                 return p ? p._fireEvent(evt, a0, a1, a2) : null;
1075         },
1076         
1077         
1078         // create plugins by modifying Player's prototype
1079         addPlugin: function(name, fn) {
1080                 Player.prototype[name] = fn;
1081                 return $f;
1082         },
1083         
1084         // utility methods for plugin developers
1085         each: each,
1086         
1087         extend: extend
1088         
1090         
1091 //}}}
1094 //{{{ jQuery support
1096 if (typeof jQuery == 'function') {
1097         
1098         jQuery.prototype.flowplayer = function(params, conf) {  
1099                 
1100                 // select instances
1101                 if (!arguments.length || typeof arguments[0] == 'number') {
1102                         var arr = [];
1103                         this.each(function()  {
1104                                 var p = $f(this);
1105                                 if (p) {
1106                                         arr.push(p);    
1107                                 }
1108                         });
1109                         return arguments.length ? arr[arguments[0]] : new Iterator(arr);
1110                 }
1111                 
1112                 // create flowplayer instances
1113                 return this.each(function() { 
1114                         $f(this, clone(params), conf ? clone(conf) : {});       
1115                 }); 
1116                 
1117         };
1118         
1121 //}}}
1124 })();
1125 /** 
1126  * flashembed 0.34. Adobe Flash embedding script
1127  * 
1128  * http://flowplayer.org/tools/flash-embed.html
1130  * Copyright (c) 2008 Tero Piirainen (support@flowplayer.org)
1132  * Released under the MIT License:
1133  * http://www.opensource.org/licenses/mit-license.php
1134  * 
1135  * >> Basically you can do anything you want but leave this header as is <<
1137  * first version 0.01 - 03/11/2008 
1138  * version 0.34 - Tue Nov 11 2008 09:09:52 GMT-0000 (GMT+00:00)
1139  */
1140 (function() { 
1142 //{{{ utility functions 
1143                 
1144 var jQ = typeof jQuery == 'function';
1147 // from "Pro JavaScript techniques" by John Resig
1148 function isDomReady() {
1149         
1150         if (domReady.done)  { return false; }
1151         
1152         var d = document;
1153         if (d && d.getElementsByTagName && d.getElementById && d.body) {
1154                 clearInterval(domReady.timer);
1155                 domReady.timer = null;
1156                 
1157                 for (var i = 0; i < domReady.ready.length; i++) {
1158                         domReady.ready[i].call();       
1159                 }
1160                 
1161                 domReady.ready = null;
1162                 domReady.done = true;
1163         } 
1166 // if jQuery is present, use it's more effective domReady method
1167 var domReady = jQ ? jQuery : function(f) {
1168         
1169         if (domReady.done) {
1170                 return f();     
1171         }
1172         
1173         if (domReady.timer) {
1174                 domReady.ready.push(f); 
1175                 
1176         } else {
1177                 domReady.ready = [f];
1178                 domReady.timer = setInterval(isDomReady, 13);
1179         } 
1180 };      
1183 // override extend params function 
1184 function extend(to, from) {
1185         if (from) {
1186                 for (key in from) {
1187                         if (from.hasOwnProperty(key)) {
1188                                 to[key] = from[key];
1189                         }
1190                 }
1191         }
1192         
1193         return to;
1194 }       
1197 function concatVars(vars) {             
1198         var out = "";
1199         
1200         for (var key in vars) { 
1201                 if (vars[key]) {
1202                         out += [key] + '=' + asString(vars[key]) + '&';
1203                 }
1204         }                       
1205         return out.substring(0, out.length -1);                         
1206 }  
1210 // JSON.asString() function
1211 function asString(obj) {
1213         switch (typeOf(obj)){
1214                 case 'string':
1215                         obj = obj.replace(new RegExp('(["\\\\])', 'g'), '\\$1');
1216                         
1217                         // flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit)
1218                         obj = obj.replace(/^\s?(\d+)%/, "$1pct");
1219                         return '"' +obj+ '"';
1220                         
1221                 case 'array':
1222                         return '['+ map(obj, function(el) {
1223                                 return asString(el);
1224                         }).join(',') +']'; 
1225                         
1226                 case 'function':
1227                         return '"function()"';
1228                         
1229                 case 'object':
1230                         var str = [];
1231                         for (var prop in obj) {
1232                                 if (obj.hasOwnProperty(prop)) {
1233                                         str.push('"'+prop+'":'+ asString(obj[prop]));
1234                                 }
1235                         }
1236                         return '{'+str.join(',')+'}';
1237         }
1238         
1239         // replace ' --> "  and remove spaces
1240         return String(obj).replace(/\s/g, " ").replace(/\'/g, "\"");
1244 // private functions
1245 function typeOf(obj) {
1246         if (obj === null || obj === undefined) { return false; }
1247         var type = typeof obj;
1248         return (type == 'object' && obj.push) ? 'array' : type;
1252 // version 9 bugfix: (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
1253 if (window.attachEvent) {
1254         window.attachEvent("onbeforeunload", function() {
1255                 __flash_unloadHandler = function() {};
1256                 __flash_savedUnloadHandler = function() {};
1257         });
1260 function map(arr, func) {
1261         var newArr = []; 
1262         for (var i in arr) {
1263                 if (arr.hasOwnProperty(i)) {
1264                         newArr[i] = func(arr[i]);
1265                 }
1266         }
1267         return newArr;
1269         
1270 function getEmbedCode(p, c) {
1271         var html = '<embed type="application/x-shockwave-flash" ';
1273         if (p.id) { extend(p, {name:p.id}); }
1274         
1275         for (var key in p) { 
1276                 if (p[key] !== null) { 
1277                         html += key + '="' +p[key]+ '"\n\t';
1278                 }
1279         }
1281         if (c) {
1282                  html += 'flashvars=\'' + concatVars(c) + '\'';
1283         }
1284         
1285         // thanks Tom Price (07/17/2008)
1286         html += '/>';
1287         
1288         return html;
1291 function getObjectCode(p, c, embeddable) {
1292         
1293         var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
1294         html += 'width="' + p.width + '" height="' + p.height + '"'; 
1295         
1296         // force id for IE. otherwise embedded Flash object cannot be returned
1297         if (!p.id && document.all) {
1298                 p.id = "_" + ("" + Math.random()).substring(5);
1299         } 
1300         
1301         if (p.id) {
1302                 html += ' id="' + p.id + '"';
1303         }
1304         
1305         html += '>';  
1306         
1307         // sometimes ie fails to load flash if it's on cache
1308         if (document.all) {
1309                 p.src += ((p.src.indexOf("?") != -1 ? "&" : "?") + Math.random());              
1310         } 
1311         
1312         html += '\n\t<param name="movie" value="'+ p.src +'" />';
1314         var e = extend({}, p);
1315         e.id = e.width = e.height = e.src = null;
1316         
1317         for (var k in e) {
1318                 if (e[k] !== null) {
1319                         html += '\n\t<param name="'+ k +'" value="'+ e[k] +'" />';
1320                 }
1321         }
1322         
1323         if (c) {
1324                 html += '\n\t<param name="flashvars" value=\'' + concatVars(c) + '\' />';
1325         }
1326         
1327         if (embeddable) {
1328                 html += getEmbedCode(p, c);     
1329         }
1330          
1331         html += "</object>";
1332         
1333         return html;
1336 function getFullHTML(p, c) {
1337         return getObjectCode(p, c, true);       
1340 function getHTML(p, c) { 
1341         var isNav = navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length; 
1342         return (isNav) ? getEmbedCode(p, c) : getObjectCode(p, c);
1345 //}}}
1347         
1348 window.flashembed = function(root, userParams, flashvars) {     
1349         
1350         
1351 //{{{ construction
1352                 
1353         // setup params
1354         var params = {
1355                 
1356                 // very common params
1357                 src: '#',
1358                 width: '100%',
1359                 height: '100%',         
1360                 
1361                 // flashembed specific options
1362                 version:null,
1363                 onFail:null,
1364                 expressInstall:null,  
1365                 debug: false,
1366                 
1367                 // flashembed defaults
1368                 // bgcolor: 'transparent',
1369                 allowfullscreen: true,
1370                 allowscriptaccess: 'always',
1371                 quality: 'high',
1372                 type: 'application/x-shockwave-flash',
1373                 pluginspage: 'http://www.adobe.com/go/getflashplayer'
1374         };
1375         
1376         
1377         if (typeof userParams == 'string') {
1378                 userParams = {src: userParams}; 
1379         }
1380         
1381         extend(params, userParams);                      
1382                 
1383         var version = flashembed.getVersion(); 
1384         var required = params.version; 
1385         var express = params.expressInstall;             
1386         var debug = params.debug;
1388         
1389         if (typeof root == 'string') {
1390                 var el = document.getElementById(root);
1391                 if (el) {
1392                         root = el;      
1393                 } else {
1394                         domReady(function() {
1395                                 flashembed(root, userParams, flashvars);
1396                         });
1397                         return;          
1398                 } 
1399         }
1400         
1401         if (!root) { return; }
1403         
1404         // is supported 
1405         if (!required || flashembed.isSupported(required)) {
1406                 params.onFail = params.version = params.expressInstall = params.debug = null;
1407                 
1408                 // root.innerHTML may cause broplems: http://domscripting.com/blog/display/99
1409                 // thanks to: Ryan Rud
1410                 // var tmp = document.createElement("extradiv");
1411                 // tmp.innerHTML = getHTML();
1412                 // root.appendChild(tmp);
1413                 
1414                 root.innerHTML = getHTML(params, flashvars);
1415                 
1416                 // return our API                       
1417                 return root.firstChild;
1418                 
1419         // custom fail event
1420         } else if (params.onFail) {
1421                 var ret = params.onFail.call(params, flashembed.getVersion(), flashvars);
1422                 if (ret === true) { root.innerHTML = ret; }             
1423                 
1425         // express install
1426         } else if (required && express && flashembed.isSupported([6,65])) {
1427                 
1428                 extend(params, {src: express});
1429                 
1430                 flashvars = {
1431                         MMredirectURL: location.href,
1432                         MMplayerType: 'PlugIn',
1433                         MMdoctitle: document.title
1434                 };
1435                 
1436                 root.innerHTML = getHTML(params, flashvars);    
1437                 
1438         // not supported
1439         } else {
1441                 // minor bug fixed here 08.04.2008 (thanks JRodman)
1442                 
1443                 if (root.innerHTML.replace(/\s/g, '') !== '') {
1444                         // custom content was supplied
1445                 
1446                 } else {
1447                         root.innerHTML = 
1448                                 "<h2>Flash version " + required + " or greater is required</h2>" + 
1449                                 "<h3>" + 
1450                                         (version[0] > 0 ? "Your version is " + version : "You have no flash plugin installed") +
1451                                 "</h3>" + 
1452                                 "<p>Download latest version from <a href='" + params.pluginspage + "'>here</a></p>";
1453                 }
1454         }
1456         return root;
1457         
1458 //}}}
1459         
1460         
1464 //{{{ static methods
1466 extend(window.flashembed, {
1468         // returns arr[major, fix]
1469         getVersion: function() {
1470         
1471                 var version = [0, 0];
1472                 
1473                 if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
1474                         var _d = navigator.plugins["Shockwave Flash"].description;
1475                         if (typeof _d != "undefined") {
1476                                 _d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
1477                                 var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10);
1478                                 var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
1479                                 version = [_m, _r];
1480                         }
1481                         
1482                 } else if (window.ActiveXObject) {
1483                         
1484                         try { // avoid fp 6 crashes
1485                                 var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
1486                                 
1487                         } catch(e) {
1488                                 try { 
1489                                         _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
1490                                         version = [6, 0];
1491                                         _a.AllowScriptAccess = "always"; // throws if fp < 6.47 
1492                                         
1493                                 } catch(ee) {
1494                                         if (version[0] == 6) { return; }
1495                                 }
1496                                 try {
1497                                         _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
1498                                 } catch(eee) {
1499                                 
1500                                 }
1501                                 
1502                         }
1503                         
1504                         if (typeof _a == "object") {
1505                                 _d = _a.GetVariable("$version"); // bugs in fp 6.21 / 6.23
1506                                 if (typeof _d != "undefined") {
1507                                         _d = _d.replace(/^\S+\s+(.*)$/, "$1").split(",");
1508                                         version = [parseInt(_d[0], 10), parseInt(_d[2], 10)];
1509                                 }
1510                         }
1511                 } 
1512                 
1513                 return version;
1514         },
1515         
1516         isSupported: function(version) {
1517                 var now = flashembed.getVersion();
1518                 var ret = (now[0] > version[0]) || (now[0] == version[0] && now[1] >= version[1]);                      
1519                 return ret;
1520         },
1521         
1522         domReady: domReady,
1523         
1524         // returns a String representation from JSON object 
1525         asString: asString,
1526         
1527         getHTML: getHTML,
1528         
1529         getFullHTML: getFullHTML
1530         
1533 //}}}
1536 // setup jquery support
1537 if (jQ) {
1538         
1539         jQuery.prototype.flashembed = function(params, flashvars) { 
1540                 return this.each(function() { 
1541                         flashembed(this, params, flashvars);
1542                 });
1543         };
1547 })();
1549 /************************************************
1550 ********* mv_embed extension to flowplayer.js ***
1551 ************************************************/        
1552 var flashEmbed = {
1553         instanceOf:'flashEmbed',
1554         monitorTimerId : 0,
1555         old_pid:0,
1556         didSeekJump:false,
1557         startedTimedPlayback:false,             
1558         didDateStartTimeRestore:false,
1559         supports: {
1560                 'play_head':true, 
1561                 'pause':true,
1562                 'stop':true, 
1563                 //'fullscreen':true, 
1564                 'time_display':true, 
1565                 'volume_control':true,
1566                 'overlay':false,
1567                 'fullscreen':false
1568         },
1569         getEmbedHTML: function (){
1570                 setTimeout('document.getElementById(\''+this.id+'\').postEmbedJS()', 150);
1571                 return this.wrapEmebedContainer( this.getEmbedObj() );
1572         },
1573         getEmbedObj:function(){ 
1574                 //give the embed element a unique pid (work around for flowplayer persistence)
1575                 if( this.old_pid!=0 ){
1576                         this.pid = this.pid +'_'+ this.old_pid;
1577                 }                               
1578                 return '<a  '+
1579                                         'href="'+ this.getSrc() + '" '+  
1580                                         'style="display:block;width:' + parseInt(this.width) + 'px;height:' + parseInt(this.height) + 'px" '+  
1581                                         'id="'+this.pid+'">'+ 
1582                                 '</a>';
1583         },
1584         postEmbedJS: function()
1585         {   
1586                 var _this = this;
1587                 js_log('embedFlow: uri:'+ this.getSrc() + "\n"+ mv_embed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ;
1588                 var flowConfig = { 
1589                         clip: { 
1590                                 url: this.getSrc(),                               
1591                                 // when this is false playback does not start until play button is pressed 
1592                                 autoPlay: true
1593                         },
1594                         plugins: { 
1595                                 controls: { 
1596                                    all: false, 
1597                                    fullscreen: true,
1598                                    backgroundColor: 'transparent',
1599                                    backgroundGradient: 'none',
1600                                    autoHide:'always',
1601                                    top:'95%',
1602                                    right:'0px'
1603                                 }                                
1604                         },
1605                         screen: {
1606                                 opacity : '1.0'
1607                         }                       
1608                 };
1609                 
1610                 //if in preview mode set grey and lower volume until "ready"
1611                 if( this.preview_mode ){
1612                         flowConfig.screen.opacity = 0.2;                                 
1613                 }                                       
1614                 
1615                 $f(this.pid,  mv_embed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf', flowConfig);                                  
1616                 //get the this.fla value:                
1617                 this.getFLA();          
1618                 //set up bindings (for when interacting with the swf causes action:  
1619                 this.fla.onPause(function(){                                                                                                                            
1620                         _this.parent_pause();   //update the interface                   
1621                 })
1622                 this.fla.onResume( function(){
1623                         _this.parent_play();    //update the interface  
1624                 });                             
1625                    
1626                 //start monitor: 
1627                 this.monitor();  
1628                 this.old_pid++;
1629         },   
1630         /* js hooks/controls */
1631         play: function(){                               
1632                 this.getFLA();          
1633                 //update play/pause button etc
1634                 this.parent_play();                             
1635                 if( this.fla ){                 
1636                         this.fla.play();                        
1637                         
1638                         //on a resume make sure volume and opacity are correct 
1639                         this.restorePlayer();                                            
1640                         setTimeout('$j(\'#'+this.id+'\').get(0).monitor()', 250);
1641                 }
1642         },
1643         //@@todo support mute
1644         toggleMute: function(){
1645                 this.parent_toggleMute();
1646                 this.getFLA();
1647                 if(this.fla){
1648                         if(this.muted){
1649                                 
1650                         }else{
1651                                 
1652                         }
1653                 }
1654         },
1655         //@@ Suport UpDateVolumen 
1656         updateVolumen:function(perc){
1657                 this.getFLA();          
1658                 if(this.fla)this.fla.setVolume(perc*100);
1659                             
1660     },  
1661     //@@ Get Volumen
1662         getVolumen:function(){
1663                 this.getFLA();          
1664                 if(this.fla)
1665                         return this.fla.getVolume() / 100;                         
1666     },  
1667         fullscreen:function(){
1668                 if(this.fla){
1669                         this.fla.fullscreen();
1670                 }else{
1671                         js_log('must be playing before you can go fullscreen');
1672                 }
1673         },
1674         pause : function()
1675         {
1676                 this.getFLA();
1677                 if(!this.thumbnail_disp){
1678                         this.parent_pause();
1679                         if(this.fla){           
1680                                 js_log("Flash:Pause: " + this.fla.isPaused() );
1681                                 if( this.fla['pause'] ){
1682                                         if( ! this.fla.isPaused() ){
1683                                                 js_log('calling plugin pause');                         
1684                                                 this.fla.pause();  
1685                                                 
1686                                                 //restore volume and opacity 
1687                                                 this.restorePlayer();              
1688                                         }
1689                                 }
1690                         }
1691                 }
1692         },
1693         monitor : function()
1694         {                       
1695                 var _this = this;
1696                 //date time
1697                 if( !this.dateStartTime ){
1698                         var d = new Date();
1699                         this.dateStartTime = d.getTime();
1700                         
1701                 }else{
1702                         var d = new Date();                                              
1703                         if( !this.didDateStartTimeRestore  && this.preview_mode)
1704                                 this.fla.setVolume(0);
1705                                 
1706                         if( (d.getTime() - this.dateStartTime) > 6000  && !this.didDateStartTimeRestore){                                                        
1707                                 this.restorePlayer(); 
1708                         }
1709                 }                                         
1710                                           
1711                 var flash_state = this.fla.getStatus();
1712                 //update the duration from the clip if its zero or not set: 
1713                 if( !this.duration || this.duration==0 ){
1714                         if( this.fla.getClip() ){
1715                                 this.duration = this.fla.getClip().fullDuration;                                
1716                                 js_log('set duration via clip value: ' + this.getDuration() );
1717                         }
1718                 }
1719                 //update the duration ntp values: 
1720                 this.getDuration();             
1722                 if( typeof flash_state == 'undefined' ){
1723                          var flash_state = {
1724                                  "time" : this.fla.getTime()
1725                          };                              
1726                         //we are not getting buffered data restore volume and opacity
1727                         this.restorePlayer();                                              
1728                 }else{
1729                         //simplification of buffer state ... should move to support returning time rages like:
1730                         //http://www.whatwg.org/specs/web-apps/current-work/#normalized-timeranges-object                       
1731                         this.bufferedPercent = flash_state.bufferEnd / this.getDuration();                                                                      
1732                 }                          
1733                 //set the current Time (based on timeFormat)            
1734                 if( this.supportsURLTimeEncoding() ){
1735                         this.currentTime = flash_state.time;                      
1736                         //js_log('set buffer: ' + flash_state.bufferEnd + ' at time: ' + flash_state.time +' of total dur: ' + this.getDuration()); 
1737                 }else{
1738                         this.currentTime = flash_state.time + this.start_offset;                                                
1739                         //stop buffering if greater than the duration: 
1740                         if( flash_state.bufferEnd > this.getDuration() + 5 ){
1741                                 //js_log('should stop buffering (does not seem to work)' + flash_state.bufferEnd + ' > dur: ' + this.getDuration() );
1742                                 this.fla.stopBuffering();
1743                         } 
1744                 }                                 
1745                 
1746                 if(this.currentTime > npt2seconds(this.start_ntp) && !this.startedTimedPlayback){
1747                         var fail = false;
1748                         try
1749                         {
1750                                 this.restorePlayer();                           
1751                         }
1752                         catch(err)
1753                         {
1754                                 js_log('failed to set values');
1755                                 fail = true;
1756                         }
1757                         if(!fail)
1758                                 this.startedTimedPlayback=true;                                                                          
1759                 }
1760                 
1761                 /* to support local seeks */
1762                 if(this.currentTime > 1 && this.seek_time_sec != 0 && !this.supportsURLTimeEncoding() )
1763                 {
1764                         js_log('flashEmbed: _local_ Seeking to ' + this.seek_time_sec);
1765                         this.fla.seek( this.seek_time_sec );
1766                         this.seek_time_sec = 0;
1767                 }                                               
1768                 
1769                 //checks to see if we reached the end of playback:                              
1770                 if(this.duration && this.startedTimedPlayback && 
1771                         (        this.currentTime > (npt2seconds(this.end_ntp)+2) 
1772                                 || 
1773                                 ( this.currentTime > (npt2seconds(this.end_ntp)-1) 
1774                                         && this.prevTime == this.currentTime) )
1775                         ){                                                      
1776                         js_log('prbally reached end of stream: '+ seconds2npt( this.currentTime) );
1777                         this.onClipDone();                                
1778                 }               
1779                 
1780                 //update the status and check timmer via universal parent monitor
1781                 this.parent_monitor();
1782                 
1783                 
1784                 this.prevTime = this.currentTime;       
1785                 //js_log('cur perc loaded: ' + this.fla.getPercentLoaded() +' cur time : ' + (this.currentTime - npt2seconds(this.start_ntp)) +' / ' +(npt2seconds(this.end_ntp)-npt2seconds(this.start_ntp)));
1786         },
1787         restorePlayer:function(){               
1788                 if(!this.fla)
1789                         this.getFLA();
1790                 if(this.fla){
1791                         js_log('f:do restorePlayer');
1792                         this.fla.setVolume(90); 
1793                         $f().getPlugin('screen').css({'opacity':'1.0'} );
1794                         //set the fallback date restore flag to true:
1795                         this.didDateStartTimeRestore=true;                                
1796                 }               
1797         },
1798         // get the embed fla object 
1799         getFLA : function (){
1800                 this.fla = $f(this.pid);                   
1801         },
1802         stop : function(){      
1803                 js_log('f:flashEmbed:stop');            
1804                 this.startedTimedPlayback=false;        
1805                 if (this.monitorTimerId != 0 )
1806                 {
1807                         clearInterval(this.monitorTimerId);
1808                         this.monitorTimerId = 0;
1809                 }
1810                 if(this.fla)
1811                         this.fla.unload();
1812                 this.parent_stop();
1813         },
1814         onStop: function(){
1815                 js_log('f:onStop');
1816                 //stop updates: 
1817                 if( this.monitorTimerId != 0 )
1818                 {
1819                         clearInterval(this.monitorTimerId);
1820                         this.monitorTimerId = 0;
1821                 }
1822         },
1823         onClipDone: function(){                 
1824                 js_log('f:flash:onClipDone');           
1825                 if( ! this.startedTimedPlayback){
1826                         js_log('clip done before timed playback started .. not good. (ignoring) ');                     
1827                         //keep monitoring: 
1828                         this.monitor();
1829                 }else{
1830                         js_log('clip done and '+ this.startedTimedPlayback);
1831                         //stop the clip if its not stopped already:
1832                         this.stop();
1833                         this.setStatus("Clip Done...");
1834                         //run the onClip done action: 
1835                         this.parent_onClipDone();
1836                 }
1837         }