# HG changeset patch # User cavaliet # Date 1336745055 -7200 # Node ID 1139ce4af5f547f06a157f3ca5e6b58aeaa4145d # Parent c96c64fc1a6bb45b20bdfcdc66f1d8dfd2993668 enable seekto in bab diff -r c96c64fc1a6b -r 1139ce4af5f5 assets/player_bab_ldt/bab/player/FlvPlayer.as --- a/assets/player_bab_ldt/bab/player/FlvPlayer.as Fri May 11 15:36:22 2012 +0200 +++ b/assets/player_bab_ldt/bab/player/FlvPlayer.as Fri May 11 16:04:15 2012 +0200 @@ -1,1 +1,1 @@ -package bab.player { import fl.video.MetadataEvent; import fl.video.SoundEvent; import fl.video.VideoEvent; import fl.video.VideoScaleMode; import fl.video.VideoState; import flash.display.Graphics; import flash.display.Loader; import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.net.URLRequest; import flash.text.StyleSheet; import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFormatAlign; import flash.utils.Timer; import fl.controls.ProgressBar; import bab.player.events.EditEvent; import flash.utils.getTimer; public class FlvPlayer extends Sprite { private var wMin:Number = 550; private var hMin:Number = 400; public var flvPB:FLVPlaybackLDT; private var widthFlv:uint; private var heightFlv:uint; private var uic:Sprite; private var loading:TextField; private var tcLabel:TextField; private var metas:Array = new Array(); private var curRatio:Number; private var savePlay:Boolean = false; public var editSkin:EditSkin; //private var babAr:Array; private var curInst:int = -1; private var babRunning:Boolean = false; private var babRunningTimer:Timer; public var babSkin:MovieClip; private var babRatio:Number = 1.25; private var editList:Array; private var mediaList:Array; private var instanceToPlay:uint = 0; private var imageLayer:MovieClip; private var pictAr:Array; private var nbPictLoaded:uint; private var mcContainer:Sprite; private var bgMcCtn:Sprite; private var textLayer:TextField; private var styles:StyleSheet; private var tf:TextFormat; private var pb:ProgressBar; private var caption:FLVPlaybackCaptioningLDT; private var fullScreenOn:Boolean = false; public var writeTC:Boolean = true; private var YTPlayer:ExternalPlayer; private var currentTcBab:Number; private var debugText:TextField; private var lastReSeek:uint = getTimer(); private var lastVolume:Number = 1; private var tcToReach:Number = 0; public function FlvPlayer(wInit:Number=550, hInit:Number=400, urlSkin:String="", debug:TextField=null) { super(); wMin = wInit; hMin = hInit; debugText = debug; // Container for text layer, image layer and flvPB uic = new Sprite(); addChild(uic); // Background container mcContainer = new Sprite(); mcContainer.visible = false; uic.addChild(mcContainer); bgMcCtn = new Sprite(); bgMcCtn.graphics.beginFill(0x770000); bgMcCtn.graphics.drawRect(0,0,wMin,hMin); bgMcCtn.graphics.endFill(); mcContainer.addChild(bgMcCtn); // Text layer textLayer = new TextField(); textLayer.width = wMin; tf = new TextFormat("Verdana",12,0xFFFFFF); tf.align = TextFormatAlign.CENTER; textLayer.wordWrap = true; textLayer.visible = false; mcContainer.addChild(textLayer); // Flv playback component flvPB = new FLVPlaybackLDT(); uic.addChild(flvPB); flvPB.autoPlay = false; flvPB.fullScreenTakeOver = false; flvPB.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; //flvPB.skin = urlSkin + "SkinUnderPlaySeekMuteVol.swf"; // urlSkin finishes with a "/" //flvPB.skinBackgroundColor = 0xCCCCCC; flvPB.addEventListener(MetadataEvent.METADATA_RECEIVED, onMDReceived); flvPB.addEventListener(VideoEvent.PLAYHEAD_UPDATE, onPlayheadUpdate); flvPB.addEventListener(VideoEvent.READY, onReady); flvPB.addEventListener(VideoEvent.SEEKED, onSeeked); flvPB.addEventListener(VideoEvent.STATE_CHANGE, onStateChange); caption = new FLVPlaybackCaptioningLDT(); uic.addChild(caption); if(urlSkin!=null && urlSkin!=""){ var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, placeBabSkin); loader.load(new URLRequest(urlSkin)); uic.addChild(loader); tcLabel = new TextField(); tcLabel.text = "[00:00:00]"; tcLabel.textColor = 0xFFFFFF; tcLabel.x = 120; this.addChild(tcLabel); } imageLayer = new MovieClip(); this.addChild(imageLayer); loading = new TextField(); loading.text = "Loading..."; loading.textColor = 0x0000FF; loading.visible = false; loading.mouseEnabled = false; //loading.styleSheet.setStyle("horizontalCenter",0); this.addChild(loading); pb = new ProgressBar(); pb.visible = false; addChild(pb); } // // On creation complete // private function placeBabSkin(e:Event=null):void { babSkin = e.target.content; //trace("babSkin 2 = " + babSkin.play_mc + ", " + babSkin.pause_mc + ", " + babSkin.back_mc + ", " + babSkin.forward_mc + ", " + babSkin.volumeBarHandle_mc + ", " + babSkin.volumeBar_mc); babSkin.y = heightFlv; babSkin.getChildAt(0).width = widthFlv; babSkin.visible = false; editSkin = new EditSkin(this); editSkin.addEventListener(EditEvent.EDIT_PLAYPAUSE, onEditPlayPause); editSkin.addEventListener(EditEvent.EDIT_BACK, onEditBack); editSkin.addEventListener(EditEvent.EDIT_FORWARD, onEditForward); editSkin.addEventListener(EditEvent.EDIT_SOUNDUPDATE, onEditVolumeUpdate); // usefull to notice edit skin has been loaded. dispatchEvent(new Event(EditEvent.EDIT_CHANGEINSTRUCTION)); } // // load media function // public function loadMedia(path:String, live:Boolean=false, paramPlay:Boolean=false, firstST:String="", extrasAr:Array=null):void{ //trace("loadMedia " + path); stopBab(); // First, we check if the url to load is a Youtube url if(path.search("youtube.com")>-1 || path.search("dailymotion.com")>-1){ pause(); // A valid youtube url is like : http://www.youtube.com/watch?v=PgEu923nxSE or http://www.youtube.com/v/PgEu923nxSE if(YTPlayer==null){ YTPlayer = new ExternalPlayer(uic, path); YTPlayer.addEventListener(VideoEvent.PLAYHEAD_UPDATE, onPlayheadUpdate); YTPlayer.addEventListener(VideoEvent.READY, initSizes); } else YTPlayer.loadVideo(path); curRatio = ExternalPlayer.EXTERNALPLAYER_RATIO; //initSizes(); YTPlayer.visible = true; flvPB.visible = false; } else{ if(YTPlayer!=null) YTPlayer.visible = false; flvPB.visible = true; // We check if the media is already loaded var nbMedias:uint = metas.length; var vp:Number = getVp(path); lastVolume = flvPB.volume; // We stop the current reading if possible if(nbMedias>0 && allowFlvPB()) { flvPB.stop(); } // We load the new content or play the already loaded content if(isNaN(vp)){ vp = metas.length; // We activate the good video player index flvPB.activeVideoPlayerIndex = flvPB.visibleVideoPlayerIndex = vp; flvPB.smoothing = true; //trace("je load " + vp + ", " + path); metas.push({path:path, w:3, h:1, ratio:3}); curRatio = metas[vp].ratio; savePlay = paramPlay; if(live==true){ savePlay = true; flvPB.play(path, NaN, true); } else flvPB.load(path); // Then the window will be resized on metadata received //trace("LoadMedia flvPB.volume : " + flvPB.volume); // sets the volume to 0 (to avoid a bug) then sets it back to its previous level flvPB.volume = 0; flvPB.volume = lastVolume; } else{ // We activate the good video player index flvPB.activeVideoPlayerIndex = flvPB.visibleVideoPlayerIndex = vp; flvPB.smoothing = true; //trace("vp = " + flvPB.activeVideoPlayerIndex + ", " + flvPB.isLive); //trace("je play " + vp + ", " + path); if(allowFlvPB()){ savePlay==false ? flvPB.pause() : flvPB.play(); } // sets the volume to 0 (to avoid a bug) then sets it back to its previous level flvPB.volume = 0; flvPB.volume = lastVolume; // We have to resize the window curRatio = metas[vp].ratio; initSizes(); } // If a subtitle path is indicated we display it var ext:String = firstST.toLowerCase().substr(firstST.length-3); if(ext=="xml"){ caption.source = firstST; } else if(ext=="srt"){ caption.loadSrt(firstST); } // We set the caption/subtitles module to the good videoPlayerIndex index caption.videoPlayerIndex = vp; } } private function getVp(path:String):Number{ // We check if the media is already loaded var i:uint = 0; var nbMedias:uint = metas.length; var vp:Number = NaN; while(i=editList[curInst].tOut && e.state=="playing"){ playBabInst(curInst+1); } //var tcBab:Number; if(mediaList[editList[curInst].m].type=="v"){ trace(editList[curInst].eIn + ", " + e.playheadTime + ", " + editList[curInst].tIn + ", diff = " + (editList[curInst].tIn - e.playheadTime) + ", last>1 = " + ((getTimer() - lastReSeek)>1000)); // If the current playheadTime is inferior to editList[curInst].tIn more than 3 seconds, we reseek to the tIn. // And we avoid too many seek by waiting 1 sec at least. if((editList[curInst].tIn - e.playheadTime)>3 && (getTimer() - lastReSeek)>1000){ //debugText.text = "HIDE and RESEEK"; if(allowFlvPB()) flvPB.seek(editList[curInst].tIn); lastReSeek = getTimer(); flvPB.visible = false; flvPB.volume = 0; loading.visible = true; } else{ if((getTimer() - lastReSeek)>1000){ //debugText.text = "SEEK OK"; flvPB.visible = true; flvPB.volume = lastVolume; } // We apply max : because of the playhead's approximation, e.playheadTime can be inferior to tIn currentTcBab = Math.max(editList[curInst].eIn*1000,(editList[curInst].eIn + e.playheadTime - editList[curInst].tIn)*1000); //currentTcBab = tcBab; if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; this.dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); } } else if(mediaList[editList[curInst].m].type=="p" || mediaList[editList[curInst].m].type=="t"){ currentTcBab = (editList[curInst].eIn)*1000; if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; this.dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); } } } // // Set the good sizes function of the ratio // public function initSizes(e:VideoEvent=null):void{ // We set hMin and wMin for the video to take the maximum of space. wMax = 415, hMax = 310 /*if((Math.round(424/curRatio)+24+37)>310){ hMin = 310; wMin = (310-24-37)*curRatio; } else{ wMin = 415; hMin = Math.round(wMin/curRatio) + 24 + 37; } if(width-1){ flvPB.setSize(widthFlv,heightFlv); flvPB.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; if(babSkin!=null){ babSkin.y = heightFlv - 3; babSkin.getChildAt(0).width = widthFlv; } var nbChilds:uint = imageLayer.numChildren; for(var i:uint=0;i0 && editListPar.length>0){ instanceToPlay = 0; curInst = -1; // We don't display the different layers textLayer.visible = false; mcContainer.visible = false; imageLayer.visible = false; flvPB.visible = false; // We search for every media var i:uint; editList = editListPar; mediaList = mediaListPar; var nbMedias:uint = mediaList.length; var nbLoaded:uint = metas.length; var canStart:Boolean = true; var a:Array = new Array(); for(i=0;i0){ // We prepare pictAr for(i=0;i0 && allowFlvPB()){ flvPB.pause(); } //displayPict( ((mediaList[editList[curInst].m].content.substr(0,9)=="_resource") ? Global.projPath : "") + mediaList[editList[curInst].m].content); displayPict(mediaList[editList[curInst].m].content); imageLayer.y = 0; babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (babAr[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } else if(mediaList[editList[curInst].m].type=="t"){ // Text case textLayer.visible = true; mcContainer.visible = true; drawBgCtn(mediaList[editList[curInst].m].color); imageLayer.visible = false; flvPB.visible = false; if(metas.length>0 && allowFlvPB()){ flvPB.pause(); } textLayer.htmlText = mediaList[editList[curInst].m].content; // If the color is clear the text will be black, if the color is dark the text will be white. tf.color = (RGB2L(mediaList[editList[curInst].m].color)>(255*3/2)) ? 0x000000 : 0xFFFFFF; textLayer.setTextFormat(tf); textLayer.height = Math.floor(textLayer.textHeight) + 10; textLayer.y = ((hMin-37-37)/2) - (textLayer.textHeight/2); if(babRunningTimer!=null){ if(babRunningTimer.running==true){ babRunningTimer.stop(); } } babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (babAr[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } //if(Global.flv2==name) trace(name + " playBabInst textLayer = " + textLayer.visible + ", mcContainer = " + mcContainer.visible + ", imageLayer = " + imageLayer.visible + ", flvPB = " + flvPB.visible); //trace("4* tcBab = " + (editList[curInst].eIn*1000)); currentTcBab = editList[curInst].eIn * 1000; dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; } // Else we run the current segment from the beginning else if(curInst==i){ babRunning = true; if(babRunningTimer!=null){ if(babRunningTimer.running==true){ babRunningTimer.stop(); } } //if(Global.flv2==name) trace(name + " 2 type m = " + mediaList[editList[curInst].m].type); //trace("m " + mediaList[editList[curInst].m].type + ", c = " + mediaList[editList[curInst].m].content + ", col = " + mediaList[editList[curInst].m].color); if(mediaList[editList[curInst].m].type=="v"){ savePlay = paramPlay; //if(Global.flv2==name) trace(name + " 2 vp = " + vp); if(allowFlvPB()){ // If the video is NOT streamed and savePlay==true, we play it. if(savePlay==true && mediaList[editList[curInst].m].content.substr(0,4).toLowerCase()!="rtmp") flvPB.play(); // If the video IS streamed and the player is playing, we have to pause it for the seek to work. if(!flvPB.paused && mediaList[editList[curInst].m].content.substr(0,4).toLowerCase()=="rtmp") flvPB.pause(); flvPB.seek(editList[curInst].tIn); } } else if(mediaList[editList[curInst].m].type=="p"){ babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (editList[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } else if(mediaList[editList[curInst].m].type=="t"){ if(babRunningTimer!=null){ if(babRunningTimer.running==true){ babRunningTimer.stop(); } } babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (babAr[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } //if(Global.flv2==name) trace(name + " playBabInst 2 textLayer = " + textLayer.visible + ", mcContainer = " + mcContainer.visible + ", imageLayer = " + imageLayer.visible + ", flvPB = " + flvPB.visible); currentTcBab = editList[curInst].eIn * 1000; dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; } } else{ if(metas.length>0 && allowFlvPB()){ flvPB.pause(); } babRunning = false; }} //if(Global.flv2==name) trace(name + " playBabInst 2 textLayer = " + textLayer.visible + ", mcContainer = " + mcContainer.visible + ", imageLayer = " + imageLayer.visible + ", flvPB = " + flvPB.visible); } private function drawBgCtn(col:uint):void{ var g:Graphics = bgMcCtn.graphics; g.clear(); g.beginFill(col); g.drawRect(0,0,wMin,hMin-((editSkin) ? 39 : 0)); g.endFill(); } // // Empties the edit arrays // public function empty():void{ editList = []; mediaList = []; babRunning = false; curInst = -1; } // // Get luminance from RGB. Luminance is the sum between the 3 values from 0 to 255 of red, green and blue. // private function RGB2L(c:uint):uint{ var r:uint = (c >> 16) & 0xFF; var g:uint = (c >> 8) & 0xFF; var b:uint = c & 0xFF; var l:uint = r + g + b; return l; } public function get volume():Number{ return flvPB.volume;} private function convertTC(monTC:Number, tenth:Boolean=true) : String { // We do this 2 divisions to keep only 1 number after "." monTC = Math.floor(monTC/100); monTC = (tenth==true) ? monTC/10 : Math.floor(monTC/10); var MaHeu:Number = Math.floor(monTC/3600); var MaMin:Number = Math.floor(monTC/60)-(60*MaHeu); var MaSec:Number = ((monTC*10)%600) / 10; // We have to do that because there is an incomprehensible probleme with %60 var MonTime:String = ((MaHeu<10)?"0":"") + MaHeu + ":" + ((MaMin<10)?"0":"") + MaMin + ":" + ((MaSec<10)?"0":"") + MaSec; return MonTime; } // // External Interface functions // public function playVideo(e:*=null):Boolean{ if(metas.length>0 && allowFlvPB()){ flvPB.play(); if(editSkin) editSkin.isPlaying = true; } debugOutput("playVideo e = " + e); return true; } public function pauseVideo(e:*=null):Boolean{ if(metas.length>0 && allowFlvPB()){ flvPB.pause(); if(editSkin) editSkin.isPlaying = false; } debugOutput("pauseVideo e = " + e); return true; } public function getCurrentTime(e:*=null):Number{ // We send in seconds var tc:Number = Math.floor(currentTcBab) / 1000; debugOutput("getCurrentTime e = " + tc); return tc; } public function seekTo(e:*=null):Boolean{ // e is a number of seconds. we search wich instruction is relative to this timecode try{ e = Number(e); } catch(er:*){ debugOutput("seekToH TIMECODE NOT VALID"); return false; } var nbInst:uint = editList.length; var iToPlay:int = -1; for(var i:uint=0;i=0){ playBabInst(iToPlay, true); // We search the diffence of timecode between the wanted timecode et the instruction's beginning goTo((editList[i].tIn + (e - editList[i].eIn)) * 1000); debugOutput("seekToH e = " + e + " FOUND i = " + iToPlay); } else{ debugOutput("seekToH e = " + e + " NOT FOUND"); } return true; } public function isMuted(e:*=null):Boolean{ var b:Boolean = (flvPB.volume==0); debugOutput("isMuted e = " + b); return b; } public function mute(e:*=null):Boolean{ debugOutput("mute e = " + e); flvPB.volume = 0; lastVolume = flvPB.volume = 0; return true; } public function unMute(e:*=null):Boolean{ debugOutput("unMute e = " + e); flvPB.volume = 0; lastVolume = flvPB.volume = 1; return true; } public function getVolume(e:*=null):Number{ debugOutput("getVolume e = " + volume); return volume; } public function setVolume(e:*=null):Boolean{ flvPB.volume = 0; lastVolume = flvPB.volume = e; debugOutput("setVolume e = " + e); return true; } public function playInstruction(e:*=null):Boolean{ var i:uint = uint(e) - 1; playBabInst(i); debugOutput("playInstruction e = " + e); return true; } private function debugOutput(s:String):void{ if(debugText) debugText.text = "bab " + s; } } } \ No newline at end of file +package bab.player { import fl.video.MetadataEvent; import fl.video.SoundEvent; import fl.video.VideoEvent; import fl.video.VideoScaleMode; import fl.video.VideoState; import flash.display.Graphics; import flash.display.Loader; import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.net.URLRequest; import flash.text.StyleSheet; import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFormatAlign; import flash.utils.Timer; import fl.controls.ProgressBar; import bab.player.events.EditEvent; import flash.utils.getTimer; public class FlvPlayer extends Sprite { private var wMin:Number = 550; private var hMin:Number = 400; public var flvPB:FLVPlaybackLDT; private var widthFlv:uint; private var heightFlv:uint; private var uic:Sprite; private var loading:TextField; private var tcLabel:TextField; private var metas:Array = new Array(); private var curRatio:Number; private var savePlay:Boolean = false; public var editSkin:EditSkin; //private var babAr:Array; private var curInst:int = -1; private var babRunning:Boolean = false; private var babRunningTimer:Timer; public var babSkin:MovieClip; private var babRatio:Number = 1.25; private var editList:Array; private var mediaList:Array; private var instanceToPlay:uint = 0; private var imageLayer:MovieClip; private var pictAr:Array; private var nbPictLoaded:uint; private var mcContainer:Sprite; private var bgMcCtn:Sprite; private var textLayer:TextField; private var styles:StyleSheet; private var tf:TextFormat; private var pb:ProgressBar; private var caption:FLVPlaybackCaptioningLDT; private var fullScreenOn:Boolean = false; public var writeTC:Boolean = true; private var YTPlayer:ExternalPlayer; private var currentTcBab:Number; private var debugText:TextField; private var lastReSeek:uint = getTimer(); private var lastVolume:Number = 1; private var tcToReach:Number = 0; public function FlvPlayer(wInit:Number=550, hInit:Number=400, urlSkin:String="", debug:TextField=null) { super(); wMin = wInit; hMin = hInit; debugText = debug; // Container for text layer, image layer and flvPB uic = new Sprite(); addChild(uic); // Background container mcContainer = new Sprite(); mcContainer.visible = false; uic.addChild(mcContainer); bgMcCtn = new Sprite(); bgMcCtn.graphics.beginFill(0x770000); bgMcCtn.graphics.drawRect(0,0,wMin,hMin); bgMcCtn.graphics.endFill(); mcContainer.addChild(bgMcCtn); // Text layer textLayer = new TextField(); textLayer.width = wMin; tf = new TextFormat("Verdana",12,0xFFFFFF); tf.align = TextFormatAlign.CENTER; textLayer.wordWrap = true; textLayer.visible = false; mcContainer.addChild(textLayer); // Flv playback component flvPB = new FLVPlaybackLDT(); uic.addChild(flvPB); flvPB.autoPlay = false; flvPB.fullScreenTakeOver = false; flvPB.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; //flvPB.skin = urlSkin + "SkinUnderPlaySeekMuteVol.swf"; // urlSkin finishes with a "/" //flvPB.skinBackgroundColor = 0xCCCCCC; flvPB.addEventListener(MetadataEvent.METADATA_RECEIVED, onMDReceived); flvPB.addEventListener(VideoEvent.PLAYHEAD_UPDATE, onPlayheadUpdate); flvPB.addEventListener(VideoEvent.READY, onReady); flvPB.addEventListener(VideoEvent.SEEKED, onSeeked); flvPB.addEventListener(VideoEvent.STATE_CHANGE, onStateChange); caption = new FLVPlaybackCaptioningLDT(); uic.addChild(caption); if(urlSkin!=null && urlSkin!=""){ var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, placeBabSkin); loader.load(new URLRequest(urlSkin)); uic.addChild(loader); tcLabel = new TextField(); tcLabel.text = "[00:00:00]"; tcLabel.textColor = 0xFFFFFF; tcLabel.x = 120; this.addChild(tcLabel); } imageLayer = new MovieClip(); this.addChild(imageLayer); loading = new TextField(); loading.text = "Loading..."; loading.textColor = 0x0000FF; //loading.visible = false; //loading.mouseEnabled = false; //loading.styleSheet.setStyle("horizontalCenter",0); this.addChild(loading); loading.addEventListener(MouseEvent.CLICK, onCCC); pb = new ProgressBar(); pb.visible = false; addChild(pb); } // // On creation complete // private function placeBabSkin(e:Event=null):void { babSkin = e.target.content; //trace("babSkin 2 = " + babSkin.play_mc + ", " + babSkin.pause_mc + ", " + babSkin.back_mc + ", " + babSkin.forward_mc + ", " + babSkin.volumeBarHandle_mc + ", " + babSkin.volumeBar_mc); babSkin.y = heightFlv; babSkin.getChildAt(0).width = widthFlv; babSkin.visible = false; editSkin = new EditSkin(this); editSkin.addEventListener(EditEvent.EDIT_PLAYPAUSE, onEditPlayPause); editSkin.addEventListener(EditEvent.EDIT_BACK, onEditBack); editSkin.addEventListener(EditEvent.EDIT_FORWARD, onEditForward); editSkin.addEventListener(EditEvent.EDIT_SOUNDUPDATE, onEditVolumeUpdate); // usefull to notice edit skin has been loaded. dispatchEvent(new Event(EditEvent.EDIT_CHANGEINSTRUCTION)); } // // load media function // public function loadMedia(path:String, live:Boolean=false, paramPlay:Boolean=false, firstST:String="", extrasAr:Array=null):void{ //trace("loadMedia " + path); stopBab(); // First, we check if the url to load is a Youtube url if(path.search("youtube.com")>-1 || path.search("dailymotion.com")>-1){ pause(); // A valid youtube url is like : http://www.youtube.com/watch?v=PgEu923nxSE or http://www.youtube.com/v/PgEu923nxSE if(YTPlayer==null){ YTPlayer = new ExternalPlayer(uic, path); YTPlayer.addEventListener(VideoEvent.PLAYHEAD_UPDATE, onPlayheadUpdate); YTPlayer.addEventListener(VideoEvent.READY, initSizes); } else YTPlayer.loadVideo(path); curRatio = ExternalPlayer.EXTERNALPLAYER_RATIO; //initSizes(); YTPlayer.visible = true; flvPB.visible = false; } else{ if(YTPlayer!=null) YTPlayer.visible = false; flvPB.visible = true; // We check if the media is already loaded var nbMedias:uint = metas.length; var vp:Number = getVp(path); lastVolume = flvPB.volume; // We stop the current reading if possible if(nbMedias>0 && allowFlvPB()) { flvPB.stop(); } // We load the new content or play the already loaded content if(isNaN(vp)){ vp = metas.length; // We activate the good video player index flvPB.activeVideoPlayerIndex = flvPB.visibleVideoPlayerIndex = vp; flvPB.smoothing = true; //trace("je load " + vp + ", " + path); metas.push({path:path, w:3, h:1, ratio:3}); curRatio = metas[vp].ratio; savePlay = paramPlay; if(live==true){ savePlay = true; flvPB.play(path, NaN, true); } else flvPB.load(path); // Then the window will be resized on metadata received //trace("LoadMedia flvPB.volume : " + flvPB.volume); // sets the volume to 0 (to avoid a bug) then sets it back to its previous level flvPB.volume = 0; flvPB.volume = lastVolume; } else{ // We activate the good video player index flvPB.activeVideoPlayerIndex = flvPB.visibleVideoPlayerIndex = vp; flvPB.smoothing = true; //trace("vp = " + flvPB.activeVideoPlayerIndex + ", " + flvPB.isLive); //trace("je play " + vp + ", " + path); if(allowFlvPB()){ savePlay==false ? flvPB.pause() : flvPB.play(); } // sets the volume to 0 (to avoid a bug) then sets it back to its previous level flvPB.volume = 0; flvPB.volume = lastVolume; // We have to resize the window curRatio = metas[vp].ratio; initSizes(); } // If a subtitle path is indicated we display it var ext:String = firstST.toLowerCase().substr(firstST.length-3); if(ext=="xml"){ caption.source = firstST; } else if(ext=="srt"){ caption.loadSrt(firstST); } // We set the caption/subtitles module to the good videoPlayerIndex index caption.videoPlayerIndex = vp; } } private function getVp(path:String):Number{ // We check if the media is already loaded var i:uint = 0; var nbMedias:uint = metas.length; var vp:Number = NaN; while(i=editList[curInst].tOut && e.state=="playing"){ playBabInst(curInst+1); } //var tcBab:Number; if(mediaList[editList[curInst].m].type=="v"){ //trace(editList[curInst].eIn + ", " + e.playheadTime + ", " + editList[curInst].tIn + ", diff = " + (editList[curInst].tIn - e.playheadTime) + ", last>1 = " + ((getTimer() - lastReSeek)>1000)); // If the current playheadTime is inferior to editList[curInst].tIn more than 3 seconds, we reseek to the tIn. // And we avoid too many seek by waiting 1 sec at least. if((editList[curInst].tIn - e.playheadTime)>3 && (getTimer() - lastReSeek)>1000){ //debugText.text = "HIDE and RESEEK"; if(allowFlvPB()) flvPB.seek(tcToReach); lastReSeek = getTimer(); flvPB.visible = false; flvPB.volume = 0; loading.visible = true; } else{ if((getTimer() - lastReSeek)>1000){ //debugText.text = "SEEK OK"; flvPB.visible = true; flvPB.volume = lastVolume; loading.visible = false; } // We apply max : because of the playhead's approximation, e.playheadTime can be inferior to tIn currentTcBab = Math.max(editList[curInst].eIn*1000,(editList[curInst].eIn + e.playheadTime - editList[curInst].tIn)*1000); //currentTcBab = tcBab; if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; this.dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); } } else if(mediaList[editList[curInst].m].type=="p" || mediaList[editList[curInst].m].type=="t"){ currentTcBab = (editList[curInst].eIn)*1000; if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; this.dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); } } } // // Set the good sizes function of the ratio // public function initSizes(e:VideoEvent=null):void{ // We set hMin and wMin for the video to take the maximum of space. wMax = 415, hMax = 310 /*if((Math.round(424/curRatio)+24+37)>310){ hMin = 310; wMin = (310-24-37)*curRatio; } else{ wMin = 415; hMin = Math.round(wMin/curRatio) + 24 + 37; } if(width-1){ flvPB.setSize(widthFlv,heightFlv); flvPB.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; if(babSkin!=null){ babSkin.y = heightFlv - 3; babSkin.getChildAt(0).width = widthFlv; } var nbChilds:uint = imageLayer.numChildren; for(var i:uint=0;i0 && editListPar.length>0){ instanceToPlay = 0; curInst = -1; // We don't display the different layers textLayer.visible = false; mcContainer.visible = false; imageLayer.visible = false; flvPB.visible = false; // We search for every media var i:uint; editList = editListPar; mediaList = mediaListPar; var nbMedias:uint = mediaList.length; var nbLoaded:uint = metas.length; var canStart:Boolean = true; var a:Array = new Array(); for(i=0;i0){ // We prepare pictAr for(i=0;i0 && allowFlvPB()){ flvPB.pause(); } //displayPict( ((mediaList[editList[curInst].m].content.substr(0,9)=="_resource") ? Global.projPath : "") + mediaList[editList[curInst].m].content); displayPict(mediaList[editList[curInst].m].content); imageLayer.y = 0; babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (babAr[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } else if(mediaList[editList[curInst].m].type=="t"){ // Text case textLayer.visible = true; mcContainer.visible = true; drawBgCtn(mediaList[editList[curInst].m].color); imageLayer.visible = false; flvPB.visible = false; if(metas.length>0 && allowFlvPB()){ flvPB.pause(); } textLayer.htmlText = mediaList[editList[curInst].m].content; // If the color is clear the text will be black, if the color is dark the text will be white. tf.color = (RGB2L(mediaList[editList[curInst].m].color)>(255*3/2)) ? 0x000000 : 0xFFFFFF; textLayer.setTextFormat(tf); textLayer.height = Math.floor(textLayer.textHeight) + 10; textLayer.y = ((hMin-37-37)/2) - (textLayer.textHeight/2); if(babRunningTimer!=null){ if(babRunningTimer.running==true){ babRunningTimer.stop(); } } babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (babAr[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } //if(Global.flv2==name) trace(name + " playBabInst textLayer = " + textLayer.visible + ", mcContainer = " + mcContainer.visible + ", imageLayer = " + imageLayer.visible + ", flvPB = " + flvPB.visible); //trace("4* tcBab = " + (editList[curInst].eIn*1000)); currentTcBab = editList[curInst].eIn * 1000; dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; } // Else we run the current segment from the beginning else if(curInst==i){ babRunning = true; if(babRunningTimer!=null){ if(babRunningTimer.running==true){ babRunningTimer.stop(); } } //if(Global.flv2==name) trace(name + " 2 type m = " + mediaList[editList[curInst].m].type); //trace("m " + mediaList[editList[curInst].m].type + ", c = " + mediaList[editList[curInst].m].content + ", col = " + mediaList[editList[curInst].m].color); if(mediaList[editList[curInst].m].type=="v"){ savePlay = paramPlay; //if(Global.flv2==name) trace(name + " 2 vp = " + vp); if(allowFlvPB()){ // If the video is NOT streamed and savePlay==true, we play it. if(savePlay==true && mediaList[editList[curInst].m].content.substr(0,4).toLowerCase()!="rtmp") flvPB.play(); // If the video IS streamed and the player is playing, we have to pause it for the seek to work. if(!flvPB.paused && mediaList[editList[curInst].m].content.substr(0,4).toLowerCase()=="rtmp") flvPB.pause(); tcToReach = editList[curInst].tIn; flvPB.seek(tcToReach); } } else if(mediaList[editList[curInst].m].type=="p"){ babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (editList[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } else if(mediaList[editList[curInst].m].type=="t"){ if(babRunningTimer!=null){ if(babRunningTimer.running==true){ babRunningTimer.stop(); } } babRunningTimer = new Timer(250, editList[i].tOut*4); //trace("je lance un timer sur " + (babAr[i].tOut*4)); babRunningTimer.addEventListener(TimerEvent.TIMER, onRunningTimer); babRunningTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeTimer); babRunningTimer.start(); if(paramPlay==false){ onEditPlayPause(); } } //if(Global.flv2==name) trace(name + " playBabInst 2 textLayer = " + textLayer.visible + ", mcContainer = " + mcContainer.visible + ", imageLayer = " + imageLayer.visible + ", flvPB = " + flvPB.visible); currentTcBab = editList[curInst].eIn * 1000; dispatchEvent(new EditEvent(EditEvent.EDIT_UPDATETC, currentTcBab)); if(tcLabel) tcLabel.text = "[" + convertTC(currentTcBab, false) + "]"; } } else{ if(metas.length>0 && allowFlvPB()){ flvPB.pause(); } babRunning = false; }} //if(Global.flv2==name) trace(name + " playBabInst 2 textLayer = " + textLayer.visible + ", mcContainer = " + mcContainer.visible + ", imageLayer = " + imageLayer.visible + ", flvPB = " + flvPB.visible); } private function drawBgCtn(col:uint):void{ var g:Graphics = bgMcCtn.graphics; g.clear(); g.beginFill(col); g.drawRect(0,0,wMin,hMin-((editSkin) ? 39 : 0)); g.endFill(); } // // Empties the edit arrays // public function empty():void{ editList = []; mediaList = []; babRunning = false; curInst = -1; } // // Get luminance from RGB. Luminance is the sum between the 3 values from 0 to 255 of red, green and blue. // private function RGB2L(c:uint):uint{ var r:uint = (c >> 16) & 0xFF; var g:uint = (c >> 8) & 0xFF; var b:uint = c & 0xFF; var l:uint = r + g + b; return l; } public function get volume():Number{ return flvPB.volume;} private function convertTC(monTC:Number, tenth:Boolean=true) : String { // We do this 2 divisions to keep only 1 number after "." monTC = Math.floor(monTC/100); monTC = (tenth==true) ? monTC/10 : Math.floor(monTC/10); var MaHeu:Number = Math.floor(monTC/3600); var MaMin:Number = Math.floor(monTC/60)-(60*MaHeu); var MaSec:Number = ((monTC*10)%600) / 10; // We have to do that because there is an incomprehensible probleme with %60 var MonTime:String = ((MaHeu<10)?"0":"") + MaHeu + ":" + ((MaMin<10)?"0":"") + MaMin + ":" + ((MaSec<10)?"0":"") + MaSec; return MonTime; } // // External Interface functions // public function playVideo(e:*=null):Boolean{ if(metas.length>0 && allowFlvPB()){ flvPB.play(); if(editSkin) editSkin.isPlaying = true; } debugOutput("playVideo e = " + e); return true; } public function pauseVideo(e:*=null):Boolean{ if(metas.length>0 && allowFlvPB()){ flvPB.pause(); if(editSkin) editSkin.isPlaying = false; } debugOutput("pauseVideo e = " + e); return true; } public function getCurrentTime(e:*=null):Number{ // We send in seconds var tc:Number = Math.floor(currentTcBab) / 1000; debugOutput("getCurrentTime e = " + tc); return tc; } public function seekTo(e:*=null):Boolean{ // e is a number of seconds. we search wich instruction is relative to this timecode try{ e = Number(e); } catch(er:*){ debugOutput("seekToH TIMECODE NOT VALID"); return false; } var nbInst:uint = editList.length; var iToPlay:int = -1; for(var i:uint=0;i=0){ // We search the diffence of timecode between the wanted timecode et the instruction's beginning playBabInst(iToPlay, true, (editList[iToPlay].tIn + (e - editList[iToPlay].eIn))); debugOutput("seekToH e = " + e + " FOUND i = " + iToPlay + ", realTC = " + ((editList[iToPlay].tIn + (e - editList[iToPlay].eIn)) * 1000)); } else{ debugOutput("seekToH e = " + e + " NOT FOUND"); } return true; } public function isMuted(e:*=null):Boolean{ var b:Boolean = (flvPB.volume==0); debugOutput("isMuted e = " + b); return b; } public function mute(e:*=null):Boolean{ debugOutput("mute e = " + e); flvPB.volume = 0; lastVolume = flvPB.volume = 0; return true; } public function unMute(e:*=null):Boolean{ debugOutput("unMute e = " + e); flvPB.volume = 0; lastVolume = flvPB.volume = 1; return true; } public function getVolume(e:*=null):Number{ debugOutput("getVolume e = " + volume); return volume; } public function setVolume(e:*=null):Boolean{ flvPB.volume = 0; lastVolume = flvPB.volume = e; debugOutput("setVolume e = " + e); return true; } public function playInstruction(e:*=null):Boolean{ var i:uint = uint(e) - 1; playBabInst(i); debugOutput("playInstruction e = " + e); return true; } private function debugOutput(s:String):void{ if(debugText) debugText.text = "bab " + s; } private function onCCC(e:*):void{ seekTo("51"); } } } \ No newline at end of file diff -r c96c64fc1a6b -r 1139ce4af5f5 assets/player_bab_ldt/player_bab_ldt.as --- a/assets/player_bab_ldt/player_bab_ldt.as Fri May 11 15:36:22 2012 +0200 +++ b/assets/player_bab_ldt/player_bab_ldt.as Fri May 11 16:04:15 2012 +0200 @@ -1,1 +1,1 @@ -package { import flash.display.MovieClip; import flash.display.StageScaleMode; import bab.XMLInOut; import bab.player.FlvPlayer; import bab.player.events.EditEvent; import flash.text.TextField; import flash.display.StageAlign; import flash.external.*; import flash.system.Security; import flash.events.Event; import fl.video.VideoEvent; import fl.video.VideoState; public class player_bab_ldt extends MovieClip { private var flashVars:Object; private var xio:XMLInOut; private var flvP1:FlvPlayer; private var ar:Array; private var t:TextField; public function player_bab_ldt() { // constructor code Security.allowDomain("*"); Security.allowInsecureDomain("*"); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; // Fuck CS5 "new feature from built-in preloader" : loaderInfo.parameters is from parent.parent.loaderInfo.parameter flashVars = new Object(); if(parent!=null){ if (parent.parent!=null) flashVars = parent.parent.loaderInfo.parameters; else flashVars = parent.loaderInfo.parameters; } else flashVars = loaderInfo.parameters; for(var param:Object in flashVars){ trace(" flashVars " + param + " : " + flashVars[param.toString()]); } //var urlData:String = "../../test/integration/fichiers_bab/yeelen_bab.ldt"; var urlData:String = "test/yeelen_bab.ldt"; if(flashVars["urlData"]!="" && flashVars["urlData"]!=null){ urlData = flashVars["urlData"]; } trace("init w = " + this.width + ", s.w = " + stage.stageWidth + ", h = " + this.height + ", s.h = " + stage.stageHeight); xio = new XMLInOut(this, urlData); } public function youCanStart():void{ trace("youCanStart"); ar = xio.getEditList1(); trace("youCanStart 2 = " + ar.length); //var urlSkin:String = "../../test/integration/fichiers_bab/SkinBoutABout.swf"; var urlSkin:String = ""; if(flashVars["urlSkin"]!="" && flashVars["urlSkin"]!=null){ urlSkin = flashVars["urlSkin"]; } flvP1 = new FlvPlayer(stage.stageWidth, stage.stageHeight, urlSkin, t = new TextField()); if(urlSkin!=null && urlSkin!=""){ flvP1.addEventListener(EditEvent.EDIT_CHANGEINSTRUCTION, youCanStartBab); } flvP1.addEventListener(EditEvent.EDIT_UPDATETC, onBabVideoProgress); flvP1.addEventListener(VideoEvent.STATE_CHANGE, onBabStateChange); addChild(flvP1); t.text = "init s.w = " + stage.stageWidth + ", s.h = " + stage.stageHeight + ", ei.a = " + ExternalInterface.available; t.textColor = 0xBBBBBB; t.width = stage.stageWidth; addChild(t); // External interface management try{ ExternalInterface.addCallback("playVideo", flvP1.playVideo); ExternalInterface.addCallback("pauseVideo", flvP1.pauseVideo); ExternalInterface.addCallback("getCurrentTime", flvP1.getCurrentTime); ExternalInterface.addCallback("seekTo", flvP1.seekTo); ExternalInterface.addCallback("isMuted", flvP1.isMuted); ExternalInterface.addCallback("mute", flvP1.mute); ExternalInterface.addCallback("unMute", flvP1.unMute); ExternalInterface.addCallback("getVolume", flvP1.getVolume); ExternalInterface.addCallback("setVolume", flvP1.setVolume); ExternalInterface.addCallback("playInstruction", flvP1.playInstruction); } catch(e:*){ t.text = "ExternalInterface error catch e = " + e; t.textColor = 0xFFFFFF; } ExternalInterface.call("onBabPlayerReady","cool"); if(urlSkin==null || urlSkin==""){ youCanStartBab(); } } public function youCanStartBab(e:*=null):void{ flvP1.removeEventListener(EditEvent.EDIT_CHANGEINSTRUCTION, youCanStartBab); flvP1.getEditList(ar[0], ar[1]); } private function onBabVideoProgress(e:EditEvent):void{ // e.tc arrives in milliseconds ExternalInterface.call("onBabVideoProgress",{mediaTime:(Math.floor(e.tc)/1000)}); } private function onBabStateChange(e:VideoEvent):void{ var s:Number; // Embeddable adaptation : we limit the number of states // States can be : loading, stopped, seeking (3), paused (2), buffering, playing (1). switch(e.state){ case VideoState.SEEKING: s = 3; break; case VideoState.PAUSED: s = 2; break; case VideoState.PLAYING: s = 1; break; } if(!isNaN(s)){ ExternalInterface.call("onBabStateChange",s); } } } } \ No newline at end of file +package { import flash.display.MovieClip; import flash.display.StageScaleMode; import bab.XMLInOut; import bab.player.FlvPlayer; import bab.player.events.EditEvent; import flash.text.TextField; import flash.display.StageAlign; import flash.external.*; import flash.system.Security; import flash.events.Event; import fl.video.VideoEvent; import fl.video.VideoState; public class player_bab_ldt extends MovieClip { private var flashVars:Object; private var xio:XMLInOut; private var flvP1:FlvPlayer; private var ar:Array; private var t:TextField; public function player_bab_ldt() { // constructor code Security.allowDomain("*"); Security.allowInsecureDomain("*"); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; // Fuck CS5 "new feature from built-in preloader" : loaderInfo.parameters is from parent.parent.loaderInfo.parameter flashVars = new Object(); if(parent!=null){ if (parent.parent!=null) flashVars = parent.parent.loaderInfo.parameters; else flashVars = parent.loaderInfo.parameters; } else flashVars = loaderInfo.parameters; for(var param:Object in flashVars){ trace(" flashVars " + param + " : " + flashVars[param.toString()]); } t = new TextField(); t.text = "init s.w = " + stage.stageWidth + ", s.h = " + stage.stageHeight + ", ei.a = " + ExternalInterface.available; t.textColor = 0xBBBBBB; t.width = stage.stageWidth; addChild(t); //var urlData:String = "../../test/integration/fichiers_bab/yeelen_bab.ldt"; var urlData:String = ""; if(flashVars["urlData"]!="" && flashVars["urlData"]!=null){ urlData = flashVars["urlData"]; } if(urlData!="" && urlData!=null){ xio = new XMLInOut(this, urlData); } else{ t.text = "urlData INVALID"; } } public function youCanStart():void{ trace("youCanStart"); ar = xio.getEditList1(); trace("youCanStart 2 = " + ar.length); //var urlSkin:String = "../../test/integration/fichiers_bab/SkinBoutABout.swf"; var urlSkin:String = ""; if(flashVars["urlSkin"]!="" && flashVars["urlSkin"]!=null){ urlSkin = flashVars["urlSkin"]; } flvP1 = new FlvPlayer(stage.stageWidth, stage.stageHeight, urlSkin, t); if(urlSkin!=null && urlSkin!=""){ flvP1.addEventListener(EditEvent.EDIT_CHANGEINSTRUCTION, youCanStartBab); } flvP1.addEventListener(EditEvent.EDIT_UPDATETC, onBabVideoProgress); flvP1.addEventListener(VideoEvent.STATE_CHANGE, onBabStateChange); addChild(flvP1); // External interface management try{ ExternalInterface.addCallback("playVideo", flvP1.playVideo); ExternalInterface.addCallback("pauseVideo", flvP1.pauseVideo); ExternalInterface.addCallback("getCurrentTime", flvP1.getCurrentTime); ExternalInterface.addCallback("seekTo", flvP1.seekTo); ExternalInterface.addCallback("isMuted", flvP1.isMuted); ExternalInterface.addCallback("mute", flvP1.mute); ExternalInterface.addCallback("unMute", flvP1.unMute); ExternalInterface.addCallback("getVolume", flvP1.getVolume); ExternalInterface.addCallback("setVolume", flvP1.setVolume); ExternalInterface.addCallback("playInstruction", flvP1.playInstruction); } catch(e:*){ t.text = "ExternalInterface error catch e = " + e; t.textColor = 0xFFFFFF; } ExternalInterface.call("onBabPlayerReady","cool"); if(urlSkin==null || urlSkin==""){ youCanStartBab(); } } public function youCanStartBab(e:*=null):void{ flvP1.removeEventListener(EditEvent.EDIT_CHANGEINSTRUCTION, youCanStartBab); flvP1.getEditList(ar[0], ar[1]); } private function onBabVideoProgress(e:EditEvent):void{ // e.tc arrives in milliseconds ExternalInterface.call("onBabVideoProgress",{mediaTime:(Math.floor(e.tc)/1000)}); } private function onBabStateChange(e:VideoEvent):void{ var s:Number; // Embeddable adaptation : we limit the number of states // States can be : loading, stopped, seeking (3), paused (2), buffering, playing (1). switch(e.state){ case VideoState.SEEKING: s = 3; break; case VideoState.PAUSED: s = 2; break; case VideoState.PLAYING: s = 1; break; } if(!isNaN(s)){ ExternalInterface.call("onBabStateChange",s); } } } } \ No newline at end of file diff -r c96c64fc1a6b -r 1139ce4af5f5 assets/player_bab_ldt/player_bab_ldt.swf Binary file assets/player_bab_ldt/player_bab_ldt.swf has changed