var TakePhoto = Class.create(JSControl, { initialize: function($super, altElementID, localid, params){ $super(altElementID); this.localid = localid; if (params.src) this.sendurl = params.src; if (!this.sendurl.startsWith('http')) { this.sendurl = location.protocol + '//' + location.host + this.sendurl; } var flashvars = {"sendurl": this.sendurl}; var swfParams = {"width": "311", "height": "504", "swfURL": "/flash/take_picture.swf"}; var objectParams = {"allowNetworking": "all", "wmode": "window", "allowFullScreen": "true", "allowScriptAccess": "always", "scale": "noscale"}; swfobject.embedSWF(swfParams.swfURL, altElementID, swfParams.width, swfParams.height, Player.defaults.version, Player.defaults["expressInstall"], flashvars, 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.setAttribute("localid", this.localid); this.ref.JSControl = this; }, Value: function(){ return this.rtmpServer + this.videoURL || ""; }, isSourceChange:function (rtmp, url) { if (rtmp == this.rtmpServer && url == this.videoURL) return false; return true; }, getSWFObject: function(){ return window[this.swfObjectName] || document[this.swfObjectName]; }, flashUpdateValue: function(){ var swfobject = this.getSWFObject(); if (swfobject && Object.isFunction(swfobject.SetURL)) swfobject.SetURL(this.rtmpServer, this.videoURL, this.fromSeconds); }, getNumberValue:function (num) { if (num.oValue_ == undefined) return undefined; if (num.oValue_.value_ == undefined) return num.oValue_; return num.oValue_.value_; }, SetValue: function(value){ var rtmp = value["RTMPServer"]; var url = value["VideoURL"]; var sec = value["FromSecond"]; if (rtmp == undefined || url == undefined) return; if (this.isSourceChange(rtmp, url)) { this.rtmpServer = rtmp.Value(); this.videoURL = url.Value(); var s = this.getNumberValue(sec); if (s == undefined) this.fromSeconds = 0; else this.fromSeconds = ((s > 0) ? s : 0); if (this.flash_ready_) this.flashUpdateValue(); } }, FlashReady: function(){ this.flash_ready_ = true; var swfobject = this.getSWFObject(); if (swfobject && swfobject.SetAttribute){ swfobject.SetAttribute("sid", JSControl.GetSID()); if (this.autoplay) swfobject.SetAttribute("autoplay", this.autoplay); } if (this.rtmpServer && this.videoURL) this.flashUpdateValue(); }, SetAttribute: function($super, nam, val){ switch (nam){ /*case "width": case "height":*/ case "autoplay": var swfobject = this.getSWFObject(); if (swfobject && Object.isFunction(swfobject.SetAttribute)) swfobject.SetAttribute(nam, val); break; default: return $super(nam, val); } }, CompleteVideo: function(){ //alert("CompleteVideo"); var evData={}; var evArgs={}; evArgs["RTMPServer"]=this.rtmpServer; evArgs["VideoURL"]=this.videoURL; evData["args"]=evArgs; new AEvent("VIDEOCOMPLETE", evData, this); }, }); Player.defaults = { "version": "9", "expressInstall": "/flash/expressInstall.swf" };