var Player = Class.create(JSControl, { initialize: function($super, altElementID, params){ $super(altElementID); this.src_ = params.url; this.subclass = params.subclass.toLowerCase(); // this.is_flash = !Object.isFunction(this.element.canPlayType); this.is_flash = true; if (this.is_flash){ var swfParams; if (this.subclass == "audio") swfParams = {"width": "500", "height": "55", "swfURL": "/flash/PlayerAudio.swf"}; if (this.subclass == "streaming-video") swfParams = {"width": "320", "height": "240", "swfURL": "/flash/VideoStream.swf"} //var swfParams = Object.clone(Player.defaults[this.subclass]); if (!swfobject.hasFlashPlayerVersion(Player.defaults.version)){ swfParams.width = Math.max(swfParams.width, 310); swfParams.height = Math.max(swfParams.height, 137); } var objectParams = {"allowNetworking": "all", "wmode": "opaque"}; if (this.subclass == "video") objectParams["allowFullScreen"] = "true"; swfobject.embedSWF(swfParams.swfURL, altElementID, swfParams.width, swfParams.height, Player.defaults.version, Player.defaults["expressInstall"], {"id": this.ID()}, objectParams, {}, this.onEmbedded.bind(this)); this.swfObjectName = altElementID; } }, onEmbedded: function(event){ if (!event.success) return void LogE("Failed to embed object " + event.id); this.element = this.ref = event.ref; this.ref.setAttribute("id", this.ID()); this.ref.JSControl = this; }, Value: function(){ return this.src_ || ""; }, getSWFObject: function(){ return window[this.swfObjectName] || document[this.swfObjectName]; }, flashSetValue: function(url){ var swfobject = this.getSWFObject(); if (swfobject && Object.isFunction(swfobject.SetURL)) swfobject.SetURL(url); }, SetValue: function(url){ if (this.src_ == url) return; this.src_ = url; if (this.is_flash){ if (this.flash_ready_) this.flashSetValue(this.src_); }else this.element.setAttribute("src", url); }, FlashReady: function(){ this.flash_ready_ = true; var swfobject = this.getSWFObject(); if (swfobject && swfobject.SetAttribute){ swfobject.SetAttribute("sid", JSControl.GetSID()); if (this.attrs_){ for (var key in this.attrs_) swfobject.SetAttribute(key, this.attrs_[key]); delete this.attrs_; } } if (this.src_) this.flashSetValue(this.src_); }, SetAttribute: function($super, nam, val){ switch (nam){ case "src": return this.SetValue(val); case "width": case "height": var swfobject = this.getSWFObject(); if (swfobject) swfobject.setAttribute(nam, val); break; case "zoom": case "deblocking": if (this.flash_ready_){ var swfobject = this.getSWFObject(); if (!swfobject) LogE("Player: swfobject is NULL"); else if (swfobject.SetAttribute) swfobject.SetAttribute(nam, val); else LogE("Player: swfobject.SetAttribute is NULL"); }else if (this.is_flash){ if (typeof this.attrs_ == "undefined") this.attrs_ = {}; this.attrs_[nam] = val; } break; default: return $super(nam, val); } } }); Player.defaults = { "version": "9", "audio": {"width": "500", "height": "55", "swfURL": "/flash/PlayerAudio.swf"}, "streaming-video": {"width": "320", "height": "240", "swfURL": "/flash/VideoStream.swf"}, "expressInstall": "/flash/expressInstall.swf" };