123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- if(!dojo._hasResource["dojox.av.FLVideo"]){
- dojo._hasResource["dojox.av.FLVideo"] = true;
- dojo.provide("dojox.av.FLVideo");
- dojo.experimental("dojox.av.FLVideo");
- dojo.require("dijit._Widget");
- dojo.require("dojox.embed.Flash");
- dojo.require("dojox.av._Media");
- dojo.declare("dojox.av.FLVideo", [dijit._Widget, dojox.av._Media], {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- _swfPath: dojo.moduleUrl("dojox.av", "resources/video.swf"),
-
-
- constructor: function(/*Object*/options){
-
-
- dojo.global.swfIsInHTML = function(){ return true; }
- },
- postCreate: function(){
-
-
-
-
- this._subs = [];
- this._cons = [];
- this.mediaUrl = this._normalizeUrl(this.mediaUrl);
- this.initialVolume = this._normalizeVolume(this.initialVolume);
- var args = {
- path:this._swfPath.uri,
- width:"100%",
- height:"100%",
- minimumVersion:9,
- expressInstall:true,
- params:{
- allowFullScreen: this.allowFullScreen,
- wmode:this.wmode,
- allowScriptAccess:this.allowScriptAccess,
- allowNetworking:this.allowNetworking
- },
-
- vars:{
- videoUrl:this.mediaUrl,
- id:this.id,
- autoPlay:this.autoPlay,
- volume:this.initialVolume,
- isDebug:this.isDebug
- }
- };
-
-
- this._sub("stageClick", "onClick");
- this._sub("stageSized", "onSwfSized");
- this._sub("mediaStatus", "onPlayerStatus");
- this._sub("mediaMeta", "onMetaData");
- this._sub("mediaError", "onError");
- this._sub("mediaStart", "onStart");
- this._sub("mediaEnd", "onEnd");
- this._flashObject = new dojox.embed.Flash(args, this.domNode);
- this._flashObject.onError = function(err){
- console.error("Flash Error:", err);
- };
- this._flashObject.onLoad = dojo.hitch(this, function(mov){
- this.flashMedia = mov;
- this.isPlaying = this.autoPlay;
- this.isStopped = !this.autoPlay;
- this.onLoad(this.flashMedia);
- this._initStatus();
- this._update();
- });
- this.inherited(arguments);
- },
-
-
-
- play: function(/* String? */newUrl){
-
-
- this.isPlaying = true;
- this.isStopped = false;
- this.flashMedia.doPlay(this._normalizeUrl(newUrl));
- },
- pause: function(){
-
-
- this.isPlaying = false;
- this.isStopped = false;
- if(this.onPaused){
- this.onPaused();
- }
- this.flashMedia.pause();
- },
- seek: function(/* Float */ time ){
-
-
- this.flashMedia.seek(time);
- },
-
-
-
- volume: function(/* Float */ vol){
-
-
-
-
- if(vol){
- if(!this.flashMedia) {
- this.initialVolume = vol;
- }
- this.flashMedia.setVolume(this._normalizeVolume(vol));
- }
- if(!this.flashMedia || !this.flashMedia.doGetVolume) {
- return this.initialVolume;
- }
- return this.flashMedia.getVolume();
- },
-
-
-
-
-
-
-
- _checkBuffer: function(/* Float */time, /* Float */bufferLength){
-
-
-
-
-
-
- if(this.percentDownloaded == 100){
- if(this.isBuffering){
- this.onBuffer(false);
- this.flashMedia.doPlay();
- }
- return;
- }
- if(!this.isBuffering && bufferLength<.1){
- this.onBuffer(true);
- this.flashMedia.pause();
- return;
- }
- var timePercentLoad = this.percentDownloaded*.01*this.duration;
-
- if(!this.isBuffering && time+this.minBufferTime*.001>timePercentLoad){
- this.onBuffer(true);
- this.flashMedia.pause();
-
- }else if(this.isBuffering && time+this.bufferTime*.001<=timePercentLoad){
- this.onBuffer(false);
- this.flashMedia.doPlay();
- }
- },
- _update: function(){
-
-
-
- var time = Math.min(this.getTime() || 0, this.duration);
- var dObj = this.flashMedia.getLoaded();
- this.percentDownloaded = Math.ceil(dObj.bytesLoaded/dObj.bytesTotal*100);
- this.onDownloaded(this.percentDownloaded);
- this.onPosition(time);
- if(this.duration){
- this._checkBuffer(time, dObj.buffer);
- }
-
- this._updateHandle = setTimeout(dojo.hitch(this, "_update"), this.updateTime);
- },
- destroy: function(){
- clearTimeout(this._updateHandle);
- dojo.disconnect(this._positionHandle);
- this.inherited(arguments);
- }
- });
- }
|