root / trunk / web / dojo / dojox / av / FLVideo.js @ 12
History | View | Annotate | Download (2.98 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.av.FLVideo"]){ |
9 |
dojo._hasResource["dojox.av.FLVideo"]=true; |
10 |
dojo.provide("dojox.av.FLVideo");
|
11 |
dojo.experimental("dojox.av.FLVideo");
|
12 |
dojo.require("dijit._Widget");
|
13 |
dojo.require("dojox.embed.Flash");
|
14 |
dojo.require("dojox.av._Media");
|
15 |
dojo.declare("dojox.av.FLVideo",[dijit._Widget,dojox.av._Media],{_swfPath:dojo.moduleUrl("dojox.av","resources/video.swf"),constructor:function(_1){ |
16 |
dojo.global.swfIsInHTML=function(){ |
17 |
return true; |
18 |
}; |
19 |
},postCreate:function(){ |
20 |
this._subs=[];
|
21 |
this._cons=[];
|
22 |
this.mediaUrl=this._normalizeUrl(this.mediaUrl); |
23 |
this.initialVolume=this._normalizeVolume(this.initialVolume); |
24 |
var _2={path:this._swfPath.uri,width:"100%",height:"100%",minimumVersion:9,expressInstall:true,params:{allowFullScreen:true,wmode:"transparent"},vars:{videoUrl:this.mediaUrl,id:this.id,autoPlay:this.autoPlay,volume:this.initialVolume,isDebug:this.isDebug}}; |
25 |
this._sub("stageClick","onClick"); |
26 |
this._sub("stageSized","onSwfSized"); |
27 |
this._sub("mediaStatus","onPlayerStatus"); |
28 |
this._sub("mediaMeta","onMetaData"); |
29 |
this._sub("mediaError","onError"); |
30 |
this._sub("mediaStart","onStart"); |
31 |
this._sub("mediaEnd","onEnd"); |
32 |
this._flashObject=new dojox.embed.Flash(_2,this.domNode); |
33 |
this._flashObject.onError=function(_3){ |
34 |
console.error("Flash Error:",_3);
|
35 |
}; |
36 |
this._flashObject.onLoad=dojo.hitch(this,function(_4){ |
37 |
this.flashMedia=_4;
|
38 |
this.isPlaying=this.autoPlay; |
39 |
this.isStopped=!this.autoPlay; |
40 |
this.onLoad(this.flashMedia); |
41 |
this._initStatus();
|
42 |
this._update();
|
43 |
}); |
44 |
this.inherited(arguments); |
45 |
},play:function(_5){ |
46 |
this.isPlaying=true; |
47 |
this.isStopped=false; |
48 |
this.flashMedia.doPlay(this._normalizeUrl(_5)); |
49 |
},pause:function(){ |
50 |
this.isPlaying=false; |
51 |
this.isStopped=false; |
52 |
this.flashMedia.pause();
|
53 |
},seek:function(_6){ |
54 |
this.flashMedia.seek(_6);
|
55 |
},volume:function(_7){ |
56 |
if(_7){
|
57 |
if(!this.flashMedia){ |
58 |
this.initialVolume=_7;
|
59 |
} |
60 |
this.flashMedia.setVolume(this._normalizeVolume(_7)); |
61 |
} |
62 |
if(!this.flashMedia||!this.flashMedia.doGetVolume){ |
63 |
return this.initialVolume; |
64 |
} |
65 |
return this.flashMedia.getVolume(); |
66 |
},_checkBuffer:function(_8,_9){ |
67 |
if(this.percentDownloaded==100){ |
68 |
if(this.isBuffering){ |
69 |
this.onBuffer(false); |
70 |
this.flashMedia.doPlay();
|
71 |
} |
72 |
return;
|
73 |
} |
74 |
if(!this.isBuffering&&_9<0.1){ |
75 |
this.onBuffer(true); |
76 |
this.flashMedia.pause();
|
77 |
return;
|
78 |
} |
79 |
var _a=this.percentDownloaded*0.01*this.duration; |
80 |
if(!this.isBuffering&&_8+this.minBufferTime*0.001>_a){ |
81 |
this.onBuffer(true); |
82 |
this.flashMedia.pause();
|
83 |
}else{
|
84 |
if(this.isBuffering&&_8+this.bufferTime*0.001<=_a){ |
85 |
this.onBuffer(false); |
86 |
this.flashMedia.doPlay();
|
87 |
} |
88 |
} |
89 |
},_update:function(){ |
90 |
var _b=Math.min(this.getTime()||0,this.duration); |
91 |
var _c=this.flashMedia.getLoaded(); |
92 |
this.percentDownloaded=Math.ceil(_c.bytesLoaded/_c.bytesTotal*100); |
93 |
this.onDownloaded(this.percentDownloaded); |
94 |
this.onPosition(_b);
|
95 |
if(this.duration){ |
96 |
this._checkBuffer(_b,_c.buffer);
|
97 |
} |
98 |
setTimeout(dojo.hitch(this,"_update"),this.updateTime); |
99 |
}}); |
100 |
} |