123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- define("dojox/av/_Media", ['dojo'],function(dojo){
- dojo.experimental("dojox.av.FLVideo");
- return dojo.declare("dojox.av._Media", null, {
-
-
-
-
-
-
- mediaUrl:"",
-
-
-
- initialVolume:1,
-
-
-
- autoPlay: false,
-
-
-
-
-
-
- bufferTime: 2000,
-
-
-
-
-
-
- minBufferTime:300,
-
-
-
- updateTime: 100,
-
-
-
- id:"",
-
-
-
- isDebug: false,
-
-
-
- percentDownloaded:0,
-
-
-
- _flashObject:null,
-
-
-
- flashMedia:null,
-
-
-
- allowScriptAccess:"always",
-
-
-
- allowNetworking: "all",
-
-
-
- wmode: "transparent",
-
-
-
- allowFullScreen:true,
-
- _initStatus: function(){
-
-
-
- this.status = "ready";
- this._positionHandle = dojo.connect(this, "onPosition", this, "_figureStatus");
-
- },
-
-
-
-
-
- getTime: function(){
-
-
-
-
-
-
- return this.flashMedia.getTime();
- },
-
-
-
-
-
- onLoad: function(/* SWF */ mov){
-
-
-
-
- },
-
- onDownloaded: function(/* Number */percent){
-
-
-
- },
-
- onClick: function(/* Object */ evt){
-
-
-
-
-
-
- },
-
- onSwfSized: function(/* Object */ data){
-
-
-
- },
-
- onMetaData: function(/* Object */ data, /* Object */ evt){
-
-
-
-
-
-
-
- console.warn("onMeta", data)
- this.duration = data.duration;
- },
-
- onPosition: function(/* Float */ time){
-
-
- },
-
- onStart: function(/* Object */ data){
-
-
-
-
- },
-
- onPlay: function(/* Object */ data){
-
-
- },
-
- onPause: function(/* Object */ data){
-
-
- },
-
- onEnd: function(/* Object */ data){
-
-
-
-
- },
-
- onStop: function(){
-
-
-
-
- },
-
- onBuffer: function(/* Boolean */ isBuffering){
-
-
-
-
- this.isBuffering = isBuffering;
- },
-
- onError: function(/* Object */ data, /* String */ url){
-
-
-
-
-
- console.warn("ERROR-"+data.type.toUpperCase()+":", data.info.code, " - URL:", url);
- },
-
- onStatus: function(/* Object */data){
-
-
- },
-
- onPlayerStatus: function(/* Object */data){
-
-
-
- },
-
- onResize: function(){
-
- },
-
- _figureStatus: function(){
-
-
-
-
-
-
- var pos = this.getTime();
-
-
- if(this.status=="stopping"){
-
- this.status = "stopped";
- this.onStop(this._eventFactory());
-
- }else if(this.status=="ending" && pos==this._prevPos){
- this.status = "ended";
- this.onEnd(this._eventFactory());
-
- }else if(this.duration && pos>this.duration-.5){
- this.status="ending"
-
- }else if(pos===0 ){
- if(this.status == "ready"){
-
- }else{
-
- this.status = "stopped";
- if(this._prevStatus != "stopped"){
- this.onStop(this._eventFactory());
- }
- }
-
- }else{
-
- if(this.status == "ready"){
-
- this.status = "started";
- this.onStart(this._eventFactory());
- this.onPlay(this._eventFactory());
-
- }else if(this.isBuffering){
- this.status = "buffering";
-
- }else if(this.status == "started" || (this.status == "playing" && pos != this._prevPos)){
- this.status = "playing";
-
-
- }else if(!this.isStopped && this.status == "playing" && pos == this._prevPos){
- this.status = "paused";
- console.warn("pause", pos, this._prevPos)
- if(this.status != this._prevStatus){
- this.onPause(this._eventFactory());
- }
-
- }else if((this.status == "paused" ||this.status == "stopped") && pos != this._prevPos){
- this.status = "started";
- this.onPlay(this._eventFactory());
- }
- }
-
- this._prevPos = pos;
- this._prevStatus = this.status;
- this.onStatus(this.status);
-
-
- },
-
- _eventFactory: function(){
-
-
-
- var evt = {
-
-
-
- status:this.status
- }
- return evt;
- },
-
-
-
- _sub: function(topic, method){
-
-
- dojo.subscribe(this.id+"/"+topic, this, method);
- },
-
- _normalizeVolume: function(vol){
-
-
-
- if(vol>1){
- while(vol>1){
- vol*=.1
- }
- }
- return vol;
- },
-
- _normalizeUrl: function(_url){
-
-
-
-
-
- console.log(" url:", _url);
-
- if(_url && (_url.toLowerCase().indexOf("http")<0 || _url.indexOf("/") == 0)){
-
-
-
- var loc = window.location.href.split("/");
- loc.pop();
-
- loc = loc.join("/")+"/";
- console.log(" loc:", loc);
- _url = loc+_url;
- }
- return _url;
- },
-
- destroy: function(){
-
-
- if(!this.flashMedia){
- this._cons.push(dojo.connect(this, "onLoad", this, "destroy"));
- return;
- }
- dojo.forEach(this._subs, function(s){
- dojo.unsubscribe(s);
- });
- dojo.forEach(this._cons, function(c){
- dojo.disconnect(c);
- });
- this._flashObject.destroy();
-
-
- }
- });
- });
|