1// afspiller wmv filer 2function videoAfspil(q_hans){ 3 if (q_hans.length > 0) 4 document.write("<embed class='video' src= 'billeder/" + q_hans + "'/>"); 5 } 6 7 8 9/** 10 * flowplayer.js 3.0.5. The Flowplayer API 11 * 12 * Copyright 2009 Flowplayer Oy 13 * 14 * This file is part of Flowplayer. 15 * 16 * Flowplayer is free software: you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation, either version 3 of the License, or 19 * (at your option) any later version. 20 * 21 * Flowplayer is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU General Public License 27 * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. 28 * 29 * Version: 3.0.5 - Tue Feb 03 2009 13:14:24 GMT-0000 (GMT+00:00) 30 */ 31(function() { 32 33/* 34 FEATURES 35 -------- 36 - handling multiple instances 37 - Flowplayer programming API 38 - Flowplayer event model 39 - player loading / unloading 40 - $f() function 41 - jQuery support 42*/ 43 44 45/*jslint glovar: true, browser: true */ 46/*global flowplayer, $f */ 47 48// {{{ private utility methods 49 50 function log(args) { 51 console.log("$f.fireEvent", [].slice.call(args)); 52 } 53 54 55 // thanks: http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone 56 function clone(obj) { 57 if (!obj || typeof obj != 'object') { return obj; } 58 var temp = new obj.constructor(); 59 for (var key in obj) { 60 if (obj.hasOwnProperty(key)) { 61 temp[key] = clone(obj[key]); 62 } 63 } 64 return temp; 65 } 66 67 // stripped from jQuery, thanks John Resig 68 function each(obj, fn) { 69 if (!obj) { return; } 70 71 var name, i = 0, length = obj.length; 72 73 // object 74 if (length === undefined) { 75 for (name in obj) { 76 if (fn.call(obj[name], name, obj[name]) === false) { break; } 77 } 78 79 // array 80 } else { 81 for (var value = obj[0]; 82 i < length && fn.call( value, i, value ) !== false; value = obj[++i]) { 83 } 84 } 85 86 return obj; 87 } 88 89 90 // convenience 91 function el(id) { 92 return document.getElementById(id); 93 } 94 95 96 // used extensively. a very simple implementation. 97 function extend(to, from, skipFuncs) { 98 if (to && from) { 99 each(from, function(name, value) { 100 if (!skipFuncs || typeof value != 'function') { 101 to[name] = value; 102 } 103 }); 104 } 105 } 106 107 // var arr = select("elem.className"); 108 function select(query) { 109 var index = query.indexOf("."); 110 if (index != -1) { 111 var tag = query.substring(0, index) || "*"; 112 var klass = query.substring(index + 1, query.length); 113 var els = []; 114 each(document.getElementsByTagName(tag), function() { 115 if (this.className && this.className.indexOf(klass) != -1) { 116 els.push(this); 117 } 118 }); 119 return els; 120 } 121 } 122 123 // fix event inconsistencies across browsers 124 function stopEvent(e) { 125 e = e || window.event; 126 127 if (e.preventDefault) { 128 e.stopPropagation(); 129 e.preventDefault(); 130 131 } else { 132 e.returnValue = false; 133 e.cancelBubble = true; 134 } 135 return false; 136 } 137 138 // push an event listener into existing array of listeners 139 function bind(to, evt, fn) { 140 to[evt] = to[evt] || []; 141 to[evt].push(fn); 142 } 143 144 145 // generates an unique id 146 function makeId() { 147 return "_" + ("" + Math.random()).substring(2, 10); 148 } 149 150//}}} 151 152 153// {{{ Clip 154 155 var Clip = function(json, index, player) { 156 157 // private variables 158 var self = this; 159 var cuepoints = {}; 160 var listeners = {}; 161 self.index = index; 162 163 // instance variables 164 if (typeof json == 'string') { 165 json = {url:json}; 166 } 167 168 extend(this, json, true); 169 170 // event handling 171 each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","), 172 function() { 173 174 var evt = "on" + this; 175 176 // before event 177 if (evt.indexOf("*") != -1) { 178 evt = evt.substring(0, evt.length -1); 179 var before = "onBefore" + evt.substring(2); 180 181 self[before] = function(fn) { 182 bind(listeners, before, fn); 183 return self; 184 }; 185 } 186 187 self[evt] = function(fn) { 188 bind(listeners, evt, fn); 189 return self; 190 }; 191 192 193 // set common clip event listeners to player level 194 if (index == -1) { 195 if (self[before]) { 196 player[before] = self[before]; 197 } 198 if (self[evt]) { 199 player[evt] = self[evt]; 200 } 201 } 202 203 }); 204 205 extend(this, { 206 207 onCuepoint: function(points, fn) { 208 209 // embedded cuepoints 210 if (arguments.length == 1) { 211 cuepoints.embedded = [null, points]; 212 return self; 213 } 214 215 if (typeof points == 'number') { 216 points = [points]; 217 } 218 219 var fnId = makeId(); 220 cuepoints[fnId] = [points, fn]; 221 222 if (player.isLoaded()) { 223 player._api().fp_addCuepoints(points, index, fnId); 224 } 225 226 return self; 227 }, 228 229 update: function(json) { 230 extend(self, json); 231 232 if (player.isLoaded()) { 233 player._api().fp_updateClip(json, index); 234 } 235 var conf = player.getConfig(); 236 var clip = (index == -1) ? conf.clip : conf.playlist[index]; 237 extend(clip, json, true); 238 }, 239 240 241 // internal event for performing clip tasks. should be made private someday 242 _fireEvent: function(evt, arg1, arg2, target) { 243 244 if (evt == 'onLoad') { 245 each(cuepoints, function(key, val) { 246 if (val[0]) { 247 player._api().fp_addCuepoints(val[0], index, key); 248 } 249 }); 250 return false; 251 } 252 253 // target clip we are working against 254 target = target || self; 255 256 if (evt == 'onCuepoint') { 257 var fn = cuepoints[arg1]; 258 if (fn) { 259 return fn[1].call(player, target, arg2); 260 } 261 } 262 263 if (evt == 'onStart' || evt == 'onUpdate') { 264 265 extend(target, arg1); 266 267 if (!target.duration) { 268 target.duration = arg1.metaData.duration; 269 } else { 270 target.fullDuration = arg1.metaData.duration; 271 } 272 } 273 274 var ret = true; 275 each(listeners[evt], function() { 276 ret = this.call(player, target, arg1, arg2); 277 }); 278 return ret; 279 } 280 281 }); 282 283 284 // get cuepoints from config 285 if (json.onCuepoint) { 286 var arg = json.onCuepoint; 287 self.onCuepoint.apply(self, typeof arg == 'function' ? [arg] : arg); 288 delete json.onCuepoint; 289 } 290 291 // get other events 292 each(json, function(key, val) { 293 if (typeof val == 'function') { 294 bind(listeners, key, val); 295 delete json[key]; 296 } 297 }); 298 299 300 // setup common clip event callbacks for Player object too (shortcuts) 301 if (index == -1) { 302 player.onCuepoint = this.onCuepoint; 303 } 304 305 }; 306 307//}}} 308 309 310// {{{ Plugin 311 312 var Plugin = function(name, json, player, fn) { 313 314 var listeners = {}; 315 var self = this; 316 var hasMethods = false; 317 318 if (fn) { 319 extend(listeners, fn); 320 } 321 322 // custom callback functions in configuration 323 each(json, function(key, val) { 324 if (typeof val == 'function') { 325 listeners[key] = val; 326 delete json[key]; 327 } 328 }); 329 330 // core plugin methods 331 extend(this, { 332 333 animate: function(props, speed, fn) { 334 if (!props) { 335 return self; 336 } 337 338 if (typeof speed == 'function') { 339 fn = speed; 340 speed = 500; 341 } 342 343 if (typeof props == 'string') { 344 var key = props; 345 props = {}; 346 props[key] = speed; 347 speed = 500; 348 } 349 350 if (fn) { 351 var fnId = makeId();
352 listeners[fnId] = fn; 353 } 354 355 if (speed === undefined) { speed = 500; } 356 json = player._api().fp_animate(name, props, speed, fnId); 357 return self; 358 }, 359 360 css: function(props, val) { 361 if (val !== undefined) { 362 var css = {}; 363 css[props] = val; 364 props = css; 365 } 366 json = player._api().fp_css(name, props); 367 extend(self, json); 368 return self; 369 }, 370 371 show: function() { 372 this.display = 'block'; 373 player._api().fp_showPlugin(name); 374 return self; 375 }, 376 377 hide: function() { 378 this.display = 'none'; 379 player._api().fp_hidePlugin(name); 380 return self; 381 }, 382 383 toggle: function() { 384 this.display = player._api().fp_togglePlugin(name); 385 return self; 386 }, 387 388 fadeTo: function(o, speed, fn) { 389 390 if (typeof speed == 'function') { 391 fn = speed; 392 speed = 500; 393 } 394 395 if (fn) { 396 var fnId = makeId(); 397 listeners[fnId] = fn; 398 } 399 this.display = player._api().fp_fadeTo(name, o, speed, fnId); 400 this.opacity = o; 401 return self; 402 }, 403 404 fadeIn: function(speed, fn) { 405 return self.fadeTo(1, speed, fn); 406 }, 407 408 fadeOut: function(speed, fn) { 409 return self.fadeTo(0, speed, fn); 410 }, 411 412 getName: function() { 413 return name; 414 }, 415 416 417 // internal method not meant to be used by clients 418 _fireEvent: function(evt, arg) { 419 420 // update plugins properties & methods 421 if (evt == 'onUpdate') { 422 var json = 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]; 444 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 }); 457 458 }; 459 460 461//}}} 462 463 464function 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 478 // n'th player on the page 479 playerIndex, 480 481 // active clip's index number 482 activeIndex, 483 484 swfHeight, 485 wrapperHeight; 486 487 488// {{{ public methods 489 490 extend(self, { 491 492 id: function() { 493 return playerId; 494 }, 495 496 isLoaded: function() { 497 return (api !== null); 498 }, 499 500 getParent: function() { 501 return wrapper; 502 }, 503 504 hide: function(all) { 505 if (all) { wrapper.style.height = "0px"; } 506 if (api) { api.style.height = "0px"; } 507 return self; 508 }, 509 510 show: function() { 511 wrapper.style.height = wrapperHeight + "px"; 512 if (api) { api.style.height = swfHeight + "px"; } 513 return self; 514 }, 515 516 isHidden: function() { 517 return api && parseInt(api.style.height, 10) === 0; 518 }, 519 520 521 load: function(fn) { 522 523 if (!api && self._fireEvent("onBeforeLoad") !== false) { 524 525 // unload all instances 526 each(players, function() { 527 this.unload(); 528 }); 529 530 html = wrapper.innerHTML; 531 flashembed(wrapper, params, {config: conf}); 532 533 // function argument 534 if (fn) { 535 fn.cached = true; 536 bind(listeners, "onLoad", fn); 537 } 538 } 539 540 return self; 541 }, 542 543 unload: function() { 544 545 // if player is dead, do nothing 546 try { 547 if (api && api.fp_isFullscreen()) { } 548 } catch (error) { 549 return; 550 } 551 552 553 if (api && html.replace(/\s/g, '') !== '' && !api.fp_isFullscreen() && self._fireEvent("onBeforeUnload") !== false) { 554 api.fp_close(); 555 wrapper.innerHTML = html; 556 self._fireEvent("onUnload"); 557 api = null; 558 } 559 560 return self; 561 }, 562 563 getClip: function(index) { 564 if (index === undefined) { 565 index = activeIndex; 566 } 567 return playlist[index]; 568 }, 569 570 571 getCommonClip: function() { 572 return commonClip; 573 }, 574 575 getPlaylist: function() { 576 return playlist; 577 }, 578 579 getPlugin: function(name) { 580 var plugin = plugins[name]; 581 582 // create plugin if nessessary 583 if (!plugin && self.isLoaded()) { 584 var json = self._api().fp_getPlugin(name); 585 if (json) { 586 plugin = new Plugin(name, json, self); 587 plugins[name] = plugin; 588 } 589 } 590 return plugin; 591 }, 592 593 getScreen: function() { 594 return self.getPlugin("screen"); 595 }, 596 597 getControls: function() {
598 return self.getPlugin("controls"); 599 }, 600 601 getConfig: function(copy) { 602 return copy ? clone(conf) : conf; 603 }, 604 605 getFlashParams: function() { 606 return params; 607 }, 608 609 loadPlugin: function(name, url, props, fn) { 610 611 // properties not supplied 612 if (typeof props == 'function') { 613 fn = props; 614 props = {}; 615 } 616 617 // if fn not given, make a fake id so that plugin's onUpdate get's fired 618 var fnId = fn ? makeId() : "_"; 619 self._api().fp_loadPlugin(name, url, props, fnId); 620 621 // create new plugin 622 var arg = {}; 623 arg[fnId] = fn; 624 var p = new Plugin(name, null, self, arg); 625 plugins[name] = p; 626 return p; 627 }, 628 629 630 getState: function() { 631 return api ? api.fp_getState() : -1; 632 }, 633 634 // "lazy" play 635 play: function(clip) { 636 637 function play() { 638 if (clip !== undefined) { 639 self._api().fp_play(clip); 640 } else { 641 self._api().fp_play(); 642 } 643 } 644 645 if (api) { 646 play(); 647 648 } else { 649 self.load(function() { 650 play(); 651 }); 652 } 653 654 return self; 655 }, 656 657 getVersion: function() { 658 var js = "flowplayer.js 3.0.5"; 659 if (api) { 660 var ver = api.fp_getVersion(); 661 ver.push(js); 662 return ver; 663 } 664 return js; 665 }, 666 667 _api: function() { 668 if (!api) { 669 throw "Flowplayer " +self.id()+ " not loaded. Try moving your call to player's onLoad event"; 670 } 671 return api; 672 }, 673 674 _dump: function() { 675 console.log(listeners); 676 }, 677 678 setClip: function(clip) { 679 self.setPlaylist([clip]); 680 }, 681 682 getIndex: function() { 683 return playerIndex; 684 } 685 686 }); 687 688 689 // event handlers 690 each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","), 691 function() { 692 var name = "on" + this; 693 694 // before event 695 if (name.indexOf("*") != -1) { 696 name = name.substring(0, name.length -1); 697 var name2 = "onBefore" + name.substring(2); 698 self[name2] = function(fn) { 699 bind(listeners, name2, fn); 700 return self; 701 }; 702 } 703 704 // normal event 705 self[name] = function(fn) { 706 bind(listeners, name, fn); 707 return self; 708 }; 709 } 710 ); 711 712 713 // core API methods 714 each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffer
714ing,stopBuffering,isFullscreen,reset,close,setPlaylist").split(","), 715 function() { 716 var name = this; 717 718 self[name] = function(arg) { 719 if (!api) { return self; } 720 var ret = (arg === undefined) ? api["fp_" + name]() : api["fp_" + name](arg); 721 return ret == 'undefined' ? self : ret; 722 }; 723 } 724 ); 725 726//}}} 727 728 729// {{{ public method: _fireEvent 730 731 self._fireEvent = function(evt, arg0, arg1, arg2) { 732 733 if (conf.debug) { 734 log(arguments); 735 } 736 737 // internal onLoad 738 if (!api && evt == 'onLoad' && arg0 == 'player') { 739 740 api = api || el(apiId); 741 swfHeight = api.clientHeight; 742 743 each(playlist, function() { 744 this._fireEvent("onLoad"); 745 }); 746 747 each(plugins, function(name, p) { 748 p._fireEvent("onUpdate"); 749 }); 750 751 commonClip._fireEvent("onLoad"); 752 } 753 754 // other onLoad events are skipped 755 if (evt == 'onLoad' && arg0 != 'player') { return; } 756 757 758 // "normalize" error handling 759 if (evt == 'onError') { 760 if (typeof arg0 == 'string' || (typeof arg0 == 'number' && typeof arg1 == 'number')) { 761 arg0 = arg1; 762 arg1 = arg2; 763 } 764 } 765 766 767 if (evt == 'onContextMenu') { 768 each(conf.contextMenu[arg0], function(key, fn) { 769 fn.call(self); 770 }); 771 return; 772 } 773 774 if (evt == 'onPluginEvent') { 775 var name = arg0.name || arg0; 776 var p = plugins[name]; 777 778 if (p) { 779 p._fireEvent("onUpdate", arg0); 780 p._fireEvent(arg1); 781 } 782 return; 783 } 784 785 // onPlaylistReplace 786 if (evt == 'onPlaylistReplace') { 787 playlist = []; 788 var index = 0; 789 each(arg0, function() { 790 playlist.push(new Clip(this, index++, self)); 791 }); 792 } 793 794 var ret = true; 795 796 // clip event 797 if (typeof arg0 == 'number' && arg0 < playlist.length) { 798 799 activeIndex = arg0; 800 var clip = playlist[arg0]; 801 802 if (clip) { 803 ret = clip._fireEvent(evt, arg1, arg2); 804 } 805 806 if (!clip || ret !== false) { 807 808 // clip argument is given for common clip, because it behaves as the target 809 ret = commonClip._fireEvent(evt, arg1, arg2, clip); 810 } 811 } 812 813 // player event 814 var i = 0; 815 each(listeners[evt], function() { 816 ret = this.call(self, arg0, arg1); 817 818 // remove cached entry 819 if (this.cached) { 820 listeners[evt].splice(i, 1); 821 } 822 823 // break loop 824 if (ret === false) { return false; } 825 i++; 826 827 }); 828 829 return ret; 830 }; 831 832//}}} 833 834 835// {{{ init 836 837 function init() { 838 839 // replace previous installation 840 if ($f(wrapper)) { 841 $f(wrapper).getParent().innerHTML = ""; 842 playerIndex = $f(wrapper).getIndex(); 843 players[playerIndex] = self; 844 845 // register this player into global array of instances 846 } else { 847 players.push(self); 848 playerIndex = players.length -1; 849 } 850 851 wrapperHeight = parseInt(wrapper.style.height, 10) || wrapper.clientHeight; 852 853 // flashembed parameters 854 if (typeof params == 'string') { 855 params = {src: params}; 856 } 857 858 // playerId 859 playerId = wrapper.id || "fp" + makeId(); 860 apiId = params.id || playerId + "_api"; 861 params.id = apiId; 862 conf.playerId = playerId; 863 864 865 // plain url is given as config 866 if (typeof conf == 'string') { 867 conf = {clip:{url:conf}}; 868 } 869 870 if (typeof conf.clip == 'string') { 871 conf.clip = {url: conf.clip}; 872 } 873 874 // common clip is always there 875 conf.clip = conf.clip || {}; 876 877 878 // wrapper href as common clip's url 879 if (wrapper.getAttribute("href", 2) && !conf.clip.url) { 880 conf.clip.url = wrapper.getAttribute("href", 2); 881 } 882 883 commonClip = new Clip(conf.clip, -1, self); 884 885 // playlist 886 conf.playlist = conf.playlist || [conf.clip]; 887 888 var index = 0; 889 each(conf.playlist, function() { 890 891 var clip = this; 892 893 if (typeof clip == 'object' && clip.length) { 894 clip = "" + clip; 895 } 896 897 if (typeof clip == 'string') { 898 clip = {url: clip}; 899 } 900 901 // populate common clip properties to each clip 902 each(conf.clip, function(key, val) { 903 if (conf.clip[key] !== undefined && typeof val != 'function') { 904 clip[key] = val; 905 } 906 }); 907 908 // modify configuration playlist 909 conf.playlist[index] = clip; 910 911 // populate playlist array 912 clip = new Clip(clip, index, self); 913 playlist.push(clip); 914 index++; 915 }); 916 917 918 // event listeners 919 each(conf, function(key, val) { 920 if (typeof val == 'function') { 921 bind(listeners, key, val); 922 delete conf[key]; 923 } 924 }); 925 926 927 // plugins 928 each(conf.plugins, function(name, val) { 929 if (val) { 930 plugins[name] = new Plugin(name, val, self); 931 } 932 }); 933 934 935 // setup controlbar plugin if not explicitly defined 936 if (!conf.plugins || conf.plugins.controls === undefined) {
937 plugins.controls = new Plugin("controls", null, self); 938 } 939 940 // Flowplayer uses black background by default 941 params.bgcolor = params.bgcolor || "#000000"; 942 943 944 // setup default settings for express install 945 params.version = params.version || [9, 0]; 946 params.expressInstall = 'http://www.flowplayer.org/swf/expressinstall.swf'; 947 948 // click function 949 function doClick(e) { 950 if (!self.isLoaded() && self._fireEvent("onBeforeClick") !== false) { 951 self.load(); 952 } 953 return stopEvent(e); 954 } 955 956 // defer loading upon click 957 html = wrapper.innerHTML; 958 if (html.replace(/\s/g, '') !== '') { 959 960 if (wrapper.addEventListener) { 961 wrapper.addEventListener("click", doClick, false); 962 963 } else if (wrapper.attachEvent) { 964 wrapper.attachEvent("onclick", doClick); 965 } 966 967 // player is loaded upon page load 968 } else { 969 970 // prevent default action from wrapper (safari problem) loaded 971 if (wrapper.addEventListener) { 972 wrapper.addEventListener("click", stopEvent, false); 973 } 974 975 // load player 976 self.load(); 977 } 978 979 } 980 981 // possibly defer initialization until DOM get's loaded 982 if (typeof wrapper == 'string') { 983 flashembed.domReady(function() { 984 var node = el(wrapper); 985 986 if (!node) { 987 throw "Flowplayer cannot access element: " + wrapper; 988 } else { 989 wrapper = node; 990 init(); 991 } 992 }); 993 994 // we have a DOM element so page is already loaded 995 } else { 996 init(); 997 } 998 999 1000//}}} 1001 1002 1003} 1004 1005 1006// {{{ flowplayer() & statics 1007 1008// container for player instances 1009var players = []; 1010 1011 1012// this object is returned when multiple player's are requested 1013function Iterator(arr) { 1014 1015 this.length = arr.length; 1016 1017 this.each = function(fn) { 1018 each(arr, fn); 1019 }; 1020 1021 this.size = function() { 1022 return arr.length; 1023 }; 1024} 1025 1026// these two variables are the only global variables 1027window.flowplayer = window.$f = function() { 1028 1029 var instance = null; 1030 var arg = arguments[0]; 1031 1032 // $f() 1033 if (!arguments.length) { 1034 each(players, function() { 1035 if (this.isLoaded()) { 1036 instance = this; 1037 return false; 1038 } 1039 }); 1040 1041 return instance || players[0]; 1042 } 1043 1044 if (arguments.length == 1) { 1045 1046 // $f(index); 1047 if (typeof arg == 'number') { 1048 return players[arg]; 1049 1050 1051 // $f(wrapper || 'containerId' || '*'); 1052 } else { 1053 1054 // $f("*"); 1055 if (arg == '*') { 1056 return new Iterator(players); 1057 } 1058 1059 // $f(wrapper || 'containerId'); 1060 each(players, function() { 1061 if (this.id() == arg.id || this.id() == arg || this.getParent() == arg) { 1062 instance = this; 1063 return false; 1064 } 1065 }); 1066 1067 return instance; 1068 } 1069 } 1070 1071 // instance builder 1072 if (arguments.length > 1) { 1073 1074 var swf = arguments[1]; 1075 var conf = (arguments.length == 3) ? arguments[2] : {}; 1076 1077 if (typeof arg == 'string') { 1078 1079 // select arg by classname 1080 if (arg.indexOf(".") != -1) { 1081 var instances = []; 1082 1083 each(select(arg), function() { 1084 instances.push(new Player(this, clone(swf), clone(conf))); 1085 }); 1086 1087 return new Iterator(instances); 1088 1089 // select node by id 1090 } else {
1091 var node = el(arg); 1092 return new Player(node !== null ? node : arg, swf, conf); 1093 } 1094 1095 1096 // arg is a DOM element 1097 } else if (arg) { 1098 return new Player(arg, swf, conf); 1099 } 1100 1101 } 1102 1103 return null; 1104}; 1105 1106extend(window.$f, { 1107 1108 // called by Flash External Interface 1109 fireEvent: function(id, evt, a0, a1, a2) { 1110 var p = $f(id); 1111 return p ? p._fireEvent(evt, a0, a1, a2) : null; 1112 }, 1113 1114 1115 // create plugins by modifying Player's prototype 1116 addPlugin: function(name, fn) { 1117 Player.prototype[name] = fn; 1118 return $f; 1119 }, 1120 1121 // utility methods for plugin developers 1122 each: each, 1123 1124 extend: extend 1125 1126}); 1127 1128 1129// sometimes IE leaves sockets open 1130if (document.all) { 1131 window.onbeforeunload = function() { 1132 $f("*").each(function() { 1133 if (this.isLoaded()) { 1134 this.close(); 1135 } 1136 }); 1137 }; 1138} 1139 1140 1141 1142//}}} 1143 1144 1145//{{{ jQuery support 1146 1147if (typeof jQuery == 'function') { 1148 1149 jQuery.prototype.flowplayer = function(params, conf) { 1150 1151 // select instances 1152 if (!arguments.length || typeof arguments[0] == 'number') { 1153 var arr = []; 1154 this.each(function() { 1155 var p = $f(this); 1156 if (p) { 1157 arr.push(p); 1158 } 1159 }); 1160 return arguments.length ? arr[arguments[0]] : new Iterator(arr); 1161 } 1162 1163 // create flowplayer instances 1164 return this.each(function() { 1165 $f(this, clone(params), conf ? clone(conf) : {}); 1166 }); 1167 1168 }; 1169 1170} 1171 1172//}}} 1173 1174 1175})(); 1176/** 1177 * flashembed 1.0.0. Adobe Flash embedding script 1178 * 1179 * Copyright (c) 2009 Tero Piirainen 1180 * http://flowplayer.org/tools/flash-embed.html 1181 * 1182 * Dual licensed under MIT and GPL 2+ licenses 1183 * http://www.opensource.org/licenses 1184 * 1185 * Launch : March 2008 1186 * Version : 1.0.0 - Tue Feb 03 2009 10:48:14 GMT-0000 (GMT+00:00) 1187 */ 1188(function() { 1189 1190/* http://code.google.com/p/swfobject/source/browse/tags/swfobject_2_1/src/swfobject.js */ 1191 1192//{{{ utility functions 1193 1194var jQ = typeof jQuery == 'function'; 1195 1196 1197// from "Pro JavaScript techniques" by John Resig 1198function isDomReady() { 1199 1200 if (domReady.done) { return false; } 1201 1202 var d = document; 1203 if (d && d.getElementsByTagName && d.getElementById && d.body) { 1204 clearInterval(domReady.timer); 1205 domReady.timer = null; 1206 1207 for (var i = 0; i < domReady.ready.length; i++) { 1208 domReady.ready[i].call(); 1209 } 1210 1211 domReady.ready = null; 1212 domReady.done = true; 1213 } 1214} 1215 1216// if jQuery is present, use it's more effective domReady method 1217var domReady = jQ ? jQuery : function(f) { 1218 1219 if (domReady.done) { 1220 return f(); 1221 } 1222 1223 if (domReady.timer) { 1224 domReady.ready.push(f); 1225 1226 } else { 1227 domReady.ready = [f]; 1228 domReady.timer = setInterval(isDomReady, 13); 1229 } 1230}; 1231 1232 1233// override extend opts function 1234function extend(to, from) { 1235 if (from) { 1236 for (key in from) { 1237 if (from.hasOwnProperty(key)) { 1238 to[key] = from[key]; 1239 } 1240 } 1241 } 1242 1243 return to; 1244} 1245 1246 1247// JSON.asString() function 1248function asString(obj) { 1249 1250 switch (typeOf(obj)){ 1251 case 'string': 1252 obj = obj.replace(new RegExp('(["\\\\])', 'g'), '\\$1'); 1253 1254 // flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit) 1255 obj = obj.replace(/^\s?(\d+)%/, "$1pct"); 1256 return '"' +obj+ '"'; 1257 1258 case 'array': 1259 return '['+ map(obj, function(el) { 1260 return asString(el); 1261 }).join(',') +']'; 1262 1263 case 'function': 1264 return '"function()"'; 1265 1266 case 'object': 1267 var str = []; 1268 for (var prop in obj) { 1269 if (obj.hasOwnProperty(prop)) { 1270 str.push('"'+prop+'":'+ asString(obj[prop])); 1271 } 1272 } 1273 return '{'+str.join(',')+'}'; 1274 } 1275 1276 // replace ' --> " and remove spaces 1277 return String(obj).replace(/\s/g, " ").replace(/\'/g, "\""); 1278} 1279 1280 1281// private functions 1282function typeOf(obj) { 1283 if (obj === null || obj === undefined) { return false; } 1284 var type = typeof obj; 1285 return (type == 'object' && obj.push) ? 'array' : type; 1286} 1287 1288 1289// version 9 bugfix: (http://blog.deconcept.com/2006/07/28/swfobject-143-released/) 1290if (window.attachEvent) { 1291 window.attachEvent("onbeforeunload", function() { 1292 __flash_unloadHandler = function() {}; 1293 __flash_savedUnloadHandler = function() {}; 1294 }); 1295} 1296 1297function map(arr, func) { 1298 var newArr = []; 1299 for (var i in arr) { 1300 if (arr.hasOwnProperty(i)) { 1301 newArr[i] = func(arr[i]); 1302 } 1303 } 1304 return newArr; 1305} 1306 1307function getHTML(p, c) { 1308 1309 var ie = document.all; 1310 var html = '<object width="' +p.width+ '" height="' +p.height+ '"'; 1311 1312 // force id for IE or Flash API cannot be returned 1313 if (ie && !p.id) { 1314 p.id = "_" + ("" + Math.random()).substring(9); 1315 } 1316 1317 if (p.id) { 1318 html += ' id="' + p.id + '"'; 1319 } 1320 1321 if (p.w3c || !ie) { 1322 html += ' data="' +p.src+ '" type="application/x-shockwave-flash"'; 1323 } else { 1324 html += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; 1325 } 1326 1327 html += '>'; 1328 1329 if (p.w3c || ie) { 1330 html += '<param name="movie" value="' +p.src+ '" />'; 1331 } 1332 1333 // parameters 1334 var e = extend({}, p); 1335 e.width = e.height = e.id = e.w3c = e.src = null; 1336 1337 for (var k in e) { 1338 if (e[k] !== null) { 1339 html += '<param name="'+ k +'" value="'+ e[k] +'" />'; 1340 } 1341 } 1342 1343 // flashvars 1344 var vars = ""; 1345 1346 if (c) { 1347 for (var key in c) { 1348 if (c[key] !== null) { 1349 vars += key +'='+ (typeof c[key] == 'object' ? asString(c[key]) : c[key]) + '&'; 1350 } 1351 } 1352 vars = vars.substring(0, vars.length -1); 1353 html += '<param name="flashvars" value=\'' + vars + '\' />'; 1354 } 1355 1356 html += "</object>"; 1357 1358 return html; 1359 1360} 1361 1362//}}} 1363 1364 1365function Flash(root, opts, flashvars) { 1366 1367 var version = flashembed.getVersion(); 1368 1369 // API methods for callback 1370 extend(this, { 1371 1372 getContainer: function() { 1373 return root; 1374 }, 1375 1376 getConf: function() { 1377 return conf; 1378 }, 1379 1380 getVersion: function() { 1381 return version; 1382 }, 1383 1384 getFlashvars: function() { 1385 return flashvars; 1386 }, 1387 1388 getApi: function() { 1389 return root.firstChild; 1390 }, 1391 1392 getHTML: function() { 1393 return getHTML(opts, flashvars); 1394 } 1395 1396 }); 1397 1398 // variables 1399 var required = opts.version; 1400 var express = opts.expressInstall; 1401 1402 1403 // everything ok -> generate OBJECT tag 1404 var ok = !required || flashembed.isSupported(required); 1405 1406 if (ok) { 1407 opts.onFail = opts.version = opts.expressInstall = null; 1408 root.innerHTML = getHTML(opts, flashvars); 1409 1410 // fail #1. express install 1411 } else if (required && express && flashembed.isSupported([6,65])) { 1412 1413 extend(opts, {src: express}); 1414 1415 flashvars = { 1416 MMredirectURL: location.href, 1417 MMplayerType: 'PlugIn', 1418 MMdoctitle: document.title 1419 }; 1420 1421 root.innerHTML = getHTML(opts, flashvars); 1422 1423 // fail #2. 1424 } else { 1425 1426 // fail #2.1 custom content inside container 1427 if (root.innerHTML.replace(/\s/g, '') !== '') { 1428 // minor bug fixed here 08.04.2008 (thanks JRodman) 1429 1430 1431 // fail #2.2 default content 1432 } else { 1433 root.innerHTML = 1434 "<h2>Flash version " + required + " or greater is required</h2>" + 1435 "<h3>" + 1436 (version[0] > 0 ? "Your version is " + version : "You have no flash plugin installed") + 1437 "</h3>" + 1438 "<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>"; 1439 } 1440 } 1441 1442 // onFail 1443 if (!ok && opts.onFail) { 1444 var ret = opts.onFail.call(this); 1445 if (typeof ret == 'string') { root.innerHTML = ret; } 1446 } 1447 1448} 1449 1450window.flashembed = function(root, conf, flashvars) { 1451
1452//{{{ construction 1453 1454 // root must be found / loaded 1455 if (typeof root == 'string') { 1456 var el = document.getElementById(root); 1457 if (el) { 1458 root = el; 1459 } else { 1460 domReady(function() { 1461 flashembed(root, conf, flashvars); 1462 }); 1463 return; 1464 } 1465 } 1466 1467 // not found 1468 if (!root) { return; } 1469 1470 1471 // setup opts 1472 var opts = { 1473 1474 // very common opts 1475 width: '100%', 1476 height: '100%', 1477 1478 // flashembed defaults 1479 allowfullscreen: true, 1480 allowscriptaccess: 'always', 1481 quality: 'high', 1482 1483 1484 // flashembed specific options 1485 version: null, 1486 onFail: null, 1487 expressInstall: null, 1488 w3c: false 1489 }; 1490 1491 1492 if (typeof conf == 'string') { 1493 conf = {src: conf}; 1494 } 1495 1496 extend(opts, conf); 1497 1498 return new Flash(root, opts, flashvars); 1499 1500//}}} 1501 1502 1503}; 1504 1505 1506//{{{ static methods 1507 1508extend(window.flashembed, { 1509 1510 // returns arr[major, fix] 1511 getVersion: function() { 1512 1513 var version = [0, 0]; 1514 1515 if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") { 1516 var _d = navigator.plugins["Shockwave Flash"].description; 1517 if (typeof _d != "undefined") { 1518 _d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); 1519 var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10); 1520 var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0; 1521 version = [_m, _r]; 1522 } 1523 1524 } else if (window.ActiveXObject) { 1525 1526 try { // avoid fp 6 crashes 1527 var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); 1528 1529 } catch(e) { 1530 try { 1531 _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); 1532 version = [6, 0]; 1533 _a.AllowScriptAccess = "always"; // throws if fp < 6.47 1534 1535 } catch(ee) { 1536 if (version[0] == 6) { return; } 1537 } 1538 try { 1539 _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 1540 } catch(eee) { 1541 1542 } 1543 1544 } 1545 1546 if (typeof _a == "object") { 1547 _d = _a.GetVariable("$version"); // bugs in fp 6.21 / 6.23 1548 if (typeof _d != "undefined") { 1549 _d = _d.replace(/^\S+\s+(.*)$/, "$1").split(","); 1550 version = [parseInt(_d[0], 10), parseInt(_d[2], 10)]; 1551 } 1552 } 1553 } 1554 1555 return version; 1556 }, 1557 1558 isSupported: function(version) { 1559 var now = flashembed.getVersion(); 1560 var ret = (now[0] > version[0]) || (now[0] == version[0] && now[1] >= version[1]); 1561 return ret; 1562 }, 1563 1564 domReady: domReady, 1565 1566 // returns a String representation from JSON object 1567 asString: asString, 1568 1569 1570 getHTML: getHTML 1571 1572}); 1573 1574//}}} 1575 1576 1577// setup jquery support 1578if (jQ) { 1579 1580 jQuery.prototype.flashembed = function(conf, flashvars) { 1581 return this.each(function() { 1582 flashembed(this, conf, flashvars); 1583 }); 1584 }; 1585 1586} 1587 1588})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.